home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / MISC / DEMO510.ZIP / DIRMNT3.INS / ENVDATE.PAS < prev   
Pascal/Delphi Source File  |  1999-01-25  |  1KB  |  57 lines

  1.  
  2. Program EnvDate;
  3.  
  4.   { Set the environment variable 'DATE' to the current system date, in
  5.     the format YYMMDD. Then execute the command line parameter(s) as a
  6.     subprocess (invoking COMMAND.COM).  }
  7.  
  8. {$M 2048,0,0}
  9.  
  10. Uses DOS;
  11.  
  12. type charray = array[1..1] of char;
  13.      chptr = ^charray;
  14.  
  15. var path,command,date,t: string;
  16.     year,month,day,dayofweek: word;
  17.     p: chptr;
  18.     i,j: integer;
  19.  
  20.  
  21. Begin
  22.   GetDate(Year,Month,Day,DayOfWeek);      { Get the system date }
  23.  
  24.   str(year-1900:2,date);              { Build date string: DATE=YYMMDD }
  25.   str(month:2,t);
  26.   if (t[1]=' ') then t[1]:='0';
  27.   date:=date+t;
  28.   str(day:2,t);
  29.   if (t[1]=' ') then t[1]:='0';
  30.   date:=date+t;
  31.   date:='DATE='+date;
  32.  
  33.   p:=Ptr(MemW[PrefixSeg:$2C],0);      { Get ptr to environment }
  34.  
  35.   i:=1;
  36.   repeat                              { Find end of environment }
  37.     inc(i)
  38.   until (p^[i]=#0) and (p^[i-1]=#0);
  39.  
  40.   for j:=1 to length(date) do begin   { Load string into environment }
  41.     p^[i]:=date[j];
  42.     inc(i);
  43.   end;
  44.   p^[i]:=#0;
  45.   p^[i+1]:=#0;
  46.  
  47.   path:=GetEnv('COMSPEC');            { Get COMMAND.COM spec }
  48.   command:='';
  49.   for j:=1 to ParamCount do           { Build command line }
  50.     command:=command+ParamStr(j)+' ';
  51.   if (command<>'') then command:='/C'+command;
  52.  
  53.   SwapVectors;
  54.   Exec(path,command);                 { Execute command }
  55.   SwapVectors;
  56.  
  57. end.