Program TSTCASTBC;

{ Version
  File:[22,310]TSTCASTBC.PAS
  Author: Jim Bostwick 18-Oct-83
  History:


Testing P3UTIL module(s): CASTBC, CBCTAS, CBCTWO

}

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

TYPE
  String = packed array [0..80] of char;

VAR
  s,s2:string;
  p:integer;
  b4:bcd4;
  b10:packed array [1..10] of bcd_digit;
  i,pos:integer;
  W:Word;

BEGIN
  writeln('bcd <-> ASCII conversion test');
  writeln('enter one or more bcds, separated by tab, comma, space:');
  sread(input,s);  
  repeat
    { convert to bcd4 }
    p := 1;
    repeat
      castbc(s,b4,p);
      for i := 1 to 4 do write(chr(ord('0') + b4[i]),',');
      writeln;
      cbctwo(b4,w);
      write('convert bcd4 to word:',w);
      s2[0] := chr(0);
      write('output position:');
      readln(pos);
      cbctas(b4,s2,pos);
      swrite(output,s2);
      if s[p] = ',' then p := p+1;
    until p >= ord(s[0]);
    writeln;
    writeln('enter one or more bcds, separated by tab, comma, space:');
    sread(input,s);  
  until s[0] = chr(0);
writeln('end of test')
end.

