Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,68 @@
|
|||
% This program uses the "get_argv" function that is supplied iwth
|
||||
% PCLU in "useful.lib".
|
||||
|
||||
NOTEFILE = "notes.txt"
|
||||
|
||||
% Format the date and time as MM/DD/YYYY HH:MM:SS [AM|PM]
|
||||
format_date = proc (d: date) returns (string)
|
||||
ds: stream := stream$create_output()
|
||||
stream$putzero(ds, int$unparse(d.month), 2)
|
||||
stream$putc(ds, '/')
|
||||
stream$putzero(ds, int$unparse(d.day), 2)
|
||||
stream$putc(ds, '/')
|
||||
stream$putzero(ds, int$unparse(d.year), 4)
|
||||
stream$putc(ds, ' ')
|
||||
|
||||
hour: int := d.hour // 12
|
||||
if hour=0 then hour:=12 end
|
||||
ampm: string := "AM"
|
||||
if d.hour>=12 then ampm := "PM" end
|
||||
|
||||
stream$putzero(ds, int$unparse(hour), 2)
|
||||
stream$putc(ds, ':')
|
||||
stream$putzero(ds, int$unparse(d.minute), 2)
|
||||
stream$putc(ds, ':')
|
||||
stream$putzero(ds, int$unparse(d.second), 2)
|
||||
stream$putc(ds, ' ')
|
||||
stream$puts(ds, ampm)
|
||||
return(stream$get_contents(ds))
|
||||
end format_date
|
||||
|
||||
% Add a note to the file
|
||||
add_note = proc (note: sequence[string])
|
||||
fn: file_name := file_name$parse(NOTEFILE)
|
||||
out: stream := stream$open(fn, "append")
|
||||
stream$putl(out, format_date(now()))
|
||||
|
||||
c: char := '\t'
|
||||
for part: string in sequence[string]$elements(note) do
|
||||
stream$putc(out, c)
|
||||
stream$puts(out, part)
|
||||
c := ' '
|
||||
end
|
||||
stream$putc(out, '\n')
|
||||
stream$close(out)
|
||||
end add_note
|
||||
|
||||
% Show the notes file, if it exists
|
||||
show_notes = proc ()
|
||||
po: stream := stream$primary_output()
|
||||
fn: file_name := file_name$parse(NOTEFILE)
|
||||
begin
|
||||
inp: stream := stream$open(fn, "read")
|
||||
while true do
|
||||
stream$putl(po, stream$getl(inp))
|
||||
except when end_of_file: break end
|
||||
end
|
||||
stream$close(inp)
|
||||
end except when not_possible(s: string): end
|
||||
end show_notes
|
||||
|
||||
% Add a note if one is given, show the notes otherwise
|
||||
start_up = proc ()
|
||||
note: sequence[string] := get_argv()
|
||||
if sequence[string]$empty(note)
|
||||
then show_notes()
|
||||
else add_note(note)
|
||||
end
|
||||
end start_up
|
||||
Loading…
Add table
Add a link
Reference in a new issue