basic.read
Reads item into dimensioned or dynamic array.
Syntax
read{u} dynamic.array from {file.variable,} id.expression {locked statement{s}} {then | else statement.block}
Description
reads an item as a dynamic array and stores the item as a string. Each attribute is automatically an element of the dynamic array variable and may be referenced with the appropriate intrinsic functions.
If the file.variable parameter is not specified, the default file.variable is used.
The 'else' clause is taken when the item is not on file.
The 'then' clause is taken when the item is read successfully.
See the 'then/else construct' for an explanation on the use of 'then' and 'else' clauses in statements that allow or require them.
The 'readu' statement is identical to the 'read' statement, except that the item is 'locked', preventing access to that item by any other process. Note that in R83 implementations, the entire group in which the item was found is locked.
The 'locked' statements are executed if the item exists and is already locked by another process or by the current process at a different level. 'system(0)', in the 'locked' clause, returns the port number which has the item locked. At the termination of the program, 'readu' unlocks the item.
If a binary item is read, 'system(0)' is set to 10. The variable string consists of the hex fid in attribute 1 and the hex frame in attribute 2.
In Advanced Pick (AP) implementations, this statement may optionally be written 'matread' or 'read'. If 'mat' is omitted, a matrix read can be determined by the definition of the variable, 'array.variable'. If no 'dim' statement appears, it is automatically treated as a 'dynamic' array.
Example
open 'customer' to customer.file else stop 201, 'customer'
item = ''
crt 'enter customer id ':
input item.id
read item from customer.file,item.id else stop 202,item.id
print 'the customer name is ':item<1>
This example opens the 'customer' file and prompts the operator for
the customer's item-id. If the read is scuccessful, the customer name in
attribute 1 is displayed.
file customer
crt 'enter customer id ':
input item.id
read customer from item.id else stop 202,item.id
print 'the customer name is ':customer(name)
This example used the 'file' statement to bind the
'customer' file to this program. It prompts for the item-id, reads
the item and prints the name. The 'file' statement allows
dictionary-type references to the read data item.
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
