User defined variables
-
mkolaski
- Posts: 33
- Joined: 16 Jul 2013 20:16
- Location: UK
User defined variables
Does XYplorer offer a facility to set up user defined variables?
For instance, in FARR, I can define a directory path as a user defined variable:
This can then be used to set up an alias:
I can then just copy my config file to another PC and change the main directory path where all my portable apps are kept on that PC.
If it's not available, I think it would be a useful addition as, if XYplorer is used on different machines, it's likely to be installed in different drive or directory locations and this would mean that, rather than using hard-coded or relative paths to external apps (which are likely to be different on each machine), they could all be set in one place making script/UDC/catlog maintenance much easier when using multiple machines.
Cheers,
Michael
For instance, in FARR, I can define a directory path as a user defined variable:
This can then be used to set up an alias:
I can then just copy my config file to another PC and change the main directory path where all my portable apps are kept on that PC.
If it's not available, I think it would be a useful addition as, if XYplorer is used on different machines, it's likely to be installed in different drive or directory locations and this would mean that, rather than using hard-coded or relative paths to external apps (which are likely to be different on each machine), they could all be set in one place making script/UDC/catlog maintenance much easier when using multiple machines.
Cheers,
Michael
To see the attached files, you need to log into the forum.
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: User defined variables
There are Native Variables such as <xypath> which is the folder where XYplorer.exe resides.
Using these, you can locate other file/folders in a relative location (eg, <xypath>\..\parent). Also, ?:\ equals the drive where XY lives.
Enter the underlined code in the addressbar for a list of such variables (not all are path-related!): ::help "idh_variables.htm";
In the scripting context, in addition to natives, there are also permanent variables (perm $APermanentVariable = "some value";) and are available to all scripts.
But permanent variables cannot be used anywhere outside of scripting, for say, defining ctb icons, catalog entries, (non-scripted) file associations etc, and native variables cannot be arbitrarily user-generated.
(unless they're declared in the XYplorer command argument and retrieved with <get CmdLine [index]>, which is a clunky method at best, with numerous disadvantages.)
That said, there is one thing: Aliases, that could come handy but is sadly often ignored. [del]
==Intermission==
Aliases are a revolutionary feature! It demands some love!
==Intermission==
Aliases are supposed to be a shorthand of sorts for locations, so it sounds logical that they be useable alongside and everywhere as native variables.
Using these, you can locate other file/folders in a relative location (eg, <xypath>\..\parent). Also, ?:\ equals the drive where XY lives.
Enter the underlined code in the addressbar for a list of such variables (not all are path-related!): ::help "idh_variables.htm";
In the scripting context, in addition to natives, there are also permanent variables (perm $APermanentVariable = "some value";) and are available to all scripts.
But permanent variables cannot be used anywhere outside of scripting, for say, defining ctb icons, catalog entries, (non-scripted) file associations etc, and native variables cannot be arbitrarily user-generated.
(unless they're declared in the XYplorer command argument and retrieved with <get CmdLine [index]>, which is a clunky method at best, with numerous disadvantages.)
That said, there is one thing: Aliases, that could come handy but is sadly often ignored. [del]
==Intermission==
Aliases are a revolutionary feature! It demands some love!
==Intermission==
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: User defined variables
[Wow, this was a reveal-ation!]
You can actually use aliases everywhere, using <get alias aliasname>!
@st=<xypath>\..\SublimeText\sublime_text.exe
CFI: ini><get alias st>
PFA: ini><get alias st>
=======
edit:
So to answer your question: yes XYplorer has superb support for user-defined variables.
Enter the following in the addressbar to setup an alias called myVar:
Now you can directly enter @PortableAppsDirectory in the addressbar to go there.
And this string can be re-used almost anywhere native variables are allowed in the form of <get alias PortableAppsDirectory>.
[Note: use <get alias PortableAppsDirectory>\XYplorer\ as a way to navigate to locations relative to the assigned location]
Although this is not still allowed in ctb icons, captions of tab, catalogs,ctbs etc.
I recommend you read what the manual has to say about aliases: ::help "idh_addressbar.htm#idh_alias";
You can actually use aliases everywhere, using <get alias aliasname>!
@st=<xypath>\..\SublimeText\sublime_text.exe
CFI: ini><get alias st>
PFA: ini><get alias st>
=======
edit:
So to answer your question: yes XYplorer has superb support for user-defined variables.
Enter the following in the addressbar to setup an alias called myVar:
Code: Select all
@PortableAppsDirectory=D:\Dropbox\AppsAnd this string can be re-used almost anywhere native variables are allowed in the form of <get alias PortableAppsDirectory>.
[Note: use <get alias PortableAppsDirectory>\XYplorer\ as a way to navigate to locations relative to the assigned location]
Although this is not still allowed in ctb icons, captions of tab, catalogs,ctbs etc.
I recommend you read what the manual has to say about aliases: ::help "idh_addressbar.htm#idh_alias";
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
Stef123
Re: User defined variables
A heavy user of aliases I've been wanting to ask this for a long time: Do I pay a performance penalty for piling up tons of aliases in my PFAs and favorite F&F and other CTBs? Because XY has to resolve the alias first, then take it from there, to build up the remaining path components.
I can't really test it, this would mean I'd have to replace a lot of paths.
Could it mean XY takes longer to launch because it first gathers all my aliases on start-up?
I can't really test it, this would mean I'd have to replace a lot of paths.
Could it mean XY takes longer to launch because it first gathers all my aliases on start-up?
-
admin
- Site Admin
- Posts: 66294
- Joined: 22 May 2004 16:48
- Location: Win8.1, Win10, Win11, all @100%
- Contact:
-
mkolaski
- Posts: 33
- Joined: 16 Jul 2013 20:16
- Location: UK
Re: User defined variables
Thanks for your help, Sammay, that's perfect.
I spent some time reading the help manual when I first started using XYplorer and have been using some of the native variables and I remember reading about aliases and thinking they were just a quick way to navigate to folder locations (and I can either use the catalog or FARR for this) so I sort of dismissed them, but they're just what I want (being clearer than relative paths and meaning that I only have to change one item if I install XY on a new machine) as I can either use them in scripts when defining paths to external apps as well as in catalog items. I have one set up to open FileLocator Pro to search the folder location in the active pane and it works perfectly when using this:
Thanks again.
Cheers,
Michael
I spent some time reading the help manual when I first started using XYplorer and have been using some of the native variables and I remember reading about aliases and thinking they were just a quick way to navigate to folder locations (and I can either use the catalog or FARR for this) so I sort of dismissed them, but they're just what I want (being clearer than relative paths and meaning that I only have to change one item if I install XY on a new machine) as I can either use them in scripts when defining paths to external apps as well as in catalog items. I have one set up to open FileLocator Pro to search the folder location in the active pane and it works perfectly when using this:
Code: Select all
"<get alias PortableAppsDirectory>\FileLocator Pro\FileLocatorPro.exe" -d "<curpath>"Cheers,
Michael
-
binocular222
- Posts: 1423
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
Re: User defined variables
This example almost convince me that alias is worth using. However, alias does not resolve variable turn me off, such as:SammaySarkar wrote:You can actually use aliases everywhere, using <get alias aliasname>!
@st=<xypath>\..\SublimeText\sublime_text.exe
CFI: ini><get alias st>
PFA: ini><get alias st>
@nircmd=<xyscripts>\nircmd\x%osbitness%\nircmd.exe
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: User defined variables
binocular222 wrote:@nircmd=<xyscripts>\nircmd\x%osbitness%\nircmd.exe
it seems to works all right here?
normally these goto and select the target exe.
Code: Select all
@test=<xypath>\..\Notepad2x%osbitness%\notepad2.exe
@nircmd=<xyscripts>\nircmd\x%osbitness%\nircmd.exeCode: Select all
txt><get alias test>
dat><get alias nircmd>Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: User defined variables
Oh, they're not resolved in PFAs... Don?
Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
binocular222
- Posts: 1423
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
Re: User defined variables
Not resolved in scripting too (the most painful to me):
@nircmd=<xyscripts>\nircmd\x%osbitness%\nircmd.exe
::echo get("alias", "nircmd")
I think variables inside alias should be resolved everywhere so that alias can be a "pool of paths" that can be resued by PFA, CFI, SC,...
@nircmd=<xyscripts>\nircmd\x%osbitness%\nircmd.exe
::echo get("alias", "nircmd")
I think variables inside alias should be resolved everywhere so that alias can be a "pool of paths" that can be resued by PFA, CFI, SC,...
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
-
TheQwerty
- Posts: 4373
- Joined: 03 Aug 2007 22:30
Re: User defined variables
This can be solved by using the reprocess flag of the set SC:binocular222 wrote:Not resolved in scripting too (the most painful to me):
@nircmd=<xyscripts>\nircmd\x%osbitness%\nircmd.exe
::echo get("alias", "nircmd")
Code: Select all
set $aliasValue, get('alias', 'nircmd'), 'r';
echo $aliasValue;Part of the problem with having XY always resolve them everywhere is that the value can actually be a script and it might not be desirable then.
Code: Select all
@exeModifiedDate=::sel '[*.exe]', 1, 1;echo "<datem yyyy-mm-dd>";My thoughts are that the Alias info value for the get SC should make use of param2 to specify whether or not the alias value should be resolved/reprocessed. Thus your original example could be:
Code: Select all
// Given: @nircmd=<xyscripts>\nircmd\x%osbitness%\nircmd.exe
::echo get("alias", "nircmd", 'r')
// or
:: echo <get alias nircmd r>;-
binocular222
- Posts: 1423
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
Re: User defined variables
I might missed something, but how to set alias via scripting?
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
-
bdeshi
- Posts: 4256
- Joined: 12 Mar 2014 17:27
- Location: Asteroid B-612
- Contact:
Re: User defined variables
Code: Select all
goto "@echo=::echo <@1>;";
goto "@echo2=""::echo <@1>;""";
goto '@echo3=::echo "<xypath>";';
Code: Select all
@echo Hello!
@echo2 Hello!
@echo3Icon Names | Onyx | Undocumented Commands | xypcre
[ this user is asleep ]
[ this user is asleep ]
-
binocular222
- Posts: 1423
- Joined: 04 Nov 2008 05:35
- Location: Win11, Win10, 100% Scaling
Re: User defined variables
you do have lots of dirty tricks!
I'm a casual coder using AHK language. All of my xys scripts:
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
http://www.xyplorer.com/xyfc/viewtopic. ... 243#p82488
XYplorer Beta Club