home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / simtel / sigm / vols000 / vol023 / dastrfix.lib < prev    next >
Text File  |  1984-04-29  |  1KB  |  57 lines

  1.  
  2. {    DASTRFIXED
  3.  
  4.     Takes an integer date value and returned an eight-character
  5.     string for month, day and year.
  6.  
  7.     If SPACES is passed as true, a leading zero will be converted
  8.     to a space in the month and day positions.
  9.  
  10.     The separator character is provided as '-' but is declared
  11.     as a constant so can be changed fairly easily.
  12.  
  13.     The following global types must be declared:
  14.         TYPE    string255 = string 255;
  15.             byte = 0..255;
  16.  
  17.     The following additional procedures must be declared:
  18.         PROCEDURE breakdate;
  19.         PROCEDURE setlength; external;
  20. }
  21.  
  22. FUNCTION strbyte (val : byte; withspace : boolean) : string255;
  23.  
  24. CONST    zero = 48;
  25.  
  26. VAR    ch : char;
  27.     str : string255;
  28.  
  29. begin
  30.     setlength (str,0);
  31.     if (val div 10 = 0) and withspace
  32.         then str := ' '
  33.         else str := chr (val div 10 + zero);
  34.     append (str,chr(val mod 10 + zero));
  35.     strbyte := str
  36. end;
  37.  
  38. FUNCTION dastrfixed (days : integer; spaces : boolean) : string255;
  39.  
  40. CONST    zero = 48;
  41.     separator = '-';
  42.  
  43. VAR    day, mo, da, yr : byte;
  44.     str : string255;
  45.  
  46. begin
  47.     brkdate (days,mo,da,yr,day);
  48.     setlength (str,0);
  49.     append (str,strbyte(mo,spaces));
  50.     append (str,separator);
  51.     append (str,strbyte(da,spaces));
  52.     append (str,separator);
  53.     append (str,strbyte(yr,false));
  54.     dastrfixed := str
  55. end;
  56.  
  57.