basic.readnext

Statement/BASIC Program, Releases: AP and R83

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

Command Name Type Description
basic.statements Definition Definition of statements and functions.
basic.select Statement Creates internal active list.
basic.execute Statement Performs TCL command expression.
active.list Definition A list of strings delimited by attribute marks created by one of the list-generating processes.
secondary.list Definition A list of item-id's generated by one of the list-generating processes while an active list is present.
basic.then/else.construct Definition provide program flow change based upon a boolean condition.
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.if Statement Initiates logical expression.
access.by-exp Modifier Explodes multi-values for sorting purposes.
access.by-exp-dsnd Modifier Explodes multi-values in descending sequence.
tcl.get-list Verb: Access Retrieves previously saved list.
access.sselect Verb: Access Creates sorted list of items meeting specific criteria.
access.select Verb: Access Creates list of items meeting specific criteria.
basic.open Statement Opens file for input and output.
basic.secondary Definition see 'readnext'.
secondary.list Definition A list of item-id's generated by one of the list-generating processes while an active list is present.
ue.21a3 User Exit Opens a file, or reads the next attribute from a file.
basic.system Function Displays status of system-controlled variables.
basic.execute Statement Performs TCL command expression.
tcl.fl Verb: Access Forms single list from two lists.

User Comments

What do you think?

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

Login to leave your comments.