Page 1 of 1

Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 17:45
by Jeff Bellune
Allow Multiple Instances is unchecked in Configuration Settings.

The script:

Code: Select all

run ""<xy>" /new";
does not open a new instance of XY. Instead, it opens Windows Explorer. Same result whether XY is set as the default file manager or not.

Bug or Operator Error?

Thanks,
Jeff

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 17:49
by klownboy
Instead use...it works.

Code: Select all

run """<xy>"" /new";

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 17:50
by Jeff Bellune
Thanks.

From the Help file:
Names with blanks must be quoted. Note that the quotes have to be wrapped in single-quotes double-quotes because an argument's outer quotes are auto-stripped by XY's script parser!
I guess this applies to each argument in the expression, not just the whole expression. Hopefully I'll remember this for next time. :)

Cheers,
Jeff

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 19:35
by klownboy
Hi Jeff, many here get around the quoting "fun" by setting up the command in a variable and by doing something like this...which will work in the Address Bar.

Code: Select all

::$xy = "<xy> /new"; run $xy;

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 19:56
by Jeff Bellune
Nice tip, thanks! I ended up putting it in an "Open" UDC:

Code: Select all

"<xy>" /new
If I use it enough, I'll probably make a toolbar button out of it. Then I can use your code.

Cheers,
Jeff

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 20:00
by PeterH
klownboy wrote:Hi Jeff, many here get around the quoting "fun" by setting up the command in a variable and by doing something like this...which will work in the Address Bar.

Code: Select all

::$xy = "<xy> /new"; run $xy;
Sorry: this isn't the same :roll:

<xy> is path and name of XY executable. It *may* contain blank characters.
Assume: path is c:\p f\xy\xyplorer.exe
the run cmd will give as argument: c:\p f\xy\xyplorer.exe /new
The first token is the executrable, it is: c:\p :?
The rest are 2 arguments :veryconfused:
So that the 1st argument is the correct path it must be wrapped in double quotes: "<xy>"
This must be expressed as a string, i.e. wrapped in quotes - *double* quotes, as a variable <xy> must be resolved. But: double quotes inside double quotes must be doubled :shock: so:
"""<xy>"" /fresh"
This may be assigned to a variable, or be directly given with run.

As long as you are 100% sure that <xy> doesn't contain blanks, and never will, you can drop the inner, doubled double quotes as you did. But if you show it to someone else this may be incorrect for him!

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 20:05
by klownboy
I see what you're saying, but I though Don just made a change (within the past couple of weeks) in XY's built in variables not requiring them to be quoted at all (see v14.30.0301 notes).

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 20:30
by PeterH
klownboy wrote:I see what you're saying, but I though Don just made a change (within the past couple of weeks) in XY's built in variables not requiring them to be quoted at all (see v14.30.0301 notes).
I think it's right: <xy> must not be quoted.
But what about /fresh?
(You see: I didn't specify it as a string, and so you don't know what I mean! I mean " /fresh" - note the blank inside the quote, but no trailing "?"!!)
So you could write
$xy = <xy> . "/new"; run $xy;
BUT: <xy> may not contain blank(s) here! Solution:
$xy = """" . <xy> . """ /new"; run $xy;

OK, to be serious: we talk about different things. Exact: <xy> may be unquoted, but Run cmd needs the path (i.e. <xy>) quoted.
<xy> or "<xy>" is the path, and now quote it: """".<xy>."""" or """<xy>"""
(Result of both is like "c:\path\path\xyplorer.exe")

I hope this explains it a bit more...

Re: Can't Open New Instance Of XY With Script

Posted: 28 Aug 2014 22:43
by klownboy
Thanks PeterH, I saved this post in my "Fun with XY Quoting" Favorites folder. :) I do typically double quote in scripts even when it's an assigned variable as an example,

Code: Select all

  $g_IrfanPath="d:\graphics\irfanView\i_view32.exe";
  run """$g_IrfanPath"" $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
but I had tested what I had posted earlier, it worked and never thought about spaces (obviously I don't have spaces in my XY command line). Now maybe the above isn't totally correct either but it has worked for me for last couple of years.
Thanks again,
Ken

Re: Can't Open New Instance Of XY With Script

Posted: 29 Aug 2014 00:11
by PeterH
klownboy wrote:Thanks PeterH, I saved this post in my "Fun with XY Quoting" Favorites folder. :) I do typically double quote in scripts even when it's an assigned variable as an example,

Code: Select all

  $g_IrfanPath="d:\graphics\irfanView\i_view32.exe";
  run """$g_IrfanPath"" $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
but I had tested what I had posted earlier, it worked and never thought about spaces (obviously I don't have spaces in my XY command line). Now maybe the above isn't totally correct either but it has worked for me for last couple of years.
Thanks again,
Ken
I think your wording doesn't exactly fit the statements :mrgreen:
In both lines you use text-strings, containing characters as c: or /aspectratio - and these must be quoted. That is: quotes are needed!
Next you use the ability of XY, that variables inside double quotes are resolved. So it generally isn't necessary to take the variables outside the quotes and use concatenation. So I'd say: the variables are not explicitely quoted - they are just inside quotes.
And there is one (solved) problem: a variable inside double quotes must be recognized. That's easy if it's name is followed by a blank or another character that is not allowed in variable names. But the variable $base is followed by an underscore - if it would be inside the double quotes it would be trated as $base_ :arrow: you correctly have pulled these apart by concatenation.

And the very last to say (I think) is to the doubled quotes in run """$g_IrfanPath"" ... These are not for XY, but for the run command, to possibly recognize the file, though it's name might contain blanks. You could have changed that as

Code: Select all

  $g_IrfanPath="""d:\graphics\irfanView\i_view32.exe""";
  run "$g_IrfanPath $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
the result would exactly be the same. This shows: the doubled double quote leads to a double quote in the resultant string. And as the 1st statement contains no variable:

Code: Select all

  $g_IrfanPath='"d:\graphics\irfanView\i_view32.exe"';
  run "$g_IrfanPath $file /aspectratio /jpgq=100 /crop=($x_crop, $y_crop, $width, $height) /convert=$path\". $base ."_$xy.$ext", , 2,0;
the same again, i.e. double quotes inside single quotes are not doubled :D

Re: Can't Open New Instance Of XY With Script

Posted: 29 Aug 2014 14:05
by klownboy
Hi again PeterH, it was nearly 2 years ago that I posted an "early" version of my script PhotoCropper You probably don't remember but if you scan down to the bottom of the post I noted you helped me through some issues probably in other threads. Note that the run command line is identical to what I posted above. You probably wouldn't believe how many iterations of that run line, and another I used with ImageMagick instead of Irfanview, I tried before I got them working. I did substitute your line above and it did work as you said it would.
Once again thanks for your help,
Ken

Re: Can't Open New Instance Of XY With Script

Posted: 29 Aug 2014 14:16
by Jeff Bellune
klownboy wrote:You probably wouldn't believe how many iterations of that run line, and another I used
I'd sure believe it. I went through dozens of iterations recently trying to get a script-generated.m3u playlist to open in Mp3tag. I just kept adding quotes around everything until I got it right. 8)

Cheers,
Jeff