PROGRAM Greeting;
  {$M $8000,0,0 }
  USES Dos;
  CONST
    Days : Array [0..6] of String[9] = ('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday');
    Month : Array [1..6] of String[9] = ('January','February','March','April','May','June');
    Months : Array [7..12] of String[9] = ('July','August','September','October','November','December');

  VAR
    D, Mn, Y, Dow, H, M, S : Word;
    Time                   : String [9];
    DateTime               : String [50];
    Day, Hour, Minute      : String [2];
    AmPm                   : String [3];
    Year                   : String [4];
    InitPath               : String [40];

PROCEDURE HourAMPM;
  Begin
    If H > 11 Then
      Begin
      AMPM := ' PM';
      H := H - 12;
      End else
      AMPM := ' AM';
    If H = 0 Then
      H := 12;
  End;

PROCEDURE TimeOfDay;
  Begin
    If AMPM = ' AM' Then
      Time := 'Morning' else
      Begin
        If H < 6 Then Time := 'afternoon' else
        Time := 'evening';
        If H = 12 Then Time := 'afternoon';
      End;
  End;

FUNCTION LeadingZero(w : Word) : String;
  VAR
    S : String;
  Begin
    Str(w:0,s);
    if Length(s) = 1 then
      s := '0' + s;
    LeadingZero := s;
  End;

BEGIN
  GetDate(Y,Mn,D,Dow);
  GetTime(H,M,S,S);
  GetDir(3,InitPath);
  HourAMPM;
  TimeOfDay;
  Str (D,Day);
  Str (Y,Year);
  Str (H,Hour);
  DateTime := Hour + ':' + LeadingZero(M) + AMPM + ' on ' + Days[Dow] + ', ' + Month[Mn] +  ' ' + Day + ', ' + Year + '.';
  SwapVectors;
  ChDir('C:\SB\SBTALKER');
  Exec('C:\SB\SBTALKER\SBTALKER.EXE','/dBLASTER');
  Exec('C:\SB\SBTALKER\SAY.EXE', '"Good ' + Time + ', it is ' + DateTime + '  What can I do for you?"');
  Exec('C:\SB\SBTALKER\REMOVE.EXE','');
  ChDir(InitPath);
  SwapVectors;
END.