NIPO ODIN Version 5.17
*READ
System
NIPO CATI and NIPO CAPI only.
Purpose
Reads data from a file.
Syntax
*READ <Qn|var> ["filename"]
Description
With this command data can be read from a file and placed in the data field or variable indicated by the first argument. If the filename is omitted data will be read from the last file used for reading. 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 reading values one by one in consecutive calls to *READ . 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 where the data being read will be stored.
var The name of the variable where the data being read will be stored.
filename The filename of the file to store the information in.
Remarks
- During an interview you can not go back over a
*READ with a filename, you can however go back over a *READ without a filename. - You can not combine
*READ with *WRITE on the same file; after a *WRITE a filename has to be specified with the next *READ . - If no more data can be read, the result question or variable will be 0 if it is numeric or empty if it is alpha-numeric.
Example
*VARS numb[2] *READ numb[1] "myfile.txt" *READ numb[2]
In this example, two numbers are read from the file myfile.txt and stored in the array numb .
|