Loading a new ini file into the existing XYplorer

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
klownboy
Posts: 4468
Joined: 28 Feb 2012 19:27
Location: Windows 11, 25H2 Build 26200.8737 at 100% 2560x1440

Re: Loading a new ini file into the existing XYplorer

Post by klownboy »

highend wrote:For what would you need a heredoc?
You are a funny man, highend. It's because I was struggling with the quoting without the heredoc. It turns out, it was easier (for you anyway) than I thought. Possibly moving the "/NH" switch to the end helped. I was looking for the situations when there were more than 1 instance of XYplorer that's why I had only ">" and not ">=".

I wasn't using SC text in the script though. I used SC gettokenindex to get a count of "XYplorer.exe* as opposed to using gettoken.
Thanks again.
Last edited by klownboy on 06 Feb 2016 22:31, edited 1 time in total.

highend
Posts: 14994
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Loading a new ini file into the existing XYplorer

Post by highend »

You are a funny man, highend
Uh, am I? :D

Same rule as always (or at least: 95% of all cases: double quotes to get single quotes (because the outer quotes are stripped)) :biggrin:
I think what confused you is that we don't need the initial """<command>"" starting sequence?
I was looking for the situations when there were more than 1 instance of XYplorer that's why I had only ">" and not ">="
That's why I edited my post. There can be cornercases where > 1 doesn't necessarily mean: really more than a "real" (with a gui) instance of XY
One of my scripts helped you out? Please donate via Paypal

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

Re: Loading a new ini file into the existing XYplorer

Post by PeterH »

Hm - to "quoting" :arrow:
You have to double quotes of the type the string is quoted with.
You use double-quotes - so you have to double contained double-quotes.
The string doesn't contain any XY variable - so you could use single-quotes:
instead of

Code: Select all

if(gettokenindex("XYplorer.exe*",runret(<<<HEREDOC
"cmd" /c "tasklist /nh /FI "Imagename eq XYplorer.exe""
HEREDOC
or

Code: Select all

if(gettokenindex("XYplorer.exe*",runret("""cmd"" /c ""tasklist /nh /FI ""Imagename eq XYplorer.exe"""""
use

Code: Select all

if(gettokenindex("XYplorer.exe*",runret('"cmd" /c "tasklist /nh /FI "Imagename eq XYplorer.exe""'
I hope I didn't count anything wrong :biggrin: )

You remember: variables are substituted inside double quoted strings, while their name is used as written inside single quotes. As long as a string doesn't contain variables it makes no difference :ugeek:

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

Re: Loading a new ini file into the existing XYplorer

Post by klownboy »

highend wrote:There can be cornercases where > 1 doesn't necessarily mean: really more than a "real" (with a gui) instance of XY
TaskManager seems to return a "(2)" after listing XYplorer and shows Help, FP or other child windows in a sub column, when child windows of XY exists, but Tasklist in a command box seems to only show full GUI instances of XYplorer at least in my quick tests. I did change the comparsion to be ">= 2". Yes, as far as the runret and using CMD, in most attempts I was double quoting "cmd" which as it turns out was not required in this case, but as PeterH's post shows...

PeterH, I ran your suggested line (the first in the code box) and it worked fine, as did highend's (the second line)

Code: Select all

 if(gettokenindex("XYplorer.exe*",runret('"cmd" /c "tasklist /nh /FI "Imagename eq XYplorer.exe""'),"<crlf>", "wc") >= 2) {
 if(gettokenindex("XYplorer.exe*",runret("cmd /c tasklist /FI ""Imagename eq XYplorer.exe"" /NH"), "<crlf>", "wc") >= 2) {
I was also able to get the other alternative below to work, which was very close to what I was attempting earlier...

Code: Select all

if(gettokenindex("XYplorer.exe*",runret("""cmd"" /c ""tasklist /nh /FI ""Imagename eq XYplorer.exe"""""),"<crlf>", "wc") >= 2) {
So, all 3 of the above work... and I hadn't stumbed on any of them other than the heredoc. Thanks guys.

Post Reply