READV

READV


READU Index Level READVU
Syntax READV{U} variable FROM {file.variable,} id.expression, ac.expression {LOCKED statement.block} {THEN | ELSE statement.block}
Category BASIC
Type Statement
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.
Options
See Also THEN | ELSE statement.block READVU ac.expression id.expression statement.block WRITEV RELEASE file.variable default file variables WRITEVU statements & functions LOCKED unlock-item SYSTEM list-locks (R83) READ BEGIN WORK
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".
Warnings The "readv" statement reads the entire item into temporary workspace, extracts the targeted attribute, places it into the variable and resets temporary space. The rest of the item is basically ignored. A series of "readv" statements against different attributes in the same item force the system to continually re-read the same item.

"readv" should be used only in cases where 1 or 2 attributes are needed from a larger item without the rest of the item. Using "readv" exclusively makes the program run noticably slower.
Compatibility D3 7.0 AP R83
READU Index Level READVU