basic.readv

Statement/BASIC Program, Releases: AP and R83

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

Command Name Type Description
basic.then/else.construct Definition provide program flow change based upon a boolean condition.
basic.readvu Statement see 'readv'.
basic.ac.expression Definition Derives an attribute count.
basic.id.expression Definition An expression which derives an item-id.
statement.block Definition one or more statements that follow a Pick/BASIC decision-path related token such as, but not limited to, 'then', 'else', 'locked' and 'onerr'.
basic.writev Statement Writes one attribute.
basic.release Statement Releases group/item lock(s).
basic.file.variable Definition Defines file location from previous 'open' statement.
basic.default.files Definition used by any file-access Pick/BASIC statement when a specific file variable is not specified.
basic.writevu Statement Writes one attribute, without unlocking.
basic.statements Definition Definition of statements and functions.
basic.locked Definition Takes 'locked' path when group/item lock encountered.
tcl.unlock-item Verb: Access Clears item locks in specified file.
basic.system Function Displays status of system-controlled variables.
tcl.list-locks_rp Verb: Access Displays status of all locks.
basic.read Statement Reads item into dimensioned or dynamic array.
basic.begin.work Statement Starts a transaction

User Comments

What do you think?

Share your experience or ask a question by using the form below.

Login to leave your comments.