program tstclu;

{ This is a test program just to see how clunks work. 
	 LAST EDIT: 6-JUN-1987 11:51:29 
}

%INCLUDE LB:[22,320]GENERAL3.TYP;
%INCLUDE DE:[107,113]CLUNK.TYP;
%INCLUDE DE:[107,113]A2CLNK.EXT;
%INCLUDE DE:[107,113]D2CLNK.EXT;
%INCLUDE DE:[107,113]C2DATE.EXT;
%INCLUDE DE:[107,113]S2CLNK.EXT;
%INCLUDE DE:[107,113]C2WDAY.EXT;
var
  i,j,k : integer;
  dummy : text;

procedure the_works;

var
  int_clunk : clunk_type;
  clunk1,clunk2 : clunk_type;
  sdate,ndate : DEC_Date;
  stime,ntime : DEC_Time;
  ids : integer;
  i : integer;
  add_days : integer;
  add_hours : integer;
  add_minutes : integer;
  add_seconds : integer;
  add_on : integer;
  sign : integer;
  diff_day : integer;
  diff_hour : integer;
  diff_min : integer;
  diff_sec : integer;
  week_day : integer;

begin 
  repeat
    for i := 1 to 4 do
    begin
      int_clunk[i] := 0;
      clunk1[i] := 0;
      clunk2[i] := 0;
    end;
  
    diff_day := 0;
    diff_hour := 0;
    diff_min := 0;
    diff_sec := 0;

    write('DATE:');
    readln(sdate);
    write('TIME:');
    readln(stime);
    write('DAYS:');
    readln(add_days);
    write('HOURS:');
    readln(add_hours);
    write('MINUTES:');
    readln(add_minutes);
    write('SECONDS:');
    readln(add_seconds);
    write('UP OR DOWN:');
    readln(add_on);

    writeln;
    writeln('convert to clunk value');  
    d2clnk(int_clunk,sdate,stime,ids);
    writeln(sdate,' ',stime);
  
    write('Return clunk value is:');
    for i := 1 to 4 do
      write(int_clunk[i],' ');
    writeln('IDS:',ids);

    writeln;
    write('Now convert to day of week:');
    c2wday(int_clunk,week_day,ids);

    if (week_day < 8) and (week_day > 0) then
      case week_day of
        1: write('Monday');
        2: write('Tuesday');
        3: write('Wednesday');
        4: write('Thursday');
        5: write('Friday');
        6: write('Saturday');
        7: write('Sunday');
        otherwise write(week_day);
      end
    else
      write(week_day);
    writeln;

    write('Return clunk value is:');
    for i := 1 to 4 do
      write(int_clunk[i],' ');
    writeln('IDS:',ids);

    clunk1 := int_clunk;
     
    writeln;
    writeln('add on entered time');
    a2clnk(int_clunk,add_on,add_days,add_hours,add_minutes,add_seconds,ids);
    
    write('Add or sub:',add_on,' days:',add_days,' hours:',add_hours);
    writeln(' minutes:',add_minutes,' seconds:',add_seconds);

    write('Return clunk value is:');
    for i := 1 to 4 do
      write(int_clunk[i],' ');
    writeln('IDS:',ids);

    clunk2 := int_clunk;

    writeln;
    write('Convert to new day of week:');
    c2wday(int_clunk,week_day,ids);
    if (week_day < 8) and (week_day > 0) then
      case week_day of
        1: write('Monday');
        2: write('Tuesday');
        3: write('Wednesday');
        4: write('Thursday');
        5: write('Friday');
        6: write('Saturday');
        7: write('Sunday');
        otherwise write(week_day);
      end
    else
      write(week_day);
    writeln;

    write('Return clunk value is:');
    for i := 1 to 4 do
      write(int_clunk[i],' ');
    writeln('IDS:',ids);

    writeln;
    writeln('Convert back to date');
    ndate := '         ';
    ntime := '        ';
    c2date(int_clunk,ndate,ntime,ids);
    writeln(ndate,' ',ntime);

    write('Return clunk value is:');
    for i := 1 to 4 do
      write(int_clunk[i],' ');
    writeln('IDS:',ids);
 
    writeln;
    writeln('Find difference between dates');
    s2clnk(clunk2,clunk1,sign,diff_day,diff_hour,diff_min,diff_sec,ids);

    write('sign:',sign:4,' diff_days:',diff_day,' diff_hour:',diff_hour:4);
    writeln(' diff_min:',diff_min:4,' diff_sec:',diff_sec:4);

    write('Return clunka value is:');
    for i := 1 to 4 do
      write(clunk2[i],' ');
    writeln;
 
    write('Return clunkb value is:');
    for i := 1 to 4 do
      write(clunk1[i],' ');
    writeln('IDS:',ids);
 
  until sdate[1] = '9';

end;

begin {main}
  rewrite(dummy,'DUMMY.TXT','/RW');
  the_works;
  writeln(dummy,'just testing');
  close(dummy);
end.
