Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
cadu
Posts: 287
Joined: 18 Mar 2012 21:50

Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by cadu »

Hi,

I'd appreciate your help.

What would be the script syntax for the following conditional (IF):

If there is any item/folder selected in the list pane, then run:

Code: Select all

run """<xypath>\_Everything\Everything.exe"" -filename ""<curitem>""";
If there ISN'T item/folder selected, instead of the command above, run:

Code: Select all

run """<xypath>\_Everything\Everything.exe"" -filelist ""<curpath>""";
Thanks a lot or your assistance!
Carlos

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by highend »

Code: Select all

    if (<curitem>) {

    } else {

    }
One of my scripts helped you out? Please donate via Paypal

cadu
Posts: 287
Joined: 18 Mar 2012 21:50

Re: Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by cadu »

Thank you very much @highend! I always learn a lot from you.

For documentation purposes, this is my script using IF:

Code: Select all

    if (<curitem>) {run """<xypath>\_Everything\Everything.exe"" -filename ""<curitem>""" -d ""<curitem>"""

    } else {run """<xypath>\_Everything\Everything.exe"" -filelist ""<curpath>""" -d ""<curpath>"""

    }
EDITED following @highend further feedback: remember adding indentation for each line, otherwise, XYplorer will pop-up a menu for choosing which IF clause to run.

Cheers,
Carlos
Last edited by cadu on 15 May 2019 17:38, edited 2 times in total.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by highend »

You didn't indent the lines properly if that's happening
One of my scripts helped you out? Please donate via Paypal

cadu
Posts: 287
Joined: 18 Mar 2012 21:50

Re: Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by cadu »

highend wrote: 15 May 2019 17:24 You didn't indent the lines properly if that's happening
Thanks for further feedback. The former post was already updated.
By the way, from XYplorer script editor, is there any other way to add indentation besides "space"?
For instance, I tried the "tab" key, but there is no effect.

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by highend »

No but seriously, nobody uses that editor to _develop_ scripts.

Use a proper text editor with syntax highlighting...
One of my scripts helped you out? Please donate via Paypal

cadu
Posts: 287
Joined: 18 Mar 2012 21:50

Re: Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by cadu »

highend wrote: 15 May 2019 17:44 Use a proper text editor with syntax highlighting...
It seems I need to evolve!
Would you mind sharing the name of your favorite text editor?

highend
Posts: 13274
Joined: 06 Feb 2011 00:33

Re: Script syntax with conditional (IF) to run command considering there is (or not) selected items in list pane

Post by highend »

Sublime Text
One of my scripts helped you out? Please donate via Paypal

Post Reply