Take notes on the command line: Difference between revisions

Add SETL
(added RPL)
(Add SETL)
 
(2 intermediate revisions by 2 users not shown)
Line 17:
print(File(‘notes.txt’).read(), end' ‘’)
E
V f = File(‘notes.txt’, ‘a’APPEND)
f.write(Time().format("YYYY-MM-DD hh:mm:ss\n"))
f.write("\t"(:argv[1..].join(‘ ’))"\n")</syntaxhighlight>
Line 3,030:
Test line 3
</pre>
 
=={{header|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
, <ArgList>: {
= <PrintNotes>;
e.Args = <WriteNote e.Args>;
};
};
 
ArgList {
= <ArgList 1>;
s.N, <Arg s.N>: {
= ;
e.Arg = (e.Arg) <ArgList <+ s.N 1>>;
};
};
 
PrintNotes {
, <ExistFile 'notes.txt'>: {
False = ;
True = <PrintFile 1 'notes.txt'>;
};
};
 
PrintFile {
s.Chan e.File = <Open 'r' s.Chan e.File> <PrintFile (s.Chan)>;
(s.Chan), <Get s.Chan>: {
0 = <Close s.Chan>;
e.Line = <Prout e.Line> <PrintFile (s.Chan)>;
};
};
 
WriteNote {
e.Args, <Time> '\n\t' <Join (' ') e.Args> '\n': e.Note =
<Open 'a' 2 'notes.txt'>
<Put 2 e.Note>
<Close 2>;
};
 
Join {
(e.X) = ;
(e.X) (e.1) = e.1;
(e.X) (e.1) e.2 = e.1 e.X <Join (e.X) e.2>;
};</syntaxhighlight>
{{out}}
<pre>$ ls notes.*
notes.ref notes.rsl
$ refgo notes
$ refgo notes This is a note
$ refgo notes This is another note
$ refgo notes Note that this is a note
$ refgo notes
Mon Apr 8 13:57:34 2024
This is a note
 
Mon Apr 8 13:57:38 2024
This is another note
 
Mon Apr 8 13:57:42 2024
Note that this is a note
 
$ ls notes.*
notes.ref notes.rsl notes.txt
$</pre>
 
=={{header|REXX}}==
Line 3,197 ⟶ 3,261:
end if;
end func;</syntaxhighlight>
 
=={{header|SETL}}==
<syntaxhighlight lang="setl">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;</syntaxhighlight>
{{out}}
<pre>$ ls notes.*
notes.setl
$ setl notes.setl
$ setl notes.setl This is a note
$ setl notes.setl This is another note
$ setl notes.setl
Mon Apr 8 14:27:07 2024
This is a note
 
Mon Apr 8 14:27:11 2024
This is another note
 
$ ls notes.*
notes.setl notes.txt</pre>
 
=={{header|Sidef}}==
2,093

edits