basic.readv
Reads one attribute and assigns to value.
Syntax
readv{u} variable from {file.variable,} id.expression, ac.expression {locked statement.block} {then | else statement.block}
Description
reads an item from the optionally-specified file.variable and assigns the value contained in the attribute number referenced in the attribute expression to the specified variable.
The 'readvu' statement is identical to the 'readv' statement, except that the item is 'locked', preventing access to that item by any other process.
The 'else' clause is taken if 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.
If the item is locked by the current process on the same level, the item lock still takes place. The 'locked' statements are executed if the item is already locked by another process or by the current at a different level. If 'locked' is not specified in a 'readvu', the program waits for the lock to be released. system (0), in the 'locked' clause returns the port number which has the item locked.
Example
readv partlist from inventory,part.number,10 then
cnt = dcount(partlist,char(253))
for l = 1 to cnt
print partlist<1,l>
next l
end
Items in the 'inventory' file have a list of composite parts in
attribute 10. In this example, only attribute 10 is read, and each sub-part is
displayed on a separate line.
readvu next.number from control.file,'nextnum',1 then
print 'got the next number'
writev next.number+1 on control.file,'nextnum',1
end
This example reads the first attribute from the 'nextnum' item in the
'control.file', and locks the entire item. The lock is cleared by
the 'writev'.
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.
