Difference between revisions of "LIST"
From SphereWiki
Rattlehead (talk | contribs) (→Adding to LIST) |
(→Examples) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 10: | Line 10: | ||
| '''LIST'''''.key'' || '''Read/Write''' || '''Description''' | | '''LIST'''''.key'' || '''Read/Write''' || '''Description''' | ||
|- | |- | ||
− | | [[LIST]].''xxx'' || R || Shows elements in LIST.''xxx'' | + | | '''SERV.'''[[LIST]].''xxx'' || R || Shows elements in LIST.''xxx'' |
|- | |- | ||
− | | [[LIST]].''xxx''.ADD ''<args>'' || W || Adds ''<args>'' as a new element in LIST.''xxx'' | + | | '''SERV.'''[[LIST]].''xxx''.ADD ''<args>'' || W || Adds ''<args>'' as a new element in LIST.''xxx'' |
|- | |- | ||
− | | [[LIST]].''xxx''. | + | | '''SERV.'''[[LIST]].''xxx''.APPEND ''<args>,...'' || W || Sets each ''<args>'' as a new element in LIST.''xxx'' |
|- | |- | ||
− | | [[LIST]].''xxx''. | + | | '''SERV.'''[[LIST]].''xxx''.CLEAR || W || Clears LIST.''xxx'' |
|- | |- | ||
− | | [[LIST]].''xxx''. | + | | '''SERV.'''[[LIST]].''xxx''.SET ''<args>,...'' || W || Clears the list and sets each ''<args>'' as a new element in LIST.''xxx'' |
|- | |- | ||
− | | [[LIST]].''xxx''.'' | + | | '''SERV.'''[[LIST]].''xxx''.SORT ''<args>'' || W || Re-orders LIST.''xxx'' according to ''<args>''. (possible values are: ''no args'' , ''i'' , ''asc'' , ''iasc'' , ''desc'' , ''idesc'') |
|- | |- | ||
− | | [[LIST]].''xxx''.''n | + | | '''SERV.'''[[LIST]].''xxx''.''n'' || R || References the ''nth'' zero based index of the LIST.''xxx'' |
|- | |- | ||
− | | [[LIST]].''xxx''. | + | | '''SERV.'''[[LIST]].''xxx''.COUNT || R || Gets the total number of elements in LIST.''xxx'' |
|- | |- | ||
− | | [[LIST]].''xxx''.''n''.FINDELEM ''<args>'' || W || Searches LIST.''xxx'' for ''<args>'' starting from the ''nth'' index of LIST.''xxx'' | + | | '''SERV.'''[[LIST]].''xxx''.''n''.REMOVE || W || Removes the ''nth'' element in LIST.''xxx'' |
+ | |- | ||
+ | | '''SERV.'''[[LIST]].''xxx''.''n''.INSERT ''<args>'' || W || Inserts ''<args>'' at the ''nth'' index of LIST.''xxx'' | ||
+ | |- | ||
+ | | '''SERV.'''[[LIST]].''xxx''.FINDELEM ''<args>'' || W || Searches LIST.''xxx'' for ''<args>'' starting from the beginning of LIST.''xxx'' | ||
+ | |- | ||
+ | | '''SERV.'''[[LIST]].''xxx''.''n''.FINDELEM ''<args>'' || W || Searches LIST.''xxx'' for ''<args>'' starting from the ''nth'' index of LIST.''xxx'' | ||
|- | |- | ||
| '''SERV.PRINTLISTS''' || R || Prints all LIST''s'' and their respective ELEMENTS | | '''SERV.PRINTLISTS''' || R || Prints all LIST''s'' and their respective ELEMENTS | ||
Line 32: | Line 38: | ||
| '''SERV.CLEARLISTS''' || W || Clears all LIST''s''. If used with mask parameter, then it will clear LIST''s'' with specified name | | '''SERV.CLEARLISTS''' || W || Clears all LIST''s''. If used with mask parameter, then it will clear LIST''s'' with specified name | ||
|} | |} | ||
− | |||
==Examples== | ==Examples== | ||
Line 46: | Line 51: | ||
SERV.LIST.MyList.ADD MyElement3 | SERV.LIST.MyList.ADD MyElement3 | ||
SERV.LIST.MyList.ADD MyElement4 | SERV.LIST.MyList.ADD MyElement4 | ||
+ | |||
+ | ... | ||
+ | |||
+ | SERV.LIST.MyList.SET MyElement1,MyElement2,MyElement3,MyElement4 - will have the same effect as the f_add_to_mylist function above | ||
</spherescript> | </spherescript> | ||
Line 53: | Line 62: | ||
<spherescript> | <spherescript> | ||
[FUNCTION f_show_mylist] | [FUNCTION f_show_mylist] | ||
− | serv.log < | + | serv.log <serv.list.MyList> |
</spherescript> | </spherescript> | ||
Line 62: | Line 71: | ||
<spherescript> | <spherescript> | ||
− | + | serv.list.MyList.0 - outputs "MyElement1" | |
− | + | serv.list.MyList.1 - outputs "MyElement2" | |
. . . | . . . | ||
+ | </spherescript> | ||
+ | |||
+ | ===Sorting the LIST=== | ||
+ | This example shows how to sort your LIST.''xxx'' : | ||
+ | |||
+ | <spherescript> | ||
+ | SERV.LIST.MyList.SORT - ascending sort in case sensitive | ||
+ | SERV.LIST.MyList.SORT asc - ascending sort in case sensitive | ||
+ | SERV.LIST.MyList.SORT i - ascending sort in case insensitive | ||
+ | SERV.LIST.MyList.SORT iasc - ascending sort in case insensitive | ||
+ | SERV.LIST.MyList.SORT desc - descending sort in case sensitive | ||
+ | SERV.LIST.MyList.SORT idesc - descending sort in case insensitive | ||
</spherescript> | </spherescript> | ||
Latest revision as of 20:47, 19 January 2014
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 |
SERV.LIST.xxx | R | Shows elements in LIST.xxx |
SERV.LIST.xxx.ADD <args> | W | Adds <args> as a new element in LIST.xxx |
SERV.LIST.xxx.APPEND <args>,... | W | Sets each <args> as a new element in LIST.xxx |
SERV.LIST.xxx.CLEAR | W | Clears LIST.xxx |
SERV.LIST.xxx.SET <args>,... | W | Clears the list and sets each <args> as a new element in LIST.xxx |
SERV.LIST.xxx.SORT <args> | W | Re-orders LIST.xxx according to <args>. (possible values are: no args , i , asc , iasc , desc , idesc) |
SERV.LIST.xxx.n | R | References the nth zero based index of the LIST.xxx |
SERV.LIST.xxx.COUNT | R | Gets the total number of elements in LIST.xxx |
SERV.LIST.xxx.n.REMOVE | W | Removes the nth element in LIST.xxx |
SERV.LIST.xxx.n.INSERT <args> | W | Inserts <args> at the nth index of LIST.xxx |
SERV.LIST.xxx.FINDELEM <args> | W | Searches LIST.xxx for <args> starting from the beginning of LIST.xxx |
SERV.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:
Adding to LIST
This example shows how to add elements to your LIST.xxx :
[FUNCTION f_add_to_mylist] SERV.LIST.MyList.ADD MyElement1 SERV.LIST.MyList.ADD MyElement2 SERV.LIST.MyList.ADD MyElement3 SERV.LIST.MyList.ADD MyElement4 ... SERV.LIST.MyList.SET MyElement1,MyElement2,MyElement3,MyElement4 - will have the same effect as the f_add_to_mylist function above
Referencing the LIST
To reference your LIST.xxx :
[FUNCTION f_show_mylist] serv.log <serv.list.MyList>
displays; "MyElement1","MyElement2","MyElement3","MyElement4"
Referencing Single Elements
in the LIST above, in order to reference by index :
serv.list.MyList.0 - outputs "MyElement1" serv.list.MyList.1 - outputs "MyElement2" . . .
Sorting the LIST
This example shows how to sort your LIST.xxx :
SERV.LIST.MyList.SORT - ascending sort in case sensitive SERV.LIST.MyList.SORT asc - ascending sort in case sensitive SERV.LIST.MyList.SORT i - ascending sort in case insensitive SERV.LIST.MyList.SORT iasc - ascending sort in case insensitive SERV.LIST.MyList.SORT desc - descending sort in case sensitive SERV.LIST.MyList.SORT idesc - descending sort in case insensitive