NIPO ODIN Version 5.17

*WRITE

Purpose

Writes data to a file.

Syntax

*WRITE <Qn|var> ["filename"]

Description

With this command data can be stored into a file from a data field or variable indicated by the first argument. If the filename is omitted data is stored in the last file used to store data. The file consists of a single record. The contents of the record consist of one or more values which are either numbers or text.

NIPO ODIN takes care of properly storing values one by one in consecutive calls to *WRITE. It is not required to be aware of the file format created by NIPO ODIN unless the data is accessed or changed by an external application.

File format for *READ and *WRITE for each value

Header Identifier Size Value

.Single position containing a 'D'

Decimal value of 4 digits indicating the size of the value.

Any string of characters of which the size is determined in the header.


For example, when the values 123456 and the text "NIPO ODIN Script" are stored in a single file, it would contain the string "D0006123456D0016NIPO ODIN Script".

Arguments

Qn
The question reference of the data field that has to be stored.

var
A variable that holds the data that has to be stored.

filename
The filename of the file to store the information in.

Remarks

  • During an interview you can not go back over a *WRITE with filename, you can only go back over a *WRITE without filename.
  • You can not use *WRITE indifferently in combination with *READ: at any time only one file is assumed open. Any *READ or *WRITE that specifies a filename automatically closes the previous file.
  • Files are automatically closed for writing when the interview is terminated.

Example

*TEXTVARS txt[2]
*PUT txt[1] "my text"
*PUT txt[2] "my second text"
*WRITE txt[1] "myfile"
*WRITE txt[2]

See Also