Allow interpolation inside quote block

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
rhaguiuda
Posts: 5
Joined: 28 Aug 2015 15:32

Allow interpolation inside quote block

Post by rhaguiuda »

How can I allow a variable interpolation inside a quote block?

In this script:

$a = get("curitem","path");run 'd:\ConEmuPack\ConEmu64.exe /dir $a';

I need that variable $a gets interpolated even inside the quotes of the run command.

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

Re: Allow interpolation inside quote block

Post by highend »

Variables aren't resolved in single quotes

Code: Select all

$a = get("curitem","path"); run """d:\ConEmuPack\ConEmu64.exe"" /dir ""$a""";
This version will put $a in quotes as well (so that it works for folders with spaces in it)

And if you don't really need:
Note: get(curitem) differs from the native variable <curitem> in that it will return the previously selected and focused item if the currently focused item is not selected.
this would be enough:

Code: Select all

run """d:\ConEmuPack\ConEmu64.exe"" /dir ""<curpath>""";
One of my scripts helped you out? Please donate via Paypal

rhaguiuda
Posts: 5
Joined: 28 Aug 2015 15:32

Re: Allow interpolation inside quote block

Post by rhaguiuda »

Thanks highend.

Is there a trick to understand this neverending number of double-quotes? They are very confusing!

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

Re: Allow interpolation inside quote block

Post by highend »

For each pair of two double quotes the outer one is stripped.
1. run """d:\ConEmuPack\ConEmu64.exe"" /dir ""$a"""
2. run ""d:\ConEmuPack\ConEmu64.exe"" /dir ""$a""
3. run "d:\ConEmuPack\ConEmu64.exe" /dir "$a"

Always a good method to understand double quotes:
Use
step;
in a script before such a line

The stepping window will show you how XY interprets all these double / tripple quotes
One of my scripts helped you out? Please donate via Paypal

admin
Site Admin
Posts: 66672
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Allow interpolation inside quote block

Post by admin »

As an alternative you can use the quote() function:

Code: Select all

run quote("d:\ConEmuPack\ConEmu64.exe") . " /dir " . quote(<curpath>);

Post Reply