The SETUP statement has the form
SETUP device,dev2,modifier,modifier...
and reads a record from (device); if (device) is a file with random access, it reads the first record of that file.
The record read is expected to be in the form
name=format:filename:filename...,name=format:filename...,...
and prepares for subsequent FETCH, STORE, INSERT, DELETE, etc. statements referencing that device.
The parameter dev2, if present, indicates that the record should instead be read from (dev2), but still used for subsequent operations on (device), as well as being output to (device), if possible to its first record. Using a STRING/CHARACTER variable for dev2 when creating a database file is the most common application of this parameter, since then, as in INPUT and READ, dev2 input is read from the text variable.
The file header record indicates, for the other records in the file, that their contents consist of fields having the given names and formats in order.
Where a character constant is present as a filename parameter, it indicates that the contents of the field just named constitute a key to the named file, whose fields may also be accessed by FETCH and STORE statemets applied to (device). (This allows the use and creation of databases in what is called "third normal form": that is, databases that avoid duplication of information by pooling information common to more than one file in a single separate file.)