backIndex

Xelagot action script

String lists


 

 

Introduction

String lists are ordered collections of strings. Xelagot uses Delphi's TStringList objects for these. The contents can be saved to or loaded from file, and manipulated in various ways, as listed below in the Statements section. Specific use is to store name=value pairs, and as database. Xelagot 3.600 introduces a new way of handeling the string list as database, with statements starting with DB instead of SList.

These lists must first be declared using the var keyword, as they are not created by default. See Xelagot action script: Variables. They store strings.
For example, you can create string lists called /s_myList, /s_myList1, /s_myList2:
var /s_myList, /s_myList1, /s_myList2

As from X1 2.9999975 and Av99bot/SrvcXlgBot 2.8 onwards, you can pack the name of a string list into a Packer variable, and use it as a substitute. This gives you a lot of flexibility when you need to apply the same operations to different string lists. For example:

var /s_myList1, /s_MyList2
# instead of
# SListClear /s_MyList1
# SListClear /s_MyList2
# you can write
^a = "/s_MyList1"
SListClear ^a
^a = "/s_MyList2"
SListClear ^a

 

 

Statements

Clearing, Retrieving, Loading, Saving:

/s_myList1 = /s_myList2 clears list /s_myList1, copies all strings from /s_myList2 to /s_myList1. Does not work with string variables that contain string list names: in this case, use SListCopy (or 3.600 statement DBCopy).
SListClear /s_myList clears the list
DBClear /s_myList xelagot 3.600
clears the list. Note: this does exactly the same as SListClear, it does not check the validity of the database. It has been added for uniformity in the notation.
SListLoad /s_myList $file [%rc] loads a text file $file into the list. Optionally %rc = 0 if all goes well, -1 otherwise.

xelagot 3.607 or newer
The filename convention is explained in the section Filenames.

xelagot 3.606 or older
The path defaults to the path of the current script file. A full drive + path may also be specified, see Program paths.
DBLoad /s_myList $file [%rc] xelagot 3.600
loads a text file $file into the list. Optionally %rc = 0 if all goes well, -1 otherwise. After loading the file, it removes any line that is not a valid name=value pair. Note: this does almost exactly the same as SListLoad, it does not check the validity of the database but it removes any lines that do not have a name=value pair, i.e. it combines SListLoad and SListNameValueOnly.

xelagot 3.607 or newer
The filename convention is explained in the section Filenames.

xelagot 3.606 or older
The path defaults to the path of the current script file. A full drive + path may also be specified, see Program paths.
SListMerge /s_myList $file [%rc] merges a text file $file into the list. Optionally %rc = 0 if all goes well, -1 otherwise.

xelagot 3.607 or newer
The filename convention is explained in the section Filenames.

xelagot 3.606 or older
The path defaults to the path of the current script file. A full drive + path may also be specified, see Program paths.
SListSave /s_myList $file [%rc] saves a list as text file $file, overwriting the file if it exists. Optionally %rc = 0 if all goes well, -1 otherwise.

xelagot 3.607 or newer
The filename convention is explained in the section Filenames. If the destination path and folder does not exist, it will be created to accommodate the file.

xelagot 3.606 or older
The path defaults to the path of the current script file. A full drive + path may also be specified, see Program paths.
DBSave /s_myList $file [%rc] xelagot 3.600
saves a list as text file $file, overwriting the file if it exists. Optionally %rc = 0 if all goes well, -1 otherwise. Note: this does exactly the same as SListSave, it does not check the validity of the database. It has been added for uniformity in the notation.

xelagot 3.607 or newer
The filename convention is explained in the section Filenames. If the destination path and folder does not exist, it will be created to accommodate the file.

xelagot 3.606 or older
The path defaults to the path of the current script file. A full drive + path may also be specified, see Program paths.
SListSaveAppend /s_myList $file [%rc] x1 2.9999971 Appends a list to text file $file (creates the file if it does not exist). Optionally %rc = 0 if all goes well, -1 otherwise.

xelagot 3.607 or newer
The filename convention is explained in the section Filenames. If the destination path and folder does not exist, it will be created to accommodate the file.

xelagot 3.606 or older
The path defaults to the path of the current script file. A full drive + path may also be specified, see Program paths.
SListCopy /s_myList1 /s_myList2 X1 2.9999977 Clears list /s_myList1, copies all strings from /s_myList2 to /s_myList1. Works also with string variables that contain string list names.
DBCopy /s_myList1 /s_myList2 xelagot 3.600
Clears list /s_myList1, copies all strings from /s_myList2 to /s_myList1. Works also with string variables that contain string list names. Note: this does exactly the same as SListCopy, it does not check the validity of the database. It has been added for uniformity in the notation.
SListAppend /s_myList1 /s_myList2 X1 2.9999977 Copies all strings from /s_myList2 to /s_myList1, appending them (it does not clear /s_MyList1 first). Works also with string variables that contain string list names.
SListSetText /s_myList $t clears the list and adds the text pointed at by text label $t
SListAddText /s_myList $t appends to the string list the text pointed at by text label $t
SListNoBlanks /s_myList removes all empty lines and lines which contain only blanks (spaces, tabs).
SListNameValueOnly /s_myList removes all entries from the list that are not a name=value pair
SListTrim /s_myList xelagot 3.608
removes all leading and trailing blanks (spaces, tabs) from lines in the string list.

Manipulating individual entries:

x1 2.9999975
SListCount /s_myList %c
older
SListGetCount /s_myList %c
retrieves the number of items in the list and stores that value in %c
DBCount /s_myList %c
xelagot 3.600
retrieves the number of items in the list and stores that value in %c. Note: this does exactly the same as SListCount, it does not check the validity of the database. It has been added for uniformity in the notation.
x1 2.9999975
SListAdd /s_myList $t
older
SListAddLine /s_myList $t
SItemAdd /s_myList $t
appends to the string list the string $t
x1 2.9999975
SListGet /s_myList [%p] $a
older
SItemGet /s_myList [%p] $a
assigns to $a the string in item index %p of list, and resets the list pointer to %p. If %p is not specified, uses the current pointer value.
x1 2.9999975
SListReplace /s_myList [%p] $a
older
SItemReplace /s_myList [%p] $a
assigns to the item index %p the value of $a and resets the list pointer to %p. If %p is not specified, uses the current pointer value.
x1 2.9999975
SListInsert /s_myList [%p] $a
older
SItemInsert /s_myList [%p] $a
inserts a new item in the list at index %p, assigns it the value of $a and resets the list pointer to %p. If %p is not specified, uses the current pointer value. If the pointer is out of rande, adds an item to the list.
x1 2.9999975
SListDelete /s_myList [%p]
older
SItemDelete /s_myList [%p]
deletes item index %p. If %p is not specified, uses the current pointer value.
x1 2.9xxx
SListGetValue /s_myList $n $v
SListGetValue /s_myList %n $v
older
SItemGetValue /s_myList $n $v
SItemGetValue /s_myList %n $v
Gets the value $v from the name $n in a name=value pair. The name is not case sensitive. The string stored in the list must have the following structure:
name=value. If the name is an integer, the second convention %n may be followed.

