HistoryCal - V0.0.7 Manual
write & file
Home Development V0.0.7 Manual Script write & file

file Statement

The file statement opens and prepares a text file, ready to receive output from a write or writeln statement.

file Statement
FormatExample
file filecode filename switch; file note "note.txt" append;

The filename is expected in the form of a string expression.

The switch is optional, if given it can be one of the following names:

SwitchNote
write Open for writing, truncating any existing text.
append Open for writing, adding new text to the end.

If no switch is given then 'write' is assumed.

write And writeln Statements

The write and writeln statements are intended to provide output. The only difference between the two statements is: writeln will automatically add a new line at the end of the output, whereas write will not.

The expression following is first evaluated and then "stringified", or converted into text. If the write statement has a filecode property attached, output will be sent to the appropriate file. Otherwise output is sent to the standard output device.

write Statement
FormatExampleOutput
write str_expr; write "Today is: " + string.g:dmy today; Today is: 14 Oct 2016
write field_expr; write today + 50; 2457726
write rlist_expr; write today .. today + 50 \ today + 25; 2457676 .. 2457700 | 2457702 .. 2457726
write record_expr; write record.g today; {"g", 2016, 10, 14, ?}
write.filecode expr; write.text "Today is: " + string today; Today is: 14 Oct 2016
Written when today equalled "jdn# 2457676" or "g:dmy# 14 Oct 2016"

It should be noted the the plus operator '+' is used for both numerical addition and string concatenation. The rule is, if both sides of the operator are numbers, the values are added together. But if one side is a string, the other side is converted to a string and the two concatenated. Since operators of equal precedence are evaluated from left to right, one string to the left of a succession of numbers being added will affect them all.

ExampleResult
write 5 + 10 + 15;30
write "" + 5 + 10 + 15;51015
write "" + 5 + (10 + 15);525

Output

For the HistoryCal program, standard output is shown in a message box after the script completes.

Home Development V0.0.7 Manual Script write & file

Managed by WebPageLayout Validated by HTML Validator (based on Tidy)

12th October 2016