READLIST Statement
Reads a list from POINTER-FILE and assigns it to a variable for program manipulation. See also the GETLIST statement.
Syntax
READLIST dyn-array FROM ["list-id" || "list-id account-name"] {SETTING setting-var} [THEN statement(s) | ELSE statement(s)]
Syntax Elements
dyn-array is the name of the variable to which the list is assigned as a dynamic array.
list-id is the name of the list saved in POINTER-FILE.
account-name specifies an account, other than the current account, from which the list was saved.
setting-var is the name of the variable to which the number of items in the list is assigned if the SETTING clause is used.
statement(s) is either a THEN or an ELSE clause (or both). A statement must be included. The THEN clause is executed if the read is successful. The ELSE clause is executed otherwise.
Operation
The
READLIST allows a DataBasic program to read in a saved list, place the contents in a variable, and then modify or search its contents.
If you READ a list, modify it, and want to save it in the POINTER-FILE again, use the WRITELIST statement.
Examples
READLIST A FROM ITEMX ELSE STOP
Reads the list identified by the contents of variable into variable A.
X = "MYLIST" READLIST LIST1 FROM X ELSE PRINT "CANNOT READ ":X; STOP
Reads the list from POINTER-FILE MYLIST into variable LIST1. If the list cannot be read, an error message is displayed and the program is terminated.
READLIST LIST1 FROM '60-90' ELSE GOTO 100
READLIST LIST2 FROM 'OVER-90' ELSE GOTO 100
LIST3 = LIST1:AM:LIST2 ; * Combine the lists
WRITELIST LIST3 ON 'OVER-60'
.
.
GETLIST 'OVER-60' TO ALIST SETTING ACCOUNT THEN
FOR I = 1 TO ACCOUNT
READNEXT ID FROM ALIST ELSE PRINT 'ERROR'
READ AITEM FROM AFILE,ID ELSE AITEM = ''
.
.
NEXT I
END
Reads the lists saved in 60-90 and OVER-90 and combines them into a new list. The new list is then written back to the POINTER-FILE using the WRITELIST statement. This new list can then be manipulated by the program.
See Also
READLIST Statement (MultiValue Compatibility).