Take notes on the command line: Difference between revisions

Add SETL
(add task to aarch assembly for raspberry pi)
(Add SETL)
 
(9 intermediate revisions by 8 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 598:
f.byte('\n');
}</syntaxhighlight>
 
=={{header|Amazing Hopper}}==
<syntaxhighlight lang="c">
/*
Take notes on the command line. Rosettacode.org
*/
#include <basico.h>
 
algoritmo
cuando ' no existe el archivo ("NOTES.txt") ' {
sys = `touch NOTES.txt`; luego limpiar 'sys'
}
si ' total argumentos es (1) '
cargar cadena desde ("NOTES.txt"); luego imprime
sino
msg=""; obtener todos los parámetros, guardar en 'msg'
#( msg = strtran("@","\n\t",msg) )
fijar separador 'NULO'
fecha y hora, "\n\t", msg, "\n\n", unir esto;
añadir al final de ("NOTES.txt")
fin si
terminar
</syntaxhighlight>
{{out}}
<pre>
:
:
$ hopper3 basica/notes.bas otra y otra y otra...@y otra
$ hopper3 basica/notes.bas
27/11/2023,23:38:28:74
iniciando estas notas con un mensaje
de prueba
 
27/11/2023,23:40:57:41
nota 2:
establecer parámetro
 
27/11/2023,23:52:22:82
nueva nota de prueba
ta es medianoche
 
27/11/2023,23:55:07:20
otra nueva nota
 
27/11/2023,23:56:21:15
otra y otra y otra...
y otra
 
$ hopper3 basica/notes.bas borrar todo de este directorio@sin asco
$ hopper3 basica/notes.bas
27/11/2023,23:38:28:74
iniciando estas notas con un mensaje
de prueba
 
27/11/2023,23:40:57:41
nota 2:
establecer parámetro
 
27/11/2023,23:52:22:82
nueva nota de prueba
ta es medianoche
 
27/11/2023,23:55:07:20
otra nueva nota
 
27/11/2023,23:56:21:15
otra y otra y otra...
y otra
 
28/11/2023,00:04:04:62
borrar todo de este directorio
sin asco
 
$
</pre>
 
=={{header|APL}}==
Line 2,861 ⟶ 2,938:
if len(sys.argv) == 1:
try:
with open('"notes.txt'", '"r'") as f:
shutil.copyfileobj(f, sys.stdout)
except IOError:
pass
else:
with open('"notes.txt'", '"a'") as f:
f.write(datetime.datetime.now().isoformat() + '"\n'")
f.write("\t%s\n" % ' '.join(sys.argv[1:]))</syntaxhighlight>
 
Line 2,953 ⟶ 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}}==
<syntaxhighlight lang="rexx">/*REXX program implements the "NOTES" command (append text to a file from the C.L.). */
notes = 'notes.txt' /*the fileID of the 'notes' file. */
timestamp=right(date(),11,0) time() date('W') /*create a (current) date & time stamp.*/
Select
nFID = 'NOTES.TXT' /*the fileID of the "notes" file. */
When arg(1)='?' Then Do
Say "'rexx notes text' appends text to file" notes
Say "'rexx notes' displays file" notes
End
When arg()==0 Then Do /*No arguments? Then display the file.*/
Do while lines(notes)>0
Say linein(notes) /* display a line of file --> screen. */
End
End
Otherwise Do
timestamp=right(date(),11,0) time() date('W') /*create current date & time stamp */
If 'f2'x==2 Then tab='05'x /* this is an EBCDIC system. */
Else tab='09'x /* " " " ASCII " */
Call lineout notes,timestamp /*append the timestamp to "notes" file.*/
Call lineout notes,tab||arg(1) /* " " text " " " */
End
End /*stick a fork in it, we're all Done. */</syntaxhighlight>
{{out}}
<pre>
K:\>rexx notes ?
'rexx notes text' appends text to file notes.txt
'rexx notes' displays file notes.txt
 
K:\>rexx notes starting work
 
07 Aug 2023 19:39:41 Monday
if 'f2'x==2 then tab="05"x /*this is an EBCDIC system. */
starting work</pre>
else tab="09"x /* " " " ASCII " */
 
=={{header|RPL}}==
if arg()==0 then do while lines(nFID) /*No arguments? Then display the file.*/
The file is idiomatically named <code>Logbook</code> rather than <code>NOTES.TXT</code>.
say linein(Nfid) /*display a line of file ──► screen. */
« '''IFERR''' Logbook '''THEN''' "" '''END'''
end /*while*/
'''IF''' DEPTH 1 > '''THEN''' "\n" + DATE TIME TSTR else+ do'''END'''
'''WHILE''' DEPTH 1 > '''REPEAT''' "\n" + DEPTH ROLL + '''END'''
call lineout nFID,timestamp /*append the timestamp to "notes" file.*/
DUP 'Logbook' STO
call lineout nFID,tab||arg(1) /* " " text " " " */
1 DISP 7 endFREEZE
» '<span style="color:blue">NOTES</span>' STO
/*stick a fork in it, we're all done. */</syntaxhighlight>
 
=={{header|Ruby}}==
Line 3,096 ⟶ 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}}==
Line 3,212 ⟶ 3,418:
 
=={{header|uBasic/4tH}}==
{{works with|R3R4}}
The lack of built-in high level time and date functions makes it more difficult than necessary, since they have to be implemented by user defined functions.
<syntaxhighlight lang="text">If Cmd (0) > 1 Then ' if there are commandline arguments
Line 3,265 ⟶ 3,471:
g@ = g@ - FUNC(_Monthdays (c@-1, f@))
' Print a@, d@, e@, f@
Return (Join (Str(b@), FUNC(_Format (c@, Dup("-"))), FUNC(_Format (e@ - g@, Dup("-")))))
 
_TimeStr ' convert epoch to time string
Param (1)
Return (Join(Str((a@%86400)/3600), FUNC(_Format ((a@%3600)/60, Dup(":"))), FUNC(_Format (a@%60, Dup(":")))))
 
_Format Param (2) : Return (Join (Iif (a@<10, Join(b@, "0"), b@), Str (a@)))
Line 3,282 ⟶ 3,488:
Anyways, it seems this task is DONE!
</pre>
 
=={{header|UNIX Shell}}==
Bash version
Line 3,338 ⟶ 3,545:
An awkward task for Wren-cli which currently has no way of determining the current date and time.
We therefore have to ask the user to input it plus the note(s).
<syntaxhighlight lang="ecmascriptwren">import "os" for Process
import "./ioutil" for File, FileUtil
import "./date" for Date
 
var dateFormatIn = "yyyy|-|mm|-|dd|+|hh|:|MM"
2,093

edits