basic.readnext
Retrieves the next item-id from an active list.
Syntax
readnext id.variable{,value.count} {secondary} {from select.variable} {then | else statement.block}
Description
retrieves the next item-id from an active list and assigns it to a specified variable.
A list must be active before the 'readnext' takes place. See the 'select' and 'execute' statements and the 'system' function (11). The list may be generated within the program using either of these statements, or the list may be passed into the program from an external process, such as TCL or a PROC, which invokes a list producing verb immediately before running this program.
The 'value.count' parameter indicates the position of the multi-value within an attribute. This is a by-product of an 'exploded' sort, executed prior to the execution of the program. This allows multi-values to be retrieved in 'exploded' sort sequence. If the list is not 'exploded', the 'value.count' value is always 1 (one).
The 'else' condition is executed when there are no more items in the list.
If no 'select.variable' is specified, the default 'primary' or 'secondary' select variable is used. The 'secondary' specification uses the active 'secondary' list. (See the 's' option on the list-producing verbs, such as 'sselect').
See the 'then/else construct' for an explanation on the use of 'then' and 'else' clauses in statements that allow or require them.
Example
open 'customer' to customer.file else stop 201,'customer'
execute 'sselect customer with balance.due by name'
loop
readnext item.id else exit
read item from customer.file,item.id then
print 'the name is ':item<1>
end
repeat
The 'readnext' command retrieves the next item-id from an active
list, but does not implicitly address the file. The file to be accessed must
be opened before an attempt to use the item-id in a 'read' statement
can be made.
execute 'select md (s'
loop readnext id secondary else exit
print id
repeat
This builds a 'secondary' list and displays each item-id.
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.
