home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TPTOOL1.ZIP / ATOI.INC < prev    next >
Encoding:
Text File  |  1987-05-08  |  498 b   |  33 lines

  1.  
  2. #log Ascii to integer conversion
  3.  
  4. (*
  5.  *
  6.  * converts ascii string to an integer value
  7.  *
  8.  *)
  9.  
  10. function atoi (asc:           anystring): integer;
  11. var
  12.    code:          integer;
  13.    value:         integer;
  14.  
  15. begin
  16.    while copy(asc,1,1) = ' ' do
  17.       delete(asc,1,1);
  18.  
  19.    if asc = '' then
  20.       value := 0
  21.    else
  22.  
  23.    begin
  24.       val(asc, value, code);
  25.       if code <> 0 then
  26.          if asc[code] <> ' ' then
  27.             value := 0;
  28.    end;
  29.  
  30.    atoi := value;
  31. end;
  32.  
  33.