TO (REFORMAT) |
|
|
The TO keyword used in a REFORMAT command specifies the name of the output file.
Format
TO new.file.name TO DATA
where
If the TO keyword is not present, the REFORMAT command prompts for the file name.
Use of TO DATA causes the query processor to create a dynamic array containing the output. This can be accessed via the @DATA variable. Each "record" in this array is separated by an item mark character (char 255) and the fields within the item correspond to the display clause elements in the REFORMAT command.
Examples
REFORMAT CUSTOMERS ZIP.CODE CUST.NO.NAME TO CUST.BY.ZIP
This command constructs a new file, CUST.BY.ZIP, keyed by zip code and containing two data fields, the customer number and name. Note that if two or more customers share the same zip code, the record will be overwritten by the second and subsequent items.
EXECUTE "REFORMAT CUSTOMERS ZIP.CODE CUST.NO.NAME TO DATA" LOOP S = REMOVEF(@DATA, @IM) UNTIL STATUS() ...processing... REPEAT
This is the same command executed from within a QMBasic program, directing the output to the @DATA variable. The loop after the EXECUTE then extracts each item mark delimited entry and processes it. |