Note: if the list is database 'old style', the value retrieved corresponds to the entire comma separated record (except for the name field). xelagots 3.606 or newer can use SListRecordGetField and SListRecordGetFields to retrieve the individual fields from $v.
DBGetValue /s_myList $n $v
DBGetValue /s_myList %n $v
xelagot 3.606

Gets the value $v from the name $n in a name=value pair (the $name gets DBEncoded automatically). The name is not case sensitive. The string stored in the list must have the following structure:
name=value. If the name is an integer, the second convention %n may be followed. It is assumed that the list has a DB structure, but the only requirement is that it contains name=value pairs, and that names are DBEncoded.

Note: if the list is database 'new style', the value retrieved corresponds to the entire comma separated record (except for the name field), DBEncoded fields remain DBEncoded. xelagots 3.606 or newer can use DBRecordGetField and DBRecordGetFields to retrieve the individual fields from $v.
IfSListGetValue /s_myList $n $v statement
IfSListGetValue /s_myList %n $v statement
similar to SListGetValue, combined with an IfString $v <> "" statement: if it gets a valid value ($v is not empty) executes statement. May be followed by an Else clause.
IfDBGetValue /s_myList $n $v statement
IfDBGetValue /s_myList %n $v statement
xelagot 3.600

A weird little statement for a database, mainly used to test whether a record with name $n or %n exists. The value retrieved is a comma separated list of DBEncoded fields.
x1 2.9xxx
SListSetValue /s_myList $n $v
SListSetValue /s_myList %n $v
older
SItemSetValue /s_myList $n $v
SItemSetValue /s_myList %n $v
Sets the value $v from the name $n in a name=value pair. The name is not case sensitive, and a value of an existing name=value pair will be replaced by the new value. The string stored in the list will have the following structure:
name=value. If the name is an integer, the second convention %n may be followed.
SListDeleteName /s_myList $n
SListDeleteName /s_myList %n
Removes, if the name=value pair is found, the name $n and its associated value from the list. If the name is an integer, the second convention %n may be followed.
DBDeleteName /s_myList $n
DBDeleteName /s_myList %n
xelagot 3.600
First, converts the value $n using DBEncode, then removes, if the name=value pair is found, the name $n and its associated value from the list. If the name is an integer, the second convention %n may be followed. To be used on string list databases made with DBSetField(s), or when names are DBEncoded.
SListGetNames /s_myList $a
makes a comma separated formated string $a (ready for printing) of all names in name=value pairs. Returns an empty string if none found.
DBGetNames /s_myList $a
xelagot 3.600
makes a comma separated formated string $a (ready for printing) of all names in name=value pairs. Returns an empty string if none found. To be used on string list databases made with DBSetField(s), or when names are DBEncoded.
SListGetNamesSDF /s_myList $a
xelagot 3.606
makes a comma separated formated string $a (using the SDF method) of all names in name=value pairs. Returns an empty string if none found.
Use GetFirstSDF $n $a repeatedly to recover the individual names in $n, until $n has an empty string.
DBGetNamesSDF /s_myList $a
xelagot 3.606
makes a comma separated formated string $a (using the SDF method) of all names in name=value pairs. Returns an empty string if none found. To be used on string list databases made with DBSetField(s), or when names are DBEncoded.
Use GetFirstSDF $n $a repeatedly to recover the individual names in $n, until $n has an empty string.
SListSetField /s_myList $n %f %i
SListSetField /s_myList $n %f !t
SListSetField /s_myList $n %f @p
SListSetField /s_myList $n %f &p
SListSetField /s_myList $n %f ~p
SListSetField /s_myList $n %f $a
or
SListSetField /s_myList %n %f %i
SListSetField /s_myList %n %f !t
SListSetField /s_myList %n %f @p
SListSetField /s_myList %n %f &p
SListSetField /s_myList %n %f ~p
SListSetField /s_myList %n %f $a
this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). SListSetField looks for name $n and creates it if necessary. Then it searches for field number %f starting by 1, creates empty fields when necessary. It then puts the value represented by the last variable in its corresponding field. If the name is an integer, the second convention %n may be followed.

Note: you can not store a float value directly from a numeric variable, you must first convert it to string (e.g from %a to $a) and then store the string:
StringFromReal $a %a [%precision]
DBSetField /s_myList $n %f %i
DBSetField /s_myList $n %f !t
DBSetField /s_myList $n %f @p
DBSetField /s_myList $n %f &p
DBSetField /s_myList $n %f ~p
DBSetField /s_myList $n %f $a
or
DBSetField /s_myList %n %f %i
DBSetField /s_myList %n %f !t
DBSetField /s_myList %n %f @p
DBSetField /s_myList %n %f &p
DBSetField /s_myList %n %f ~p
DBSetField /s_myList %n %f $a
xelagot 3.600

this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). The difference with SListSetField is that strings and the world name are encoded by DBSetField using DBEncode, that encodes percentage, comma and equal signs to %1, %2, %3. DBSetField looks for name $n and creates it if necessary. Then it searches for field number %f starting by 1, creates empty fields when necessary. It then puts the value represented by the last variable in its corresponding field. If the name is an integer, the second convention %n may be followed.

