Take notes on the command line: Difference between revisions
Content added Content deleted
(Added Erlang) |
(Pascal) |
||
Line 1,051: | Line 1,051: | ||
{Application.exit 0} |
{Application.exit 0} |
||
end</lang> |
end</lang> |
||
=={{header|Pascal}}== |
|||
Free Pascal in Delphi mode or Delphi in console mode. |
|||
<lang Pascal> |
|||
{$mode delphi} |
|||
PROGRAM notes; |
|||
// Notes: a time-stamped command line notebook |
|||
// usage: >notes "note"< or >notes< to display contents |
|||
USES Classes, SysUtils; |
|||
VAR |
|||
Note : TStringList; |
|||
Fname : STRING = 'Notes.txt'; |
|||
Dtime : STRING; |
|||
Ntext : STRING; |
|||
c : Cardinal; |
|||
BEGIN |
|||
DTime := FormatDateTime('YYYY-MM-DD-hhnn',Now); |
|||
Note := TStringList.Create; |
|||
WITH Note DO BEGIN |
|||
TRY |
|||
LoadFromFile(Fname); |
|||
EXCEPT |
|||
Add(DTime); |
|||
NText := 'Notes.txt created.'; |
|||
END; |
|||
// command line args present: |
|||
// add note with date & time |
|||
IF ParamStr(1) <> '' THEN BEGIN |
|||
NText := ParamStr(1); |
|||
Add(DTime); |
|||
Add(NText); |
|||
SaveToFile(Fname); |
|||
// command line args absent: |
|||
// display contents of notebook |
|||
END ELSE |
|||
FOR c := 0 TO Count-1 DO |
|||
Writeln(Note[c]); |
|||
Free; |
|||
END; |
|||
END. |
|||
</lang> |
|||
Program usage and output: |
|||
<pre> |
|||
>notes "Done: coded notes.pas for RC. It was quick." |
|||
>notes |
|||
2013-09-18-2243 |
|||
Notes.txt created. |
|||
2013-09-18-2252 |
|||
To do: code notes.pas for RC. |
|||
2013-09-18-2253 |
|||
Done: coded notes.pas for RC. It was quick. |
|||
</pre> |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |