Page 1 of 1
Couple basic questions about scripting
Posted: 07 Dec 2014 21:21
by mydarkpassenger
I've been playing around with scripting for a bit but I was wondering a few things:
1) is there a way to pass variables to functions or return data or does everything need to be done as global?
2) Is it possible to keep more than one script in a file pass and call it without having to choose the starting point? For example, maybe adding a function in a script to a keyboard shortcut so I don't have to choose what starting point I want when I pass the script a value.
Re: Couple basic questions about scripting
Posted: 07 Dec 2014 21:48
by PeterH
To 1)
XY doesn't (yet?) allow passing arguments to scripts, or to return a value. So you must use globals.
I'm really waiting for this - would make scripting much much easier, and very much more "elegant".
Re: Couple basic questions about scripting
Posted: 07 Dec 2014 22:42
by mydarkpassenger
Thanks for the answers. You wouldn't happen to know if it's possible to use something like python to work with scripts would you?
Re: Couple basic questions about scripting
Posted: 07 Dec 2014 23:28
by mydarkpassenger
Sorry a couple other questions:
1) Is there a way to pull the first item from a list without having to loop through the results?
2) Is there a way to search for an item in a list without looping through the results? I can search the string but it doesn't seem very elegant.
Re: Couple basic questions about scripting
Posted: 08 Dec 2014 01:09
by klownboy
It shouldn't be a problem for question 1 or 2. Take a look at Help | Help on Scripting Commands. It will take you to the "Scripting Commands Reference". Look up "gettoken" as well as "gettokenindex". Each SC has examples. If you have any problems, please post an example.
Code: Select all
gettokenindex()
Returns the first index of a token in a token list, or the count of its occurrences
Syntax
gettokenindex(token, tokenlist, [separator=|], [flags=iw]);
gettoken()
Returns a substring by index.
Syntax
gettoken(string, [index=1], [separator=" "], [format], [flags])
Re: Couple basic questions about scripting
Posted: 10 Dec 2014 01:50
by mydarkpassenger
Thank you that was a big help!