WRITE
Writes expression values to any of the following:
●
●
●
You can write a numeric or string expression that is evaluated in the template, or a literal piece of text. In addition, theWRITE
statement can be used to write information retrieved from the database, such as element names.TheWRITE
statement is commonly used to write lines that include text (string literals) together with expression values. For example:
●
This results in KUKU being written in the output segment file NAME, where KUKU is a value of
di_name
.
Note the following:
● There can be more than one write expression. When there are multiple expressions, they are separated by commas.
● For lines of pure text, it is better to use theVerbatim
statement.
●
For example, the following call writes the value of
alpha
at the beginning of the next line in the output segment file:
●
Optionally, you can specify the minimum number of characters to be written in the output file using the following syntax:
●
In this syntax,
expression
can be either a numeric or a string expression, andnum
is an integer constant or integer expression that represents the minimum number of characters thatexpression
will occupy.expression
andnum
can involve operands, operations, and function calls.
●
WRITE (act_name: 10, ’,’ , act_synonym);
●
This call results in the string value for
act_name
being written in the output file to a length of at least 10 characters; if the name has less than this number, blanks are added to achieve the specified string length. For example:
●
In this example, spaces have been added to “COMP” to give it a length of 10 characters.
●
The use of
num
determines the minimum number of characters to be written in the output file, as follows:
●
For a string, the length of the string is the minimum number of output characters. When specified, and where
num
is greater than the string length, blanks are padded to the right of the string to achieve a total string length ofnum
.
●
For an integer, when
num
is specified, and wherenum
is greater than the number of digits in the integer, blanks are padded to the left of the number to achieve a total output length ofnum
.
●
For a real number, when
num
is not specified, the value is output to no more than 8 decimal places. Thereafter, the number is automatically rounded. When specified, and wherenum
is greater than the digits output according to the default, blanks are padded to the left of the number to achieve a total output length ofnum
. Wherenum
is less than the digits output according to the default, the decimal portion of the number might be rounded to arrive at a specified output length ofnum
. However, in no case will the integer portion of the real number be truncated.
An identifier of type FILE, previously assigned by the OPEN statement, to which to write the specified string.Using the WRITE statement to write to a file or to the dialog area is particularly useful if you want to write messages (error messages, run-time messages, and so on). When writing to a file or to the dialog area, you must include the fl identifier. In such cases, you must also precede the WRITE statement with an OPEN statement.Assume that
name
contains “Xfactor” andv
is an integer that equals 5105. This call writes the following lines to the output file:
Note: TheWRITE
command cannot access alist
variable directly; if you attempt to write a variable that refers to a list, the Documentor displays an error message. To output a list, use a control flow construct such as a loop, writing one list item at a time.You can use aWRITE
statement to write information to a file or to the dialog area, instead of to the document itself. For this, you must first open a file inOUTPUT
mode using theOPEN
statement (refere to OPEN).In the syntax,fl
is a pointer to the file to which you want to write the messages.
●
●
●
●
●