DGL Statement Reference : WRITE

WRITE

Description
Writes expression values to any of the following:

The document output segment

Another file

The dialog area of the tool window

You can write a numeric or string expression that is evaluated in the template, or a literal piece of text. In addition, the WRITE statement can be used to write information retrieved from the database, such as element names.
The WRITE statement is commonly used to write lines that include text (string literals) together with expression values. For example:

WRITE (’NAME:’, di_name);

This results in KUKU being written in the output segment file NAME, where KUKU is a value of di_name.

Note the following:

:

For example, the following call writes the value of alpha at the beginning of the next line in the output segment file:

WRITE (’\n’, alpha);

Optionally, you can specify the minimum number of characters to be written in the output file using the following syntax:

expression : num

In this syntax, expression can be either a numeric or a string expression, and num is an integer constant or integer expression that represents the minimum number of characters that expression will occupy. expression and num can involve operands, operations, and function calls.

For example:

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:

COMP , SET

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 of num.

For an integer, when num is specified, and where num 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 of num.

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 where num 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 of num. Where num 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 of num. However, in no case will the integer portion of the real number be truncated.

Syntax
WRITE ([fl,] write_expression,...);
Parameters
 
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.
Example
WRITE (’Name:’:8, name,’\n’,’Value:’:8, v);

Assume that name contains “Xfactor” and v is an integer that equals 5105. This call writes the following lines to the output file:

Name: Xfactor
Value: 5105

Note:
The WRITE command cannot access a list 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.
Using WRITE to Produce Messages
You can use a WRITE 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 in OUTPUT mode using the OPEN statement (refere to OPEN).
To write a string message to a file, use the following syntax:

WRITE (fl, write_expression);

In the syntax, fl is a pointer to the file to which you want to write the messages.
See Also