Next: , Previous: , Up: Internal Routines   [Contents][Index]

15.5.481 read

read, var1 [, var2 …] [, /word]

Reads values from the keyboard or batch file into the specified variables. Supports scalars (real and complex), strings, and numerical and string arrays. Arrays and strings must be predefined so the number of elements to be read can be determined from them. Undefined variables cause reading of one scalar. Other variable types are not allowed. Literal strings in the argument list cause their contents to be written on the screen (if reading from the standard input) or ignored (if not reading from the standard input). Other unnamed variables are not allowed.

Upon exit, !read_count contains the number of read elements.

When accepting input, read displays a prompt consisting of the number of elements read so far followed by a greater-than sign (>). During input to read through the keyboard, all command line editing functions are available except for those dealing with the history buffer (Command Input). If the end of the input file is reached before all specified arguments have been serviced, then an error is generated.

For numerical arguments, the input is divided into tokens separated by whitespace and/or commas. The contents of one such token are converted into one value. Numerical values can be specified just like scalar values can in LUX scripts, so input 10o corresponds to octal 10 or decimal 8 (Scalars). The token is converted up to the first character that is not part of any legal number specification. If a token contains no legal number, then 0 is returned.

For string arguments, all input up to the end of the current input line is returned as one value, except if /word is specified, in which case the next whitespace-separated word is returned. For string arrays, the input for each element must be on a separate input line.

Data from a file is read character by character as needed. Data from the keyboard (standard input) is read one line at a time.

See also: readarr, readf, print, openr, !read_count

Next: , Previous: , Up: Internal Routines   [Contents][Index]