home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / pascal / tplib21.zip / INSTALL.EXE / EXTIME.PAS < prev    next >
Pascal/Delphi Source File  |  1993-05-30  |  4KB  |  112 lines

  1. (* Example program: TIME unit *)
  2.  
  3. PROGRAM EXTIME;
  4.  
  5. USES 
  6.     STRINGS, TIME;
  7.  
  8. VAR
  9.     s:  STRING;
  10.  
  11.  
  12. PROCEDURE ExOpt1;
  13.  
  14.     VAR
  15.         d:  DateRec;
  16.  
  17.     BEGIN
  18.       WriteLn ('At each prompt enter a string that represents a date.  The');
  19.       WriteLn ('DateParse function is used to convert your input to a date');
  20.       WriteLn ('record and the program then shows examples of formatted');
  21.       WriteLn ('output.  Enter "Q" to exit.');
  22.       DateDelimiter := '-';
  23.       REPEAT
  24.           WriteLn;
  25.           Write ('Enter date : ');
  26.           ReadLn(s);
  27.           IF UpperCase(s)='Q' THEN EXIT;
  28.           IF DateParse(s,d) THEN
  29.               BEGIN
  30.                   WriteLn ('Date accepted');
  31.                   DateFormat := DateFormNumeric;
  32.                   WriteLn('Numeric format     = "', DateStr(d), '"');
  33.                   DateFormat := DateFormAlpha;
  34.                   WriteLn('Alphabetic format  = "', DateStr(d), '"');
  35.                   DateFormat := DateFormMDY;
  36.                   WriteLn('MDY format         = "', DateStr(d), '"');
  37.                   DateFormat := DateFormDMY;
  38.                   WriteLn('DMY format         = "', DateStr(d), '"');
  39.                   DateFormat := DateFormNumeric;
  40.                   FullDateFormat := FullDateFormMDY;
  41.                   WriteLn('Full format MDY    = "', FullDateStr(d), '"');
  42.                   FullDateFormat := FullDateFormDMY;
  43.                   WriteLn('Full format DMY    = "', FullDateStr(d), '"');
  44.                   WriteLn('Day                = "',
  45.                   DayOfWeekStr(DayOfWeek(DateToWord(d))),'"');
  46.               END
  47.           ELSE
  48.               WriteLn ('Cannot convert typed string to date - Try again');
  49.       UNTIL FALSE;
  50.     END;  { ExOpt1 }
  51.  
  52.  
  53. PROCEDURE ExOpt2;
  54.  
  55.     VAR
  56.         t:  TimeRec;
  57.  
  58.     BEGIN
  59.         WriteLn ('At each prompt enter a string that represents a time.  The');
  60.         WriteLn ('TimeParse function is used to convert your input to a time');
  61.         WriteLn ('record and the program then shows examples of formatted');
  62.         WriteLn ('output.  Enter "Q" to exit.');
  63.         REPEAT
  64.             WriteLn;
  65.             Write('Input time: ');
  66.             ReadLn(s);
  67.             IF UpperCase(s)='Q' THEN EXIT;
  68.             IF TimeParse(s,t) THEN
  69.                 BEGIN
  70.                     TimeFormat:=TimeFormNormal;
  71.                     WriteLn('TimeFormNormal       = "',TimeStr(t),'"');
  72.                     TimeFormat:=TimeFormNormalSec;
  73.                     WriteLn('TimeFormNormalSec    = "',TimeStr(t),'"');
  74.                     TimeFormat:=TimeFormShort;
  75.                     WriteLn('TimeFormShort        = "',TimeStr(t),'"');
  76.                     TimeFormat:=TimeFormShortSec;
  77.                     WriteLn('TimeFormShortSec     = "',TimeStr(t),'"');
  78.                     TimeFormat:=TimeFormMilitary;
  79.                     WriteLn('TimeFormMilitary     = "',TimeStr(t),'"');
  80.                     TimeFormat:=TimeFormMilitarySec;
  81.                     WriteLn('TimeFormMilitarySec  = "',TimeStr(t),'"');
  82.                     TimeFormat:=TimeFormMilitaryHHMM;
  83.                     WriteLn('TimeFormMilitaryHHMM = "',TimeStr(t),'"');
  84.                 END
  85.             ELSE
  86.                 WriteLn('Cannot convert typed string - Try again.');
  87.         UNTIL FALSE;
  88.     END;  { ExOpt2 }
  89.  
  90.  
  91. BEGIN  { ExTime }
  92.     WriteLn('EXTIME - TIME UNIT EXAMPLE PROGRAM');
  93.     WriteLn;
  94.     REPEAT
  95.         WriteLn;
  96.         WriteLn('Select the features you wish to try:');
  97.         WriteLn;
  98.         WriteLn('    1.  Date parsing.');
  99.         WriteLn('    2.  Time parsing');
  100.         WriteLn;
  101.         Write('Enter option or zero to quit : ');
  102.         ReadLn(s);
  103.         s:=TrimL(s);
  104.         WriteLn;
  105.         CASE s[1] OF
  106.             '1':    ExOpt1;
  107.             '2':    ExOpt2;
  108.         END;
  109.     UNTIL s[1]='0';
  110. END.
  111.  
  112.