Program TSTCASTIN;

{ Version 
  File:[22,311]TSTCastin.PAS
  Author: Phil Hannay.  15-Jan-86.
  Last Edit: 16-JAN-1987 18:12:01 
  History:


Testing P3UTIL module(s): castin

}

{$nolist}
{[a+,b+,l-,k+,r+] Pasmat }
%INCLUDE 'EX:[22,320]GENERAL3.TYP';
%INCLUDE 'EX:[22,320]SREAD.EXT';
%INCLUDE 'EX:[22,320]SWRITE.EXT';
%INCLUDE 'EX:[22,320]SLEN.EXT';
%INCLUDE 'EX:[22,320]CASTIN.EXT';

{$list}


TYPE
  String = packed array [0..80] of char;
VAR
  i:integer;
  p:integer;
  s:string;
  z:ch80;

BEGIN
  writeln('ascii to word conversion test');  
  writeln('first we do type 0 strings (arrays)...');
  writeln('enter a line of numbers, separated by comma, tab, or space:');
  sread(input,s);
  { do while input string is not zero characters long }
  while s[0] <> chr(0) do 
    BEGIN 
    p := 1;
    repeat
      castin(s,i,p);
      if p < 0 
        then begin
          { integer overflow }
          write ( 'overflow, ');
          p:= p * (-1);
          end
        else begin
          write(i:1,', ')
          end;
      p := p + 1; {skip terminator }
     until p >slen(s);
    writeln;
    writeln('enter a line of numbers, separated by comma, tab, or space:');
    sread(input,s)
    END;
  writeln;
  writeln('next we do type 1 strings (arrays)...');
  writeln('enter a line of numbers, separated by comma, tab, or space:');
  sread(input,z);
  while z[1] <> chr(0) do 
    BEGIN 
    p := 1;
    repeat
      castin(z,i,p);
      if p < 0 
        then begin
          { integer overflow }
          write ( 'overflow, ');
          p:= p * (-1);
          end
        else begin
          write(i:1,', ')
          end;
      p := p + 1; {skip terminator }
     until p > slen(z);
    writeln;
    writeln('enter a line of numbers, separated by comma, tab, or space:');
    sread(input,z);
    END;
  writeln('end of test.')
end.

      
