Take notes on the command line: Difference between revisions

no edit summary
m (→‎{{header|Sidef}}: updated code)
No edit summary
Line 905:
 
note</lang>
 
=={{header|Gambas}}==
<lang gambas>'Note that the 1st item in 'Args' is the file name as on the command line './CLIOnly.gambas'
 
Public Sub Main()
Dim sContents As String 'To store the file contents
Dim sArgs As String[] = Args.All 'To store all the Command line Arguments
 
If Not Exist(User.home &/ "NOTES.TXT") Then 'If NOTES.TXT doesn't already exist in the current directory then..
File.Save(User.home &/ "NOTES.TXT", "") 'a new NOTES.TXT file should be created.
Print "New file 'NOTES.TXT' created." 'A meassge
Endif
 
sContents = File.Load(User.home &/ "NOTES.TXT") 'Get the contents of the file
 
If Args.count < 2 Then 'If NOTES has arguments (other than the file name)
Print sContents 'Print the file contents
Else
sContents &= Format(Now, "dddd dd mmmm, yyyy, hh:nn:ss") & gb.NewLine & 'The current date and time are appended to the local NOTES.TXT followed by a newline and..
gb.Tab & sArgs.Join(" ") & gb.NewLine 'Then all the arguments, joined with spaces, prepended with a tab, and appended with a trailing newline
Print sContents 'Displays the current contents of the local NOTES.TXT
File.Save(User.home &/ "NOTES.TXT", sContents) 'Write contents to NOTES.TXT
Endif
 
End</lang>
Output:
<pre>
Wednesday 24 May, 2017, 17:55:56
./CLIOnly.gambas Hello to
Wednesday 24 May, 2017, 17:55:58
./CLIOnly.gambas Hello to you all
</pre>
 
=={{header|Go}}==
Anonymous user