WRITE

<< Click to Display Table of Contents >>

Navigation:  Reference > Commands >

WRITE

The form of the WRITE command is:

WRITE,

WRITE MARK [(n)],

WRITE BACK [(n)] variable, variable, ... ,

The WRITE command (first example above) is used at the Data Stage to write away a record to the IDF (Intermediate Data File). A record in the IDF contains the values of all variables defined in the stage except temporary variables.

IMPORTANT: the values for all the variables are written with the values they have at the time that the WRITE command is executed.

The presence of one or more WRITE commands inhibits the automatic write feature, whereby the FINISH DATA command writes away a record. It is normally only used when you wish to generate more than one output record for each input record, for example when using trailer cards or when excluding records from the IDF. This can be done by jumping round the WRITE command.

If variable $XIERR is not 0, then the record is not written to the IDF and a message is printed to the Report file. Variable $XIERR is reset to 0 after each WRITE command is executed.

The last two commands above allow you to copy variable values back onto previous IDF records (previous WRITE commands). This gives you the ability to accumulate information during a questionnaire (or sections of a questionnaire) and then have the final values of these variables written back to previous records that have already been written to the IDF. This facility is especially useful for Companion Reflect generation when the end customer will not know which variables are available at the various levels. Using these commands accumulated variables will always be available for tables at all levels.

If (n) is not used then (1) is assumed.

The WRITE MARK command sets a marker in the output IDF for later WRITE BACK commands. Any subsequent WRITE BACK using the same number (n) or higher will not write back to any records before the WRITE MARK is executed. At the beginning of the run CL generates a WRITE MARK (0) to prevent any attempt to write back beyond the beginning of the IDF. At START DATA CL generates a WRITE MARK (1) so that you cannot write back over previous questionnaires unless you use WRITE BACK (0). If your CL script does not pass through FINISH DATA you are advised to use WRITE MARK (1) when a new questionnaire is started.

The WRITE BACK command takes the current values of all the variables listed and replaces the contents of these variables into all IDF records written since the last time WRITE BACK was executed with the same (n) or lower.

Each WRITE BACK is executed separately and you should therefore try to list all the variables to be written back into one WRITE BACK command. Although CL can only accept up to 100 items to be written back it will combine any variables that use consecutive space (were originally defined together) into one item. To assist pre-processor list generation a trailing . (full stop) after the last variable is permitted.