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.
Allow interpolation inside quote block
-
highend
- Posts: 14996
- Joined: 06 Feb 2011 00:33
- Location: Win Server 2022 @100%
Re: Allow interpolation inside quote block
Variables aren't resolved in single quotes
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:
Code: Select all
$a = get("curitem","path"); run """d:\ConEmuPack\ConEmu64.exe"" /dir ""$a""";
And if you don't really need:
this would be enough: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.
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
Thanks highend.
Is there a trick to understand this neverending number of double-quotes? They are very confusing!
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
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
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
As an alternative you can use the quote() function:
Code: Select all
run quote("d:\ConEmuPack\ConEmu64.exe") . " /dir " . quote(<curpath>);FAQ | XY News RSS | XY X
XYplorer Beta Club