Difference between revisions of "LIST"
From SphereWiki
Rattlehead (talk | contribs) |
Rattlehead (talk | contribs) (→Examples) |
||
| Line 38: | Line 38: | ||
| − | SRC.LIST.MyList.ADD | + | This example shows how to add elements to your LIST.''xxx'' : |
| + | |||
| + | <spherescript> | ||
| + | [FUNCTION f_add_to_mylist] | ||
| + | SRC.LIST.MyList.ADD MyElement1 | ||
| + | SRC.LIST.MyList.ADD MyElement2 | ||
| + | SRC.LIST.MyList.ADD MyElement3 | ||
| + | SRC.LIST.MyList.ADD MyElement4 | ||
| + | </spherescript> | ||
| + | |||
| + | To reference your LIST.''xxx'' : | ||
| + | |||
| + | <spherescript> | ||
| + | [FUNCTION f_show_mylist] | ||
| + | serv.log <src.list.MyList> | ||
| + | |||
| + | - ''displays; "MyElement1","MyElement2","MyElement3","MyElement4"'' | ||
| + | </spherescript> | ||
| + | |||
| + | in the LIST above, in order to reference by index : | ||
| + | |||
| + | <spherescript> | ||
| + | src.list.MyList.0 - outputs "MyElement1" | ||
| + | src.list.MyList.1 - outputs "MyElement2" | ||
| + | . . . | ||
| + | </spherescript> | ||
Revision as of 18:53, 1 October 2013
Contents
LIST Functions
These functions will allow the insertion and referencing of elements in a list, this is a global property much like VAR and can be referenced or set globally.
| LIST.key | Read/Write | Description |
| LIST.xxx | R | Shows elements in LIST.xxx |
| LIST.xxx.ADD <args> | W | Adds <args> as a new element in LIST.xxx |
| LIST.xxx.CLEAR | W | Clears LIST.xxx |
| LIST.xxx.n | R | References the nth zero based index of the LIST.xxx |
| LIST.xxx.COUNT | R | Gets the total number of elements in LIST.xxx |
| LIST.xxx.n.REMOVE | W | Removes the nth element in LIST.xxx |
| LIST.xxx.n.INSERT <args> | W | Inserts <args> at the nth index of LIST.xxx |
| LIST.xxx.FINDELEM <args> | W | Searches LIST.xxx for <args> starting from the beginning of LIST.xxx |
| LIST.xxx.n.FINDELEM <args> | W | Searches LIST.xxx for <args> starting from the nth index of LIST.xxx |
| SERV.PRINTLISTS | R | Prints all LISTs and their respective ELEMENTS |
| SERV.CLEARLISTS | W | Clears all LISTs. If used with mask parameter, then it will clear LISTs with specified name |
Examples
Below are examples of the use of the LIST functions:
This example shows how to add elements to your LIST.xxx :
[FUNCTION f_add_to_mylist] SRC.LIST.MyList.ADD MyElement1 SRC.LIST.MyList.ADD MyElement2 SRC.LIST.MyList.ADD MyElement3 SRC.LIST.MyList.ADD MyElement4
To reference your LIST.xxx :
[FUNCTION f_show_mylist] serv.log <src.list.MyList> - ''displays; "MyElement1","MyElement2","MyElement3","MyElement4"''
in the LIST above, in order to reference by index :
src.list.MyList.0 - outputs "MyElement1" src.list.MyList.1 - outputs "MyElement2" . . .