Program TSTCASTWO;

{ Version 
  File:[22,311]TSTCastwo.PAS
  Author: Jim Bostwick 18-oct-83
  History:

    Phil Hannay.  15-Jan-86.  Enhanced test to test both type 0 and type 1
      strings.

Testing P3UTIL module(s): castwo

}

{$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]CASTWO.EXT';

{$list}


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

BEGIN
  writeln('ascii to word conversion test');  
  writeln('first using a type 0 string...');
  writeln('enter a line of numbers, separated by comma, tab, or space:');
  sread(input,s);
  while s[0] <> chr(0) do 
    BEGIN 
    write('radix:');
    readln(radix);
    p := 1;
    repeat
      castwo(s,w,p,radix);
      if p<0 then begin
        { word overflow}
        write('overflow, ');
        p:= p * (-1);
        end
        else begin
        write(w,', ')
        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 using a type 1 string...');
  writeln('enter a line of numbers, separated by comma, tab, or space:');
  sread(input,z);
  while z[1] <> chr(0) do 
    BEGIN 
    write('radix:');
    readln(radix);
    p := 1;
    repeat
      castwo(z,w,p,radix);
      if p<0 then begin
        { word overflow}
        write('overflow, ');
        p:= p * (-1);
        end
        else begin
        write(w,', ')
        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.

      