Note: you can not store a float value directly from a numeric variable, you must first convert it to string (e.g from %a to $a) and then store the string:
StringFromReal $a %a [%precision]
SListGetField /s_myList $n %f %i
SListGetField /s_myList $n %f !t
SListGetField /s_myList $n %f @p
SListGetField /s_myList $n %f &p
SListGetField /s_myList $n %f ~p
SListGetField /s_myList $n %f $a
or
SListGetField /s_myList %n %f %i
SListGetField /s_myList %n %f !t
SListGetField /s_myList %n %f @p
SListGetField /s_myList %n %f &p
SListGetField /s_myList %n %f ~p
SListGetField /s_myList %n %f $a
this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). SListGetField looks for name $n. Then it searches for field number %f starting by 1, ignores non existing fields, pretending they exist. It then retrieves the value represented by the last variable in the field and assignes it to the variable. Non-values or overflows default to: 0 for integers, the origin of the Delphi DateTime system for date-time (30 dec 1899 0h 0m 0s), 0.000n 0.000w 0.00a 0.0 for location. If the name is an integer, the second convention %n may be followed.

As from version 3.6, dates and times stored in SQL format are also read correctly into a date time variable:
YYYY-MM-DD hh:mm:ss
YYYY-MM-DD (this one sets the time to 0h 0m 0s)
hh:mm:ss (this one sets the date to 30 dec 1899)


As from version 3.6, floats can be read directly into numeric variables. Up to this version, you need to read into a string, e.g. $a, and then convert to numeric, using %a = $a.
DBGetField /s_myList $n %f %i
DBGetField /s_myList $n %f !t
DBGetField /s_myList $n %f @p
DBGetField /s_myList $n %f &p
DBGetField /s_myList $n %f ~p
DBGetField /s_myList $n %f $a
or
DBGetField /s_myList %n %f %i
DBGetField /s_myList %n %f !t
DBGetField /s_myList %n %f @p
DBGetField /s_myList %n %f &p
DBGetField /s_myList %n %f ~p
DBGetField /s_myList %n %f $a
xelagot 3.600

this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). The difference with SListGetField is that strings and the world name are decoded by DBGetField using DBDecode, that decodes commas, percentages and equal signs encoded by DBEncode, DBSetField and DBSetFields. DBGetField looks for name $n. Then it searches for field number %f starting by 1, ignores non existing fields, pretending they exist. It then retrieves the value represented by the last variable in the field and assignes it to the variable. Non-values or overflows default to: 0 for integers, the origin of the Delphi DateTime system for date-time (30 dec 1899 0h 0m 0s), 0.000n 0.000w 0.00a 0.0 for location. If the name is an integer, the second convention %n may be followed.

Dates and times stored in SQL format are also read correctly into a date time variable:
YYYY-MM-DD hh:mm:ss
YYYY-MM-DD (this one sets the time to 0h 0m 0s)
hh:mm:ss (this one sets the date to 30 dec 1899)


Floats can be read directly into numeric variables.
SListAddField /s_myList %f %i
SListAddField /s_myList %f $a
this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). SListAddField searches all name=value pairs for field number %f starting by 1, ignores non existing fields, pretending they are there. If the last parameter is a numeric variable, it then retrieves the integer value of the field and adds it up, the total sum of field number %f is assigned to %i. Non-integer values or overflows default to 0. If the last parameter is a string variable, it makes a comma separated formated string (ready for printing), similar to the one produced by SListGetNames. This statement has been renamed, it was first called SListAddFields, which now has another meaning.
DBAddField /s_myList %f %i
DbAddField /s_myList %f $a
xelagot 3.600

this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). The difference with DBAddField is that strings by DBAddField using DBDecode, that decodes commas, percentages and equal signs encoded by DBEncode, DBSetField and DBSetFields. DBAddField searches all name=value pairs for field number %f starting by 1, ignores non existing fields, pretending they are there. If the last parameter is a numeric variable, it then retrieves the integer value of the field and adds it up, the total sum of field number %f is assigned to %i. Non-integer values or overflows default to 0. If the last parameter is a string variable, it makes a comma separated formated string (ready for printing), similar to the one produced by DBGetNames.
SListSetFields /s_myList $n %c variables
SListSetFields /s_myList %n %c variables
this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). SListSetFields sets the first fields up to field %c with the values provided in the variables. These variables must be space-separated. To skip a field, use any non-variable placeholder, like for instance a string-literal. For example:
SListSetFields /s_TeamA $Paticipant 3 %hits xxx %total
will set the 1st and 3rd fields of $Participant's record, and skip the second. The variables are the same as allowed for fields in SListSetField. If the name is an integer, the second convention %n may be followed.

Note: you can not store a float value directly from a numeric variable, you must first convert it to string (e.g from %a to $a) and then store the string:
StringFromReal $a %a [%precision]
DBSetFields /s_myList $n %c variables
DBSetFields /s_myList %n %c variables
xelagot 3.600

this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). The difference with SListSetFields is that strings and the world name are encoded by DBSetFields using DBEncode, that encodes percentage, comma and equal signs to %1, %2, %3. DBSetFields sets the first fields up to field %c with the values provided in the variables. These variables must be space-separated. To skip a field, use any non-variable placeholder, like for instance a string-literal. For example:
DBSetFields /s_TeamA $Paticipant 3 %hits xxx %total
will set the 1st and 3rd fields of $Participant's record, and skip the second. The variables are the same as allowed for fields in SListSetField. If the name is an integer, the second convention %n may be followed.

Note: you can not store a float value directly from a numeric variable, you must first convert it to string (e.g from %a to $a) and then store the string:
StringFromReal $a %a [%precision]
SListGetFields /s_myList $n %c variables
SListGetFields /s_myList %n %c variables
this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). SListGetFields gets the values in the first fields up to field %c and assignes them to the variables. These variables must be space-separated. To skip a field, use any non-variable placeholder, like for instance a string-literal. For example:
SlistGetFields /s_TeamA $Paticipant 3 %hits xxx %total
will retrieve the 1st and 3rd fields of $Participant's record, and skip the second. The variables are the same as allowed for fields in SListGetField. If the name is an integer, the second convention %n may be followed.

As from version 3.6, dates and times stored in SQL format are also read correctly into a date time variable:
YYYY-MM-DD hh:mm:ss
YYYY-MM-DD (this one sets the time to 0h 0m 0s)
hh:mm:ss (this one sets the date to 30 dec 1899)


As from version 3.6, floats can be read directly into numeric variables. Up to this version, you need to read into a string, e.g. $a, and then convert to numeric, using %a = $a.
DBGetFields /s_myList $n %c variables
DBGetFields /s_myList %n %c variables
xelagot 3.600

this statement is only used in lists containing name=value pairs, where the value is a comma separated string containing fields (no commas are allowed in these fields). The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). The difference with SListGetFields is that strings and the world name are decoded by DBGetFields using DBDecode, that decodes percentage, comma and equal signs encoded by DBEncode, DBSetField and DBSetFields. DBGetFields gets the values in the first fields up to field %c and assignes them to the variables. These variables must be space-separated. To skip a field, use any non-variable placeholder, like for instance a string-literal. For example:
DBGetFields /s_TeamA $Paticipant 3 %hits xxx %total
will retrieve the 1st and 3rd fields of $Participant's record, and skip the second. The variables are the same as allowed for fields in SListGetField. If the name is an integer, the second convention %n may be followed.

Dates and times stored in SQL format are also read correctly into a date time variable:
YYYY-MM-DD hh:mm:ss
YYYY-MM-DD (this one sets the time to 0h 0m 0s)
hh:mm:ss (this one sets the date to 30 dec 1899)

Floats can be read directly into numeric variables.
SListGetRecord /_myList %i $n variables xelagot 3.600

This statement was added to xelagot 3.600 to help migrating old databases to the new DB style. Record number %i (from 1 to number of records obtained with SListCount %c) gets retrieved: the name field is assigned to $n, the other fields are assigned to the variable list, which is similar to the ones in SListGetFields. To migrate the database from old style in /s_old to /s_new, do something like this in a loop, where the name is retrieved in $citnumber, and there are 3 more fields, of which $citname is URLEncoded:

SListGetRecord /s_old %i $citnumber $citname %life %shots
URLDecode $citname $citname
DBSetFields /s_new $citnumber 3 $citname %life %shots

Note: If you need the whole value part of the name=value pair, use SListGetValue.

DBGetRecord /_myList %i $n variables xelagot 3.600

Similar to the previous statement but retrieves from new style database. May come in useful to retrieve a record by number. Do not use it to migrate databases!


xelagot 3.606 Note: If you need the whole value part of the name=value pair, use DBGetValue.

SListGetString /s_myList $n %c
SListGetString /s_myList %n %c
SListGetStringExact /s_myList $n %c
SListGetStringExact /s_myList %n %c
Matches $n with the whole strings in the list, and stops at the first occurrence of the string. Case insensitive or sensitive, but works faster if the match is exact. The notation with %n may be used if the list contains integers. If no match is found, %c = 0, otherwise %c is the item's index number (pointer, starts at 1).
IfSListGetString /s_myList $n %c statement
IfSListGetString /s_myList %n %c statement
IfSListGetStringExact /s_myList $n %c statement
IfSListGetStringExact /s_myList %n %c statement
similar to SListGetString and SListGetStringExact, combined with an IfInt %c > 0 statement: if it gets a valid value (%c > 0) executes statement. May be followed by an Else clause. Otherwise %c is the item's index number (pointer, starts at 1).
IfSListInString /s_myList $a %frL %frS %posL %posS $s statement
IfSListInStringExact /s_myList $a %fr %pos $s statement
see IfNameInString for an alternative statement
compares each string in the list with string $a, starting at position %frL in List and %frS in string $a (first position = 1). If it finds a substring of $a, %posL and %posS get the positions of the the List pointer and begining of the substring, $s gets the substring, and statement is executed. IfSListInString is not case sensitive, IfSListInStringExact is case sensitive. An Else clause may follow. Use for instance to see if a word kept in a list appears in a chatline. Is shorter than:
%found = 0
Copy $a2 $a %frS
SListGetCount /s_myList %c
%i = %frL
Label LoopList
   IfInt %i > %c Goto LoopListEnd
   SItemGet /s_myList %i $b
   IfString $b IsIn $a2 %found = 1
   # or IfStringExact ....
   IfInt %found = 1 Goto LoopListEnd
   Inc %i
   Goto LoopList
Label LoopListEnd
IfInt %found = 0 Goto MyElse
%posL = %i
$s = $b
Pos %posS $s $a %frS
# here comes the statement

Label MyElse
# alternative statement    
(I hope i got it right LOL)
IfSListWordInString /s_myList $a $w statement
IfSListWordInStringExact /s_myList $a $w statement
see IfNameWordInString for an alternative statement
checks each string in the list to see if it is a word in string $a. The following rules apply: (1) the string in the list item is cut at the first appearence of an equal sign, if any is present (2) then it searches if this is a word in string $a (3) separators for words are Space and the following characters .,;:¡!¿? (4) if a word is found, it is assigned to variable $w. An Else clause may follow. Use for instance to see if a word kept in a list appears in a chatline. Why cut at the first equal sign? If an equal sign is present, the item of the string list is a name=value pair, and the word in question is the name part of that pair. The value part may be retrieved using the SListGetValue or IfSListGetValue statements.
IfSListGetNameValue /s_myList $a $n $v statement
used for lists that store name=value pairs. Checks all names (case insensitive) to see if one is equal to string $a. Retrieves the first match as $n (name) and $v (value).
IfNameInString /s_myList $a $a1 $name $a2 $v statement
IfSListNameInString /s_myList $a $a1 $name $a2 $v statement
checks each name in a name-value pair list to see if it is a sub-string of string $a. The following rules apply: (1) each string in the list item is cut at the first appearence of an equal sign, if any is present: this is the name of the name-value pair; (2) then it searches if this name is a sub-string in string $a (case insensitive). If it is not a sub-string, it searches the next element of the string list. If the name is a sub-string, it splits $a into three parts; $a1 contains the sub-string before the name, $name contains the name as is written in string $a, $a2 contains the rest of string $a, $v contains the value corresponding to the name, if one is defined; then it executes the statement. An Else clause may follow, which is executed if nothing is found. Use to see if a word kept as name in a list appears in a chatline as a sub-string of the chatline. Because $a2 contains the rest of string $a, one can keep on picking out new occurrences of names in $a: this is valid
IfNameInString /s_words $chatline $a1 $word $chatline $value Gosub DoSomething
See comments in next statement.
IfNameWordInString /s_myList $a $a1 $name $a2 $v statement
IfSListNameWordInString /s_myList $a $a1 $name $a2 $v statement
checks each name in a name-value pair list to see if it is a word in string $a. The following rules apply: (1) each string in the list item is cut at the first appearence of an equal sign, if any is present: this is the name of the name-value pair; (2) then it searches if this name is a word in string $a (case insensitive) (3) separators for words are Space and the following characters .,;:¡!¿?. If it is not a a word in $a, it searches the next element of the string list. If it is a word in $a, it splits $a into three parts; $a1 contains the sub-string before the word (including the last separator), $name contains the word as written in string $a, $a2 contains the rest of the string (including the separator after $name), $v contains the value corresponding to the name, if one is defined; then it executes the statement. An Else clause may follow, which is executed if nothing is found. Use to see if a word kept as name in a list is a word (separated by the above mentioned separators) in a chatline. Because $a2 contains the rest of string $a, one can keep on picking out new occurrences of names in $a: this is valid, if $value contains the name of a Sub

Label LabOne
   IfNameWordInString /s_words $chatline $a1 $word $chatline $value Gosub $value
   Else Goto Lab2
   Goto LabOne
Label Lab2

... but can cause repeating an action when the same word occurs more than once in a chatline :) Beware of circularity... which can cause the bot to remain in an endless loop and finally crash.
SListGetPointer /s_myList %c retrieves the pointer to the current list item and stores that value in %c. A value of 0 means the list is empty.
SListSetPointer /s_myList %c sets the current list item and stores the pointer value in %c. If the pointer is set higher that the last item, or lower than 1, it will automatically be set to 1. If the list is empty, the pointer will default to 0.
SListRenumber /s_MyList [NO] xelagot 3.606

Prepends to each line in the list a number followed by an equal sign, starting with number 1. Optionally, can have a "NO" string parameter (literal or in a variable). If NO is omitted (default setting), it will, before prepending the number, look for an equal sign in the line and, if found, change it to a comma.

See DBRenumber.
DBRenumber /s_MyList [NO] xelagot 3.606

Works exactly the same as SListRenumber.

Usefull when having called an SQLQuerySelect statement, with %KeyField = -1, that only gives a comma separated record, with no name=value structure. Calling DBRenumber after this query adds the name part as a sequence of integers starting with 1, allowing you to use this /s_MyList as a database. The NO parameter may be omitted in this case, as it has no effect (equal signs are DBEncoded and do no show).
SListRecordGetField $Record %Number %i
SListRecordGetField $Record %Number !t
SListRecordGetField $Record %Number @p
SListRecordGetField $Record %Number &p
SListRecordGetField $Record %Number ~p
SListRecordGetField $Record %Number $a
xelagot 3.606

Assumes a comma separated list of field values in $Record, for example as retrieved from a database 'old style' with:
SListGetValue /s_MyList $name $Record
or with IfListGetValue etc.
Retrieves an individual field at position %Number and stores it in the variable %i, !t, etc. Works similar to SListGetField, only the record is in a string instead of a list.
DBRecordGetField $Record %Number %i
DBRecordGetField $Record %Number !t
DBRecordGetField $Record %Number @p
DBRecordGetField $Record %Number &p
DBRecordGetField $Record %Number ~p
DBRecordGetField $Record %Number $a
xelagot 3.606

Assumes a comma separated list of field values in $Record, for example as retrieved from a database 'new style' with:
DBGetValue /s_MyList $name $Record
or with IfDBGetValue etc.
Retrieves an individual field at position %Number and stores it in the variable %i, !t, etc, DBDecoding it if necessary. It works similar to DBGetField, only the record is in a string instead of a list.
SListRecordGetFields $Record %Number variables
xelagot 3.606

$Record contains a comma separated string of fields values (no commas are allowed in these fields), as retrieved from a database 'old style' with:
SListGetValue /s_MyList $name $Record
or with IfListGetValue etc. It works similar to SListGetFields, only in this case the record is in a string instead of a list.
The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). SListRecordGetFields gets the values in the first fields up to field %c and assignes them to the variables. These variables must be space-separated. To skip a field, use any non-variable placeholder, like for instance a string-literal. For example:
SlistRecordGetFields $Scores 3 %hits xxx %total
will retrieve the 1st and 3rd fields of the $Scores record, and skip the second. The variables are the same as allowed for fields in SListRecordGetField.
Dates and times stored in SQL format are also read correctly into a date time variable:
YYYY-MM-DD hh:mm:ss
YYYY-MM-DD (this one sets the time to 0h 0m 0s)
hh:mm:ss (this one sets the date to 30 dec 1899)

Floats can be read directly into numeric variables.
DBRecordGetFields $Record %Number variables
xelagot 3.606

$Record contains a comma separated string of DBEncoded field values, as retrieved from a database 'new style' with:
DBGetValue /s_MyList $name $Record
or with IfDBGetValue etc. It works similar to DBGetFields, only in this case the record is in a string instead of a list.
The fields may represent strings, integers, delphi-style DateTime floats, and location optionally including world (also person and object as location). The difference with SListRecordGetFields is that strings and the world name are decoded by DBRecordGetFields using DBDecode, that decodes percentage, comma and equal signs encoded by DBEncode, DBSetField and DBSetFields. DBRecordGetFields gets the values in the first fields up to field %c and assignes them to the variables. These variables must be space-separated. To skip a field, use any non-variable placeholder, like for instance a string-literal. For example:
DBRecordGetFields $Scores 3 %hits xxx %total
will retrieve the 1st and 3rd fields of the $Scores record, and skip the second. The variables are the same as allowed for fields in DBRecordGetField.

Dates and times stored in SQL format are also read correctly into a date time variable:
YYYY-MM-DD hh:mm:ss
YYYY-MM-DD (this one sets the time to 0h 0m 0s)
hh:mm:ss (this one sets the date to 30 dec 1899)

Floats can be read directly into numeric variables.

Special statements. The sorting algorithm is QuickSort and is not 'stable' (successive sorts disarrange previous ones).

SListSortNames /s_myList
SListReverseSortNames /s_myList
SListSortField /s_myList %f
SListReverseSortField /s_myList %f
x1 2.9999977 Sorts the list according to names or field number %f in name=value pairs. To sort by a field, %f must have the field number (1 or higher). If %f = 0, the names are sorted, if %f = -1 the values are sorted as one large field. And if %f = -2, then the whole string is used to sort the list.
SListSortUCNames /s_myList
SListReverseSortUCNames /s_myList
SListSortUCField /s_myList %f
SListReverseSortUCField /s_myList %f
x1 2.9999977 Sorts the list according to URLEncoded names or field number %f in name=value pairs. The requested name or field must contain only URL encoded strings. To sort by a field, %f must have the field number (1 or higher). If %f = 0, the names are sorted, if %f = -1 the values are sorted as one large field. And if %f = -2, then the whole string is used to sort the list.
DBSortStringNames /s_myList
DBReverseSortStringNames /s_myList
DBSortStringField /s_myList %f
DBReverseSortStringField /s_myList %f
xelagot 3.600

Sorts the list according to DBEncoded names or field number %f in name=value pairs. The requested name or field must contain only DBEncoded strings. Databases made with the 3.600 DB prefix have all strings DBEncoded automatically. To sort by a field, %f must have the field number (1 or higher). If %f = 0, the names are sorted, if %f = -1 the values are sorted as one large field. And if %f = -2, then the whole string is used to sort the list.
SListSortIntNames /s_myList
SListReverseSortIntNames /s_myList
SListSortIntField /s_myList %f
SListReverseSortIntField /s_myList %f
x1 2.9999977 Sorts the list according to integer names or field number %f in name=value pairs. The requested names or field must contain only integers. To sort by a field, %f must have the field number (1 or higher). If %f = 0, the names are sorted, if %f = -1 the values are sorted as one large field. And if %f = -2, then the whole string is used to sort the list. %f as -1 or -2 should only be used if the whole value or string is an integer.
DBSortIntNames /s_myList
DBReverseSortIntNames /s_myList
DBSortIntField /s_myList %f
DBReverseSortIntField /s_myList %f
xelagot 3.600

Sorts the list according to integer names or field number %f in name=value pairs. The requested names or field must contain only integers. To sort by a field, %f must have the field number (1 or higher). If %f = 0, the names are sorted, if %f = -1 the values are sorted as one large field. And if %f = -2, then the whole string is used to sort the list. %f as -1 or -2 should only be used if the whole value or string is an integer.
SListSortNumNames /s_myList
SListReverseSortNumNames /s_myList
SListSortNumField /s_myList %f
SListReverseSortNumField /s_myList %f
x1 2.9999977 Sorts the list according to numeric names or field number %f in name=value pairs. The requested names or field must be a number (integer or real), or a date-time value. To sort by a field, %f must have the field number (1 or higher). If %f = 0, the names are sorted, if %f = -1 the values are sorted as one large field. And if %f = -2, then the whole string is used to sort the list. %f as -1 or -2 should only be used if the whole value or string is numerical.
DBSortNumNames /s_myList
DBReverseSortNumNames /s_myList
DBSortNumField /s_myList %f
DBReverseSortNumField /s_myList %f
xelagot 3.600

Sorts the list according to numeric names or field number %f in name=value pairs. The requested names or field must be a number (integer or real), or a date-time value. To sort by a field, %f must have the field number (1 or higher). If %f = 0, the names are sorted, if %f = -1 the values are sorted as one large field. And if %f = -2, then the whole string is used to sort the list. %f as -1 or -2 should only be used if the whole value or string is numerical.
SListShuffle /s_myList shuffles the items in the list in a random fashion.
SayText %a [&p] /s_myList sends the strings in the list to the chat buffer. Person variable &p is optional. See the section on Say for details.
WhisperText %a &p /s_myList sends the strings in the list to the whisper buffer. See the section on Say for details.
Replace /s_myList1 /s_myList2 $c $d
ReplaceInList /s_myList1 /s_myList2 $c $d
Replace is a batch replacement statement, similar to its string counterpart: it clears /s_myList1, copies all strings from /s_myList2 to s_myList1, replacing sub-string $c with string $d. Note that Replace /s_myList /s_myList $c $d is also valid (that is, it will not be cleared, substitutions are done in the list).

X1 2.9999977 ReplaceInList has the same functionality as Replace, but admits string variables containing the names of string lists. It was introduced due to the ambiguity with the string counterpart of Replace.
AttributesList /s_myList dumps world attributes to a string list. See World attributes for details
ChangeAttributes /s_myList changes world attributes. See World attributes for details
SListGetURLParams /s_myList $params (xelagot 3.501) If the string $params contains parameters in the standard POST or GET method, they are set as name=value pairs in the string list (which is first cleared). All names and values are URLDecoded.

 
 

 

String Lists with name=value pairs

Name=value pairs can help store and retrieve data in an easy way. Names are not case sensitive, and should only appear once. They may not contain the equal sign, which is used to separate the name from the value within the string list, and should not contain the comma either. They must not have leading or trailing blanks. Neither names nor values should contain formatting characters, like line feeds and carriage returns (ascii codes below 32 or hex 20). An example of a name=value pair is:
WelcomeMessage=AWBingo is now open!!! Join us for fun and prizes!!! :-)
The name here is WelcomeMessage, the value is AWBingo is now open!!! Join us for fun and prizes!!! :-)

In the following examples, I use $n or %n (integer) for name, and $v for value.

Put (or modify) a name=value pair in a string list:

  1. SListSetValue /s_myList $n $v
  2. SListSetValue /s_myList %n $v
Make sure to give $v a non blank value.

Remove a name=value pair from a list:

  1. SListDeleteName /s_myList $n
  2. SListDeleteName /s_myList %n

List the names as a comma separated string in $a:

  1. SListGetNames /s_myList $a

List the names as an SDF comma separated string in $a (xelagot 3.606):

  1. SListGetNamesSDF /s_myList $a

use GetFirstSDF $n $a repeatedly to recover individual names in $n, until $n has an empty string.

Get the value associated with a name:

  1. IfSListGetValue /s_myList $n $v statement1
    Else statement2
  2. IfSListGetValue /s_myList %n $v statement1
    Else statement2
can be used to test if a string $n is one of the names, for instance, if the name of an avatar, retrieved in a chat event, is one of the names in the list. It is more efficient than using
  1. SListGetValue /s_myList $n $v
  2. SListGetValue /s_myList %n $v
because the outcome of these 2 statements is always true: $v will be empty if $n is not in the list. Note: if the value is an empty string but the name exists, this test will give negative!
You can also retrieve the exact 'spelling' of $n. In this case, test if $a is a name, retrieve it again in $n (with case preservation) and its value in $v
  1. IfSListGetNameValue /s_myList $a $n $v statement1
    Else statement2

For parsing a string, for example string $a, there are a few statements associated with string list names. These can be used, for example, to parse chatlines: the script scans all names in the string list to see if one of them appears in string $a, either as a substring of $a or as a word in $a.

Parsing $a for name as substring of $a: test if any of the names is a substring of $a. If this is the case, $a will be split into 3 parts: $a1 containing the part before the name, $n containing the name as spelled in $a, $a2 contains the rest of $a after the name. $v contains the value associated with $n

  1. IfNameInString /s_myList $a $a1 $n $a2 $v statement1
    Else statement2
  2. IfSListNameInString /s_myList $a $a1 $n $a2 $v statement
    Else statement2

Parsing $a for name as word in $a: test if any of the names is a word of $a. Delimiters for words are: space and .,;:¡!¿?. If this is the case, $a will be split into 3 parts: $a1 containing the part before the name, $n containing the name as spelled in $a, $a2 contains the rest of $a after the name. $v contains the value associated with $n

  1. IfNameWordInString /s_myList $a $a1 $n $a2 $v statement1
    Else statement2
  2. IfSListNameWordInString /s_myList $a $a1 $n $a2 $v statement
    Else statement2

(x1 2.9999977) To sort a list by names:

  1. SListSortNames /s_MyList or
    SListReverseSortNames /s_MyList for string names
  2. SListSortUCNames /s_MyList or
    SListReverseSortUCNames /s_MyList for url encoded names
  3. SListSortIntNames /s_MyList or
    SListReverseSortIntNames /s_MyList for names if they are integers
  4. SListSortNumNames /s_MyList or
    SListReverseSortNumNames /s_MyList for names if they are numbers or date-time
     

(x1 2.9999977) To sort by values, %f must be -1.

  1. SListSortField /s_MyList %f or
    SListReverseSortField /s_MyList %f for string field number %f
  2. SListSortUCField /s_MyList %f or
    SListReverseSortUCField /s_MyList %f for url encoded field number %f
  3. SListSortIntField /s_MyList %f or
    SListReverseSortIntField /s_MyList %f for integer field number %f
  4. SListSortNumField /s_MyList %f or
    SListReverseSortNumField /s_MyList %f for numeric or date-time field number %f


 

String Lists used as database (traditional way)

For a new and better way as from xelagot 3.600, see the next section. The methods described in this section remain valid, but new scripts should use the newer methods for xelagots 3.600 or higher. Databases created with the traditional method described here may be used with the new methods of next section only if fields (i) do not contain URLEncoded strings, (ii) do not contain the characters = or %. To migrate to a new style database, see the comments (first table) on SListGetRecord.

String lists can be used, in a limited way, as storage for database records. This is quite adequate, for example, to store scores in games and competitions. These lists can be made 'permanent' by saving them to file. Each name=value pair in a string list can be used as a database record. The name functions as the indexed field or primary key, other fields are comma separated entries in the value part of the name=value pair. You access each record individually using the name field and the number of another of its fields. Field numbers start by 1. You can access one or more fields in this way. Fields may not contain commas.

Create a record, or modify an existing one, by entering a name ($n or %n) for the name field, and a field number %f (it may be a literal) and a value $a for another of its fields:
  1. SListSetField /s_myList $n %f $a
  2. SListSetField /s_myList %n %f $a
The value of a certain field is not limited to strings like $a, there are certain rules for using integers %i, date-time variables !t, and location family variables @p, &p and ~p. See details in first table on this page.

You can modify more than one field at a time. %c is then the number of the last field to be modified (it may be a literal), 'variables' is a space separated list of variables of the type allowed in fields, starting by field number 1 up to the last field. To avoid modifying a field, just put an 'x' or any characters which are not a variable instead of a variable in the right position in this list.

  1. SListSetFields /s_myList $n %c variables
  2. SListSetFields /s_myList %n %c variables
Example to modify the first and 3rd field of indexed record $n (or create the record if necessary), putting values $d and %i there:
SlistSetFields /s_ListA $n 3 $d x %i

To retrieve values from fields, use SListGetField and SListGetFields:

  1. SListGetField /s_myList $n %f $a
  2. SListGetField /s_myList %n %f $a
  1. SListGetFields /s_myList $n %c variables
  2. SListGetFields /s_myList %n %c variables

A record can be retrieved by index (xelagot 3.600), this is handy to migrate databases to the new style:

  1. SListGetRecord /s_myList %index $name variables
You can test if a record exists by name $n or %n, $v will receive a comma separated list of fields.
  1. IfSListGetValue /s_myList $n $v statement
  2. IfSListGetValue /s_myList %n $v statement

Remove a record:

  1. SListDeleteName /s_myList $n
  2. SListDeleteName /s_myList %n

To totalise a numeric field at position %f, putting the total in %i, use:

  1. SListAddField /s_myList %f %i

To make a comma separated list in $a of all the strings in field number %f, use:

  1. SListAddField /s_myList %f $a
Here, all values in field number %f will be treated as strings.

For a comma separated list of names im $a, use the old

  1. SListGetNames /s_myList $a

(x1 2.9999977) To sort a list by names:

  1. SListSortNames /s_MyList or
    SListReverseSortNames /s_MyList for string names
  2. SListSortUCNames /s_MyList or
    SListReverseSortUCNames /s_MyList for url encoded names
  3. SListSortIntNames /s_MyList or
    SListReverseSortIntNames /s_MyList for names if they are integers
  4. SListSortNumNames /s_MyList or
    SListReverseSortNumNames /s_MyList for names if they are numbers or date-time
     

(x1 2.9999977) To sort by a field, %f must have the field number (0 for names, 1 or higher for fields).

  1. SListSortField /s_MyList %f or
    SListReverseSortField /s_MyList %f for string field number %f
  2. SListSortUCField /s_MyList %f or
    SListReverseSortUCField /s_MyList %f for url encoded field number %f
  3. SListSortIntField /s_MyList %f or
    SListReverseSortIntField /s_MyList %f for integer field number %f
  4. SListSortNumField /s_MyList %f or
    SListReverseSortNumField /s_MyList %f for numeric or date-time field number %f


 

String Lists used as database (xelagot 3.600 and combining with SQL), the recommended way

Requires xelagot 3.600 or higher.

String lists can be used, in a limited way, as storage for database records. This is quite adequate, for example, to store scores in games and competitions. The traditional way is explained in the previous section. Xelagot 3.600 introduces a new way, in apearence very similar to the old way, but that automatically encodes and decodes string-data so as to avoid commas and equal signs; the encoding is done with the % character, so this character is also encoded: % to %1, comma to %2 and = to %3. These lists can be made 'permanent' by saving them to file. Each name=value pair in a string list can be used as a database record. The name functions as the indexed field or primary key, other fields are comma separated entries in the value part of the name=value pair. You access each record individually using the name field and the number of another of its fields. Field numbers start by 1. You can access one or more fields in this way. Fields may now contain commas and equal signs, as these get encoded, but it is better not to include commas in primary key fields (name in the name=value pair).

An enhancement introduced in xelagot 3.600 is the ability to communicate with SQL databases. Records retrieved from these databases are presented to xelagot as string lists, formatted according to this new encoding method, if a correct value is passed to the %KeyField parameter in SQLQuerySelect. For details on SQL connectivity, see Database Connectivity: SQL. NOTE: the name (key field) in the xelagot database is not case sensitive, in SQL databases it may be. Be aware of that when you build up your SQL database!

Databases created with these statements should not be used with the old traditional statements. Databases created with the old traditional statements can migrate to using the new statements described here only if their fields (i) do not contain URLEncoded strings, (ii) do not contain the characters % or =.

Create a record, or modify an existing one, by entering a name ($n or %n) for the name field, and a field number %f (it may be a literal) and a value $a for another of its fields:
  1. DBSetField /s_myList $n %f $a
  2. DBSetField /s_myList %n %f $a
The value of a certain field is not limited to strings like $a, there are certain rules for using integers %i, date-time variables !t, and location family variables @p, &p and ~p. See details in first table on this page.

You can modify more than one field at a time. %c is then the number of the last field to be modified (it may be a literal), 'variables' is a space separated list of variables of the type allowed in fields, starting by field number 1 up to the last field number %c. To avoid modifying a field, just put an 'x' or any characters which are not a variable instead of a variable in the right position in this list.

  1. DBSetFields /s_myList $n %c variables
  2. DBSetFields /s_myList %n %c variables
Example to modify the first and 3rd field of indexed record $n (or create the record if necessary), putting values $d and %i there:
DBSetFields /s_ListA $n 3 $d x %i

To retrieve values from fields, use DBGetField and DBGetFields:

  1. DBGetField /s_myList $n %f $a
  2. DBGetField /s_myList %n %f $a
  1. DBGetFields /s_myList $n %c variables
  2. DBGetFields /s_myList %n %c variables

A record can be retrieved by index (index starts at 1), $n will receive the name, the variables receive the other fields:

  1. DBGetRecord /s_myList %index $n variables

You can test if a record exists by name $n or %n, $v will receive a record, i.e. a comma separated list of DBEncoded fields (as from xelagot 3.600)

  1. IfDBGetValue /s_myList $n $v statement
  2. IfDBGetValue /s_myList %n $v statement

Or you can simply retrieve the record as in previous statement but without the conditional testing (xelagot 3.606)

  1. DBGetValue /s_myList $n $v
  2. DBGetValue /s_myList %n $v

This record $v can be used to retrieve the individual field values (xelagot 3.606)

  1. DBRecodGetField $v %c variable
  2. DBRecodGetFields $v %c variables

similar to DBGetField and DBGetFields, only in this case the information is contained in a string and not a string list.

Remove a record:

  1. DBDeleteName /s_myList $n
  2. DBDeleteName /s_myList %n

To totalise a numeric field at position %f, putting the total in %i, use:

  1. DBAddField /s_myList %f %i

To make a comma separated list in $a of all the strings in field number %f, use:

  1. DBAddField /s_myList %f $a
Here, all values in field number %f will be treated as strings.
Caution: if a string field contains an encoded comma, it shows as comma in this string! If you do not want that, use the old
SListAddField /s_MyList $a
that will give you a comma separated list of DBEncoded items. You can then Split the string at commas, and use DBDecode to decode each item. See string operations.

For a comma separated list of DBDecoded names in $a, you can also use:

  1. DBGetNames /s_myList $a
Caution: if a name field contains an encoded comma, it shows as comma in this string! If you do not want that, use the old
SListGetNames /s_MyList $a
that will give you a comma separated list of DBEncoded names. You can then Split the string at commas, and use DBDecode to decode each item. See string operations.

For a SDF comma separated list of DBDecoded names in $a, you can also use (xelagot 3.606):

  1. DBGetNamesSDF /s_myList $a

use GetFirstSDF $n $a repeatedly to recover individual names in $n, until $n has an empty string.

To load from and save to file (filename $f), use:

  1. DBLoad /s_myList $f [%r]
  2. DBSave /s_myList $f

To clear the database, to copy from database /s_myList2 to /s_myList1 (clearing /s_myList1 first), and to count the records, use:

  1. DBClear /s_myList
  2. DBCopy /s_myList1 /s_myList2
  3. DBCount /s_myList %c

If the database was retrieved from an SQL query and lacks a name field, i.e. is a pure DBEncoded comma separated list (e.g. when %KeyField = -1 in the query), a numeric name value followed by an equal sign can be prepended to each record, starting with 1 and ending with the number of records (xelagot 3.606)

  1. DBRenumber /s_myList

To sort a list by names:

  1. DBSortStringNames /s_MyList or
    DBReverseSortStringNames /s_MyList for names if the are (DBEncoded) strings.
  2. DBSortIntNames /s_MyList or
    DBReverseSortIntNames /s_MyList for names if they are integers
  3. DBSortNumNames /s_MyList or
    DBReverseSortNumNames /s_MyList for names if they are numbers or date-time
     

To sort by a field, %f must have the field number (0 for names, 1 or higher for fields).

  1. DBtSortStringField /s_MyList %f or
    DBReverseSortStringField /s_MyList %f for (DBEncoded) string field number %f.
  2. DBSortIntField /s_MyList %f or
    DBReverseSortIntField /s_MyList %f for integer field number %f
  3. DBSortNumField /s_MyList %f or
    DBReverseSortNumField /s_MyList %f for numeric or date-time field number %f


backIndex