Some usefull array functions
Posted: 24 Oct 2009, 12:16
Thanks to Svengali for giving me a clue on how to parse out values using Parse I came up with a bunch of utillity functions today for working with arrays in george.
Drop the attached file in your george folder and include it at the end of your scripts with:
#Include kc-arrayfunctions.grg
Here's some examples of what can be done.
Have fun
Drop the attached file in your george folder and include it at the end of your scripts with:
#Include kc-arrayfunctions.grg
Here's some examples of what can be done.
Code: Select all
tv_getactivetool
//Parse the result variable into array "ParsedArray"
ParseArray(Result)
//After calling "ParseArray" you now have a global array Called "ParsedArray" that you can work with containing
//each space delimited word/value
//Lookup the "step" value in the array
Print "Step: " ArrayLookup("step",1)
//Lookup the second "handle" value in the array using the offset
Print "handle second parameter: " ArrayLookup("handle",2)
//Create string from the array, notice value of second handle parameter.
print StringFromArray()
//Now look for handle in the array and replace the second parameter to 555 just so we can see that it works. (Don't do that in a real script)
ReplaceArrayIndex("handle","555",2)
//Print out again, notice handle second value is now 555
print StringFromArray()
//Print out number of indexes in array. Usefull for creating your own loops through "ParsedArray"
Print ParseArrayLength()
//Reset array
ResetTheArray()
//Print out number of indexes, array is reset so we get zero.
Print ParseArrayLength()
#Include kc-arrayfunctions.grg