home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 December / PCO1296.ISO / filesbbs / dos / terminat.arj / DEVELOP.EXE / STARTIME.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-08-13  |  1.4 KB  |  51 lines

  1. {$M 4096,0,1024}
  2. { Terminate help file      }
  3. { Made 1993 by Bo Bendtsen }
  4.  
  5. Uses Dos,Crt;
  6.  
  7. Var
  8.   Param    : String;
  9.   ph, pm   : Word;
  10.   h,m,s,hu : Word;
  11.   ch       : Char;
  12.  
  13. Function StrToInt(S: String) : LongInt;
  14. Var Kode,i : Integer;
  15. Begin
  16.   If Length(S) = 0 Then StrToInt := 0 Else Begin Val(S,i,Kode);
  17.     If Kode = 0 Then StrToInt := i Else StrToInt := 0; End;
  18. End;
  19.  
  20. Function IntToNulStr(i: LongInt;b:Byte): String;
  21. Var S : String[11];
  22. Begin
  23.   Str(i, S); While Length(S)<b Do S:='0'+S;
  24.   If Length(S)>b Then S:='?'+Copy(S,Length(S)-b+2,10); IntToNulStr:=S;
  25. End;
  26.  
  27. Begin
  28.   WriteLn(#13#10'Another Terminate utility');
  29.   If Paramcount<2 Then
  30.   Begin
  31.     WriteLn(#13#10#10'Start program at time. Syntax: STARTIME HH:MM Program parameters');
  32.     WriteLn('STARTIME 03:00 TERMINAT /BOSS:1');
  33.     Halt;
  34.   End;
  35.   Param:=ParamStr(1); ch:=#0;
  36.   ph:=StrToInt(Copy(Param,1,2)); pm:=StrToInt(Copy(Param,4,2));
  37.   Param:=''; For h:=2 to Paramcount Do Param:=Param+ParamStr(h)+' ';
  38.   WriteLn(#13#10#10'Starting: '+Param+' at time '+Paramstr(1));
  39.   Repeat
  40.     Gettime(h,m,s,hu);
  41.     Write(#13+IntToNulStr(h,2)+':'+IntToNulStr(m,2)+':'+IntToNulStr(s,2));
  42.     If KeyPressed Then Ch:=Readkey; Delay(250);
  43.   Until (ch=#$1B) or ((h=ph) and (m=pm));
  44.   If ch<>#$1B Then
  45.   Begin
  46.     SwapVectors;
  47.     Exec(GetEnv('COMSPEC'),' /C '+Param);
  48.     SwapVectors;
  49.   End;
  50. End.
  51.