Page 1 of 1

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

Posted: 15 May 2019 15:54
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

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

Posted: 15 May 2019 16:17
by highend

Code: Select all

    if (<curitem>) {

    } else {

    }

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

Posted: 15 May 2019 17:16
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

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

Posted: 15 May 2019 17:24
by highend
You didn't indent the lines properly if that's happening

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

Posted: 15 May 2019 17:41
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.

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

Posted: 15 May 2019 17:44
by highend
No but seriously, nobody uses that editor to _develop_ scripts.

Use a proper text editor with syntax highlighting...

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

Posted: 15 May 2019 19:04
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?

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

Posted: 15 May 2019 19:15
by highend
Sublime Text