{+++++++++++++++++++++++++++++++++++++} {+ STRING TO INTEGER +} {+++++++++++++++++++++++++++++++++++++} Function IVAL( var st: dstring; { alphanumeric string to be converted } var int: integer { returned integer } ): integer; { error_status := IVAL( alphanumeric, returned_integer ); RETURNS: error_status > 0 NUMERIC STRING and int = integer number = 0 NON-NUMERIC STRING = -1 OVERFLOW EXAMPLE: write( 'Chose one answer only: ' ); readln( answer ); err := IVAL( answer, n ); if err>0 then else begin if err=0 then if err<0 then end; } label 1,2; const zero = 48; { ORD('0'); } var inx, len: integer; signed, negating: boolean; ch: char; special, numeric: set of char; begin numeric := ['0'..'9']; special := numeric + ['+','-']; signed := false; negating := false; int := 0; {+++ SCAN STRING FOR NON-NUMERIC CHARS +++} len := length(st); for inx:=1 to len do begin ch := st[inx]; if ( ch IN numeric ) then {EXIT} goto 2 else if ( ch IN ['+','-'] ) and ( inx