Category : Science and Education
Archive   : HC21DEMO.ZIP
Filename : HCDOS.PAS

 
Output of file : HCDOS.PAS contained in archive : HC21DEMO.ZIP



{HCDOS.PAS 2.1 Nov 93}
{$M 6000,0,0} {We need this to allow memory for EXEC}
uses
Crt,
Dos, {standard DOS/BIOS routines}
HCIF; {Interface to HC2000 Tables}

{==========================================================================}
{ Routine to call Dos from HC2000 (and log messages) }
{==========================================================================}
var
LogMessage, DosMessage: string;
I: integer;
LogFile: text;


procedure OpenLogFile;
var
Year,Month,Day,dayOfWeek,
Hour,Minute,Second,Sec100: word;
Filename: string;

begin
GetDate(Year,Month,Day,dayOfWeek);
GetTime(Hour,Minute,Second,Sec100);
Str(Month * 1000 + Day * 10 + Hour div 10, Filename);
Assign(LogFile,Filename + '.log');
Rewrite(LogFile);
end;

procedure CloseLogFile;
begin
writeln(LogFile);
Writeln(LogFile,chr(13),chr(10),chr(26),chr(0)); {solid EOF}
Close(LogFile);
end;

begin
AccessHC2000; {Abort if HC200 not loaded}
writeln('HCDOS is running.');
writeln('');
writeln('Log messages will be displayed and logged as they arrive.');
writeln('');
writeln('Messages that read DOS ');
writeln('will try to execute the program in .');
writeln('{ .EXE and .COM files only }');
writeln('');
writeln('Example: 03:23:45 DOS PLAY.EXE GIDAY.VOC');
writeln('');
writeln('');
writeln('Press any key to terminate');
writeln('');

OpenLogFile;

repeat
{ GetLog is the string function defined in HCIF.TPU }
{ It returns an empty string if the HC2000 Log Buffer is empty }

LogMessage := GetLog;
if LogMessage <> '' then begin {ignore empty strings}
writeln(LogMessage);
writeln(LogFile, LogMessage);
if copy(LogMessage,10,4) = 'DOS ' then
begin
DosMessage := copy(LogMessage,14,50);
I := pos(' ',DosMessage); {to find start of parameter}
EXEC(copy(DosMessage,1,I),copy(DosMessage,I,29));
if DosError <> 0 then
writeln('HCDOS: DosError = ',DosError);
end;
end;
until keypressed;

CloseLogFile;
writeln('');
writeln('HCDOS terminated.');
end.