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
Wrap
Pascal/Delphi Source File
|
1999-01-25
|
1KB
|
57 lines
Program EnvDate;
{ Set the environment variable 'DATE' to the current system date, in
the format YYMMDD. Then execute the command line parameter(s) as a
subprocess (invoking COMMAND.COM). }
{$M 2048,0,0}
Uses DOS;
type charray = array[1..1] of char;
chptr = ^charray;
var path,command,date,t: string;
year,month,day,dayofweek: word;
p: chptr;
i,j: integer;
Begin
GetDate(Year,Month,Day,DayOfWeek); { Get the system date }
str(year-1900:2,date); { Build date string: DATE=YYMMDD }
str(month:2,t);
if (t[1]=' ') then t[1]:='0';
date:=date+t;
str(day:2,t);
if (t[1]=' ') then t[1]:='0';
date:=date+t;
date:='DATE='+date;
p:=Ptr(MemW[PrefixSeg:$2C],0); { Get ptr to environment }
i:=1;
repeat { Find end of environment }
inc(i)
until (p^[i]=#0) and (p^[i-1]=#0);
for j:=1 to length(date) do begin { Load string into environment }
p^[i]:=date[j];
inc(i);
end;
p^[i]:=#0;
p^[i+1]:=#0;
path:=GetEnv('COMSPEC'); { Get COMMAND.COM spec }
command:='';
for j:=1 to ParamCount do { Build command line }
command:=command+ParamStr(j)+' ';
if (command<>'') then command:='/C'+command;
SwapVectors;
Exec(path,command); { Execute command }
SwapVectors;
end.