* Graham  
Xtscript does not have an array function but here is how to "fake" a simple array
first the function script



Define the array
var $arr= banana|apple|orange|grape|lemon|mango
If you change the separator used in the array set $sep=new separator in your array function calls
Or to change it permanently change the default for $sep in the function script

To read a element in the array (read is the default mode so it can be omitted )
var $value = call array $d=$arr;$n=4;$m=read
Returns the 4th element (starting from 0) which is "lemon"

To replace an element in the array
var $arr=call array $d=$arr;$n=4;$nv=melon;$m=replace
Array is now "banana|apple|orange|grape|melon|mango"

To insert an element into the array
var $arr=call array $d=$arr;$n=4;$nv=rhubarb;$m=insert
Array is now "banana|apple|orange|grape|rhubarb|melon|mango "

To delete an element from the array
var $arr=call array $d=$arr;$n=4;$m=delete
Array is now "banana|apple|orange|grape|melon|mango"

To search for a value in the array and return the elements position
$sv is the value to search for
$fl is first or last occurrence default is first ( can be omitted )
var $value = call array $d=$arr;$sv=melon;$fl=first;$m=search
Returns "4" for "melon"
Returns "-1" if the value is not found

To count the elements in an array
var $value = call array $d=$arr;$m=count
Returns "5" (remember the first element is 0)
Note: Out of range values for $n will also return the element count
2014-02-24 10:01 (edited 2014-02-28 20:03 by Graham ) · (1)

Online: Guests: 1