Take notes on the command line: Difference between revisions

Add SETL
imported>Thebeez
(Add SETL)
 
(6 intermediate revisions by 5 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,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}}==
Line 2,985 ⟶ 3,126:
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,111 ⟶ 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,354 ⟶ 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