FB
Reads an item from a file into a special "fast" buffer without first opening the file.
Syntax
FB file-specifier {item-id}
alt-cmd
Syntax Elements
file-specifier The name of the file to be read, as defined in Conventions.
file-specifier can be a literal or a direct or indirect buffer reference.
item-id The name of the item to be read.
item-id can be a literal string (not enclosed in quotes), or it can be a direct or indirect buffer reference. If item-id is not specified, then the value at the current buffer pointer location in the active input buffer is used as the item-id.
Note
For compatibility with earlier releases all of the above elements may be enclosed in a single pair of parentheses, ().
alt-cmd The command(s) to be executed if the named item cannot be read. Must be on the line immediately after the command itself.
Operation
The FB command allows you to read an item into a special "fast buffer" without first opening the file. There is only one fast buffer, so the previous buffer contents are destroyed with every subsequent use of the FB command. The P command also destroys the contents of the fast buffer.
The FB command is preferable to an F-OPEN and F-READ command sequence if you are only processing one item from a file. However, it is generally preferable to use F-OPEN and F-READ if reference to the data is required later in the Proc.
The FB command must always followed by a command line that is executed if the read fails.
If the read is successful, the statement on the following line is skipped and execution continues with the next line.
After the item is read into the fast buffer, it is
referenced as &0.a, where a is the attribute number. For
example, &0.3
references the 3rd attribute in the fast buffer.
Note
The previous format for referencing attribute a in the fast buffer (the format &a) is supported for backwards compatibility.
Example 1
001 PQN
002 FB STAFF 14324
003 XItem not on file
004 MV #3 &0.12
.
.
.
This example reads item 14324 from the STAFF file into the fast buffer. If item 14324 cannot be found, the Proc exits with the message "Item not on file". Otherwise, execution continues with line 004, which copies attribute 12 of the item read into parameter 3 of the active output buffer.
Example 2
001 PQN 002 T C,(10,10),"Enter id",S5,+ 003 IP:%5 004 FB STAFF %5 005 T "'",%5,"' is a new item" 006 T (10,10),"Enter hourly wage",S5,+ 007 IP:%6 . . .
This example prompts for an item-id and places it in a parameter file. It reads the specified item from the STAFF file into the fast buffer. If the item cannot be found, a message identifying it as a new item displays. Otherwise, execution continues with line 006.