Pascal/Turbo Pascal - Ayuda con una funcion en Pascal Standar Extendido

 
Vista:

Ayuda con una funcion en Pascal Standar Extendido

Publicado por Antonio Rodriguez (2 intervenciones) el 10/01/2006 16:14:23
Buenas! Necesito que alguien me ayude con una funcion que pase de String a Integer, yo lo intente con esto

function Integ (NumeroString : tIndiceStr): integer;
var h : 1..4;
NumeroInteger : 0..n;
begin
NumeroInteger := 0;
for h := 1 to length(NumeroString) do
NumeroInteger := NumeroInteger * 10 + ord(NumeroString[h])
- ord('0');
Integ := NumeroInteger
end;

pero no funciona bien y me cierra el programa, si alguien sabe como arreglar ese codigo para que funcione se lo agradeceria mucho

Gracias por vuestra paciencia
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:Ayuda con una funcion en Pascal Standar Extendi

Publicado por Antonio Rodriguez (2 intervenciones) el 10/01/2006 16:17:56
perdon os pongo el procedure que sino no se ven las variables generales



procedure PedirIndice; type tIndiceStr = string(4);
var IndiceValido : boolean;
IndiceStr : tIndiceStr;
h : integer;

function Integ (NumeroString : tIndiceStr): integer;
var h : 1..4;
NumeroInteger : 0..n;
begin
NumeroInteger := 0;
for h := 1 to length(NumeroString) do
NumeroInteger := NumeroInteger * 10 + ord(NumeroString[h])
- ord('0');
Integ := NumeroInteger
end;

begin
repeat
writeln;
write(' Indice : ');
readln(IndiceStr);

IndiceValido := true;
case length(IndiceStr) of
1 : if not(IndiceStr[1] in ['1'..'9']) then IndiceValido := false;
2 : if not(IndiceStr[1] in ['1'..'9'])
or not(IndiceStr[2] in ['0'..'9']) then IndiceValido := false;
3 : if not(IndiceStr = '100') then IndiceValido := false;
otherwise IndiceValido := false
end;

if not(IndiceValido)
then begin
writeln;
writeln;
writeln('- Indice invalido -':50);
writeln
end
else if not(Integ(IndiceStr) in ConjIndices)
then begin
writeln;
writeln;
writeln('- El indice no corresponde con ninguno de los registros mostrados -':73);
writeln;
IndiceValido := false
end;

if not(IndiceValido) then begin
repeat
writeln;
writeln(' 1 -> Selecionar otro ');
writeln(' 2 -> Buscar ');
writeln(' 3 -> Volver a menu ');
write(' ');readln(opcion)
until (length(opcion) = 1)
and_then (opcion[1] in['1','2','3']);

if opcion = '2' then begin
IndiceValido := true;
CantIndices := 0
end;
if opcion = '3' then SubMenu := Principal
end;

until IndiceValido or (SubMenu = Principal)
end;
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar