readnext Statement

The readnext statement retrieves the next item-ID from an active list and assigns it to a specified variable.

Syntax

readnext ID.var{,value.count}{from select.var} [then|else statement.block]

Parameter(s)

value.count

Indicates the position of the MultiValue within an attribute. This is a by-product of an exploded sort, executed prior to the execution of the program. This allows MultiValues to be retrieved in exploded sort sequence. If the list is not exploded, the value count value is always 1.

select.var  

If select.var is not specified, the default primary or secondary select variable is used. The secondary specification uses the active secondary list.

Description

A list must be active before the readnext occurs. The list can be generated within the program or the list can be passed into the program from an external process, such as TCL or a Proc, that invokes a list producing command immediately before running this program.

The else condition is executed when there are no more items in the list.

TIP

Another select clears the primary and secondary lists.

The select and readnext statements both consume an external list if one is available. As a result, system(11) always returns 0 after one of these commands. For example:

execute "select bp sampling 5"

print system(11)

select

print system(11)

This prints 5, then 0. The external list is consumed by a BASIC variable and is then only available from FlashBASIC or BASIC.

When using an external list, it is necessary to readnext all items in that list until the readnext actually fails. At this point, the list is reset and it searches again for a new external list.

Example(s)

The readnext statement 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.

open ’customer’ to customer.file else stop 201,’customer’

execute ’sselect customer with balance.due by name’

loop

readnext item-ID else atop

read item from customer.file,item-ID then

print ’the name is ’:item<1>

end

repeat

This displays each item-ID.

execute "select md (s"

loop readnext ID else stop

print ID

repeat

See Also

Active List

begin work Statement

by-exp Modifier

by-exp-dsnd Modifier

execute Statement

file Statement

fl Command

get-list Command

if Statement

loop Statement

open Statement

Secondary List

select Command

select Statement

sselect Command

Statement Blocks

Statements and Functions

system() Function

then/else Statement Blocks

u21a3 User Exit