- 1.7
- 1.6
- 1.5
- Beta
- Examples (for 1.6a)
- Misc
Formatted output in Aten is based largely on string formatting in C, so if you're familiar with C then this should be a breeze. If you're a Soldier of Fortran, then the principles are very similar. If you're familiar with neither, then now's the time to learn.
![]() | See Also: |
|---|---|
|
Formatted output corresponds to output to either the screen or to files, and is used in the following commands:
Table 4.7. Formatted output commands
| Command | Function |
|---|---|
| error | Write a message to the screen and immediately terminate execution of the current script / filter / command structure |
| printf | Write a message to the screen |
| verbose | Write a message to the screen, provided verbose output mode is on |
| writelinef | Write a formatted line to the current output file |
| writevarf | Write a formatted string to a variable (equivalent to the C 'sprintf' command) |
Note that all are called the same as their ((Delimited Reading and Writing|delimited counterparts)), but with the addition of an 'f' at the end of the name.
Formatting a string for output, as mentioned elsewhere on numerous occasions, works the same as for C. The C 'printf' command (equivalent to the command of the same name in Aten) takes a character string as its first argument, and at its simplest, this is all that is required:
printf("Hello");This prints 'Hello' to the screen (minus the quotes). Importantly, however, a newline character is not printed, meaning that the next thing you try and printf will appear on the same line. For instance:
printf("Hello");
printf("There.");would output:
HelloThere.
The end of a character constant in the printf command does not implicitly mean 'and this is the end of the line' - you must indicate the end of the line yourself by placing '\n' at the point where you wish the line to end. So:
printf("Hello\n");
printf("There.");would output:
Hello There.
Newlines (\n) are an example of escaped characters - the backslash '\' indicates that the following character, in this case 'n', is not to be treated as a normal 'n', but instead will take on its alternative 'meaning', in this case a newline. There are one or two other escaped characters recognised - see Escaped Characters for a list. Note that the newline token can appear anywhere in the string, and any number of times. So:
printf("Hello\nThere\n.");would output:
Hello There .


![[Note]](images/note.png)