Couple basic questions about scripting

Discuss and share scripts and script files...
Post Reply
mydarkpassenger
Posts: 31
Joined: 19 Apr 2014 19:39

Couple basic questions about scripting

Post 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.

PeterH
Posts: 2827
Joined: 21 Nov 2005 20:39
Location: DE W11Pro 24H2, 1920*1200*100% 3840*2160*150%

Re: Couple basic questions about scripting

Post 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".

mydarkpassenger
Posts: 31
Joined: 19 Apr 2014 19:39

Re: Couple basic questions about scripting

Post 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?

mydarkpassenger
Posts: 31
Joined: 19 Apr 2014 19:39

Re: Couple basic questions about scripting

Post 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.

klownboy
Posts: 4459
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8037 at 100% 2560x1440

Re: Couple basic questions about scripting

Post 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])

mydarkpassenger
Posts: 31
Joined: 19 Apr 2014 19:39

Re: Couple basic questions about scripting

Post by mydarkpassenger »

Thank you that was a big help!

Post Reply