35 lines
1.2 KiB
Text
35 lines
1.2 KiB
Text
include xpllib; \Date and Time routines
|
|
int I, NotesSize, Ch, CmdArgSize;
|
|
char Notes(1_000_000), CmdArg(1000);
|
|
[\Read in notes.txt, if it exists
|
|
Trap(false); \disable abort on errors
|
|
FSet(FOpen("notes.txt", 0), ^i);
|
|
OpenI(3);
|
|
if GetErr = 0 then \file exists
|
|
[I:= 0;
|
|
while GetErr = 0 do \GetErr detects end-of-file
|
|
[Notes(I):= ChIn(3);
|
|
I:= I+1;
|
|
];
|
|
NotesSize:= I-2; \remove 2 EOFs
|
|
];
|
|
\Get command-line argument, if any, from command line
|
|
I:= 0;
|
|
loop [Ch:= ChIn(8);
|
|
if Ch = CR then quit;
|
|
CmdArg(I):= Ch;
|
|
I:= I+1;
|
|
];
|
|
CmdArg(I):= 0; \terminate string
|
|
if I = 0 then \no args, just display notes.txt
|
|
for I:= 0 to NotesSize-1 do ChOut(0, Notes(I))
|
|
else \open notes.txt for output and append CmdArg
|
|
[FSet(FOpen("notes.txt", 1), ^o);
|
|
OpenO(3);
|
|
for I:= 0 to NotesSize-1 do ChOut(3, Notes(I));
|
|
DateOut(3, GetDosDate); ChOut(3, ^ );
|
|
TimeOut(3, GetDosTime); CrLf(3);
|
|
ChOut(3, Tab); Text(3, CmdArg); CrLf(3);
|
|
Close(3);
|
|
];
|
|
]
|