Resultados 1 al 3 de 3

Tema: Ayuda con una funcion en pascal standard extendido

  1. Magnum
    Magnum está desconectado
    Usuario registrado
    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;

  2. Magnum
    Magnum está desconectado
    Usuario registrado
    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.

  3. Murphi
    Murphi está desconectado
    Usuario registrado CV
    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