Using Lists

Syntax

LIST ADD,<list>,<text>
LIST APPEND,<list>,<list2>
LIST ASSIGN,<list>,<list2>
LIST CLEAR,<list>
LIST CLOSE,<list>
LIST COPY,<list>
LIST CREATE,<list>, SORTED
LIST DELETE,<list>
LIST INSERT,<list>
LIST PASTE,<list>
LIST PUT,<list>,<text>
LIST REVERSE,<list>
LIST SEEK,<list>,<record number>
LIST SORT,<list>{,<column>}

Description

These LIST commands are used to modify, save and dispose of string lists. The parameters <list> and <list2> must be either a list number or the name of the dialog list box to which the command will apply. An error will occur if the list does not already exist or the record number (for the SEEK command) is out of range.

ADD is used to add an item to the list. You use this to add items to a sorted list (they are inserted in the correct position according to the sort order) or to append items to an unsorted list, much as you would write successive lines to a text file.

ASSIGN copies the contents of <list2> to <list>

APPEND appends the contents of <list2> to <list>. The second list parameter can be a string containing a list of items separated by carriage return characters as well as a list identifier.

CLEAR is used to remove all items from a list and reset the item pointer to zero.

CLOSE must be used to dispose of a list that you have created once you have finished with it. This releases the memory it used, and makes the list number available again for a new list.

COPY causes the contents of <list> to be copied to the Clipboard.

LIST CREATE creates a new, empty string list. The option SORTED specifies whether the list is to be maintained in ASCII code order. [VDS6] A better method is to use the @NEW(LIST) function. This avoids the difficulty in large programs of knowing which list identifiers have already been used.

DELETE deletes the item at the position in the list indicated by the index (pointer). This is the first item (item 0) when the list is first opened, but can be modified by means of the SEEK command. If the list is a dialog multi-select list box, then all selected items are deleted.In a multiple-select LIST dialog element (using the MULTI style), all selected items are deleted.

INSERT inserts a new item in front of the current pointer position. After the insertion, the index position is the item following the one just inserted. Note that you should not use INSERT with sorted lists.

PASTE causes <list> to be filled with the contents of the Clipboard (as text.)

PUT is used to write the specified text to the position in the list indicated by the index (pointer). PUT lets you treat a list as a random access file. Note that you cannot use PUT with sorted lists.

REVERSE reverses the order of the list items. If your list was filled in order 1 through 10, when you use REVERSE on the list, the first item now becomes 10 and continues down in reverse order.

SEEK is used to set the index pointer to a specific item number.

SORT can use an optional extra parameter when used for a TABLE dialog element. It allows you to specify the column number to sort by – the first column and default value is 1.

OK

Set to true if the command is successful, false if it fails.

Example:

LIST SEEK,1, 3
LIST WRITE,1,This is item 4 in the list
LIST SAVEFILE,1,LIST.TXT
LIST CLOSE,1

See also