Page 2 of 2

Re: Loading a new ini file into the existing XYplorer

Posted: 06 Feb 2016 22:22
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.

Re: Loading a new ini file into the existing XYplorer

Posted: 06 Feb 2016 22:29
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

Re: Loading a new ini file into the existing XYplorer

Posted: 06 Feb 2016 22:53
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:

Re: Loading a new ini file into the existing XYplorer

Posted: 06 Feb 2016 23:37
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.