To write a file, the same procedure is used as for reading.
At first a file object is created via "var <variable> = new File". This variable represents the file object.
When the object is created, it should be opened. Therefore the mode in which the file should be opened is communicated. In this case, we open the file in 'WriteOnly' mode.
Once the file is opened in write only mode, nothing stops us to write to the file. This can be performed by using the 'writeLine()' command. Other commands are also possible, but the writeLine() method adds a return at the end of the sentence, which can be convenient.
A date object was created in the 'main.qs' via "var today = new Date;'. When a variable is declared in the main, it is called a 'global' variable. All functions can use this variable. In the example below, the date object is used to log the date. Therefore the date object should be converted to string with the 'toString()' command.
When all the necessary writing is performed, the file object should be closed, otherwise the file is not accessible to other programs or users.
And, when checking for the logfile, it seems to be there:
Next:
4d: Directories
Index