Take notes on the command line: Difference between revisions

PascalABC.NET
m (→‎{{header|Wren}}: Minor tidy)
(PascalABC.NET)
(4 intermediate revisions by 3 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 2,785:
Done: coded notes.pas for RC. It was quick.
</pre>
 
=={{header|PascalABC.NET}}==
<syntaxhighlight lang="delphi">
begin
//Print(ParamStr(1));
if ParamCount = 0 then
System.IO.File.ReadAllText('Notes.txt').Print
else begin
System.IO.File.AppendAllText('Notes.txt',DateTime.Now.ToString);
var s := (1..ParamCount).Select(i -> ParamStr(i)+NewLine).JoinToString;
s := #9 + NewLine + s;
System.IO.File.AppendAllText('Notes.txt',s);
end;
end.
</syntaxhighlight>
 
 
=={{header|Perl}}==
Line 3,030 ⟶ 3,046:
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,062 ⟶ 3,142:
07 Aug 2023 19:39:41 Monday
starting work</pre>
 
=={{header|RPL}}==
The file is idiomatically named <code>Logbook</code> rather than <code>NOTES.TXT</code>.
« '''IFERR''' Logbook '''THEN''' "" '''END'''
'''IF''' DEPTH 1 > '''THEN''' "\n" + DATE TIME TSTR + '''END'''
'''WHILE''' DEPTH 1 > '''REPEAT''' "\n" + DEPTH ROLL + '''END'''
DUP 'Logbook' STO
1 DISP 7 FREEZE
» '<span style="color:blue">NOTES</span>' STO
 
=={{header|Ruby}}==
Line 3,188 ⟶ 3,277:
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}}==
256

edits