reformat Command

The reformat command takes values from the attributes specified in the command and places them either in another file or to tape in the order in which they are presented.

The specific items to be selected are included in the item list. If no item list is specified, all items in the file are selected in order by the group into which they hash, and within groups, in the order that they were added to the file. The items are written to the new file or tape in the order in which they are selected. The output specification indicate those attributes that are to be selected.

The source item-ID is selected first and becomes the destination item-ID unless id-supp is specified. In that case, the first attribute value becomes the new item-ID. Subsequent attributes are placed in the new item in the order they are specified.

reformat requests the destination file.reference. To send the output to a file, enter the file reference. To send the output to magnetic tape, enter the word tape. To write the output back onto the source file, press ENTER.

NOTE

If the items are to be written back to the source file, an item  list must be specified or a list must be active, otherwise, an infinite  loop condition may result, in which items are continually added to  the file.

When a file is reformatted to tape, the values are concatenated and either truncated or padded at the end with nulls (hexadecimal 00) to the record length specified by the most recently executed t-att command. One tape record is written for each item. Item-IDs are printed as items are dumped, unless the id-supp connective or i option is specified.

A tape label, containing the file reference, tape record length in hexadecimal, time, and date, is written on the tape first, unless the hdr-supp or col-hdr-supp connectives (h or c options) are specified. Two end-of-file (eof) marks terminate the tape. Any processing code that refers to a selected attribute is applied before the item is written to the new file or tape.

Syntax

reformat file.reference {selection.criteria} {item.list} output.specification {modifiers}

filename:destination-file|tape

 

NOTE

The destination item is usually nonexistent.

If the targeted attribute is null, the new value is placed there. If the targeted attribute is nonnull, a new value is added to the end of the attribute.

CAUTION

Items can overwrite themselves on the same file, destroying the  originals!

Example(s)

This takes all items from the entity file and writes them to the entity-new file, using the temporary attribute-defining item reference of a0 to use the same item-IDs in both files. The data in entity-new contains the name in attribute one and the phone number in attribute two.

reformat entity a0 name phone

File Name:? entity-new

See Also

col-hdr-supp Modifier, Commands, Item List, Options, sreformat Command, t-att Command