RosettaCodeData/Task/Take-notes-on-the-command-line/SETL/take-notes-on-the-command-line.setl
2024-04-19 16:56:29 -07:00

24 lines
512 B
Text

program notes;
if #command_line = 0 then
show_notes;
else
write_note;
end if;
show_notes::
if (notefile := open('notes.txt', 'r')) = om then
stop;
end if;
loop for line in [getline notefile : until eof(notefile)] do
print(line);
end loop;
close(notefile);
write_note::
notefile := open('notes.txt', 'a');
note := (+/[' ' + a : a in command_line])(2..);
puta(notefile, date + '\n\t' + note + '\n');
close(notefile);
end program;