Inicio > Foros
Resultados 1 al 3 de 3
Tema: Ayuda con una funcion en pascal standard extendido
-
10/01/2006, 17:01Magnum
- Fecha de ingreso
- 25 abr, 05
- Ubicación
- La Coruña
- Mensajes
- 74
Ayuda con una funcion en pascal standard extendido
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
Os pongo el procedure para que veais las variables.
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;
-
11/01/2006, 22:36Magnum
- Fecha de ingreso
- 25 abr, 05
- Ubicación
- La Coruña
- Mensajes
- 74
Ya lo he solucionado, he tenido que cambiar esa funcion :lol:
Se puede Cerrar.
-
11/01/2006, 22:59Murphi
- Fecha de ingreso
- 21 ene, 05
- Ubicación
- L´H*(BCN)
- Mensajes
- 5,245
Pos....Lo suyo seria,ya que Pascal casi no se trata aqui,que pusieras como lo has hecho,pal que viene detras mas que nada....
Salu2
Powered by vBulletin® Version 4.2.5
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.
Traducción por vBulletin Castellano Copyright © 2025.
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.
Traducción por vBulletin Castellano Copyright © 2025.