Previous: , Up: Formatted Input/Output   [Contents][Index]

4.3.9 Input Data Formats

Routines fread and freadf have a format string as their first (for fread) or second (for freadf) argument. Each next data value is read according to the next viable format entry in the format string.

LUX accepts most legal C input format strings, but with some notable exceptions. LUX’s input format strings consist of whitespace (which matches that much or more whitespace), ordinary text, which must be matched by the next non-whitespace input, and format entries.

Ordinarily, each input value consists of the next string of non-whitespace characters up to the next whitespace or until the specified field width has been reached, so that whitespace does not count against field width. However, if the /COUNTSPACES keyword is specified, then LUX does count whitespace against field width. This format is suitable for reading data that is aligned on specific columns but for which no field delimiters are present and for which some values may be missing.

If the format contains explicit text to be matched but that text is not present in the expected position in the input, then an error is generated.

The differences between LUX input formats and C input formats are:

  1. Initial whitespace in format specifications is ignored by LUX, while in C it usually matches any amount of initial whitespace in the input.
  2. Whitespace counts against field width in LUX if the /COUNTSPACES keyword is specified. In C and in LUX (in absence of the /COUNTSPACES keyword) whitespace does not count against field width.
  3. LUX format %S, which reads non-newline characters, is not available in C.
  4. LUX postfices such as 6#, not available in standard C, indicate that the preceding format must be used 6 times and the result stored in a single array (if not suppressed through the * modifier).
  5. LUX does not support the C input format %u (unsigned integer).
  6. C modifier L is not supported in LUX.
  7. LUX formats %t and %T read data in sexagesimal notation. This format is not available in C.
  8. LUX format %z reads complex numbers. This format is not available in C.

Previous: , Up: Formatted Input/Output   [Contents][Index]