Page 1 of 2

Allow user defined global variables

Posted: 16 May 2022 22:04
by highend
I'd really like to be able to define global variables that can be used anywhere in XY

Very much like 1.) aliases or 2.) a definition like perm $P_<some var name>; but without the need to use a perm (and therefore a script) in the place where this would be used

It should have a specific format like: <glob_{name of your global variable}>, e.g.:
<glob_uk_nuc_01>

And the same rules as they are valid for scripting variables could be used (without a leading $ ofc)

and in the definition for it its defined as: uk_nuc_01=192.168.0.5
So XY would put them together into its specific global variable name...

And now I could use it in the catalog (or anywhere else, CFA, scripting, etc.) e.g. for a location like:
\\<glob_uk_nuc_01>\dlna\movies

Re: Allow user defined global variables

Posted: 16 May 2022 23:22
by WirlyWirly
+1

I posted pretty much the same thing just last month: viewtopic.php?f=5&t=24532

Re: Allow user defined global variables

Posted: 16 May 2022 23:41
by klownboy
+1 also

Where are we defining these new global variables, if not in scripts (or at least as you say, it doesn't have to be a script)? In a new menu item or list "Global variables" like the "Permanent variables" on the Scripting menu?

uk_nuc ? Is that from last week's news? :shock:

Re: Allow user defined global variables

Posted: 16 May 2022 23:43
by highend
In: Menu - Tools - List Management - Global Variables
Is that from last week's news?
No, it's the netbios name of my local linux server :titter:

Re: Allow user defined global variables

Posted: 17 May 2022 01:04
by WirlyWirly
I'd like to add that being able to set variables from the output of scripts would be very useful.

Lets say I want a variable for my current IP address, a global variable definition might look something like this...

Code: Select all

uk_nuc=::load "<xyscripts>\get_external_ip.xys"
Or the quick-scripting equivalent of whatever that file might contain

Re: Allow user defined global variables

Posted: 17 May 2022 08:40
by highend
I guess this would be a different approach (being able to define them via scripting).

But a valid one as well...

In that case they would be manageable via: Scripting - (Super?) Global Variables

and they could be created e.g. via
setglobal {some prefix to identify them as global}{var_name}; / unsetglobal <{global var}>;

And then we'd only need one additional custom event action: On startup

The initial script could be used with that and you are free to change / create / delete them whenever / wherever you like (via scripting)

Re: Allow user defined global variables

Posted: 18 May 2022 14:54
by eil
I like the idea of using @alias as global variable, but reading the full description, i don't see any difference from permanent variables(only the syntax). Maybe it's better to improve PV, than create kinda twin..?(like say give PV own file, making .ini clearer)

Re: Allow user defined global variables

Posted: 19 May 2022 00:08
by highend
Both won't work. @ and $ can be part of paths and it's impossible to know if an alias / perm is part of it or stands for something completely different.

The var needs to be enclosed into something that avoids any ambiguity...

A simple example:
Alias: 1 = VSCode

Code: Select all

$menu = "@1|_first_entry_|D:\icons\@1.ico";
My icon is really D:\icons\@1.ico...
The caption would be fine, my icon not^^

Re: Allow user defined global variables

Posted: 19 May 2022 17:10
by admin
What about giving access to permanent variables via a new variable type <perm [permanent_variable_name]>?

Re: Allow user defined global variables

Posted: 19 May 2022 17:14
by highend
If you add the CEA for "Other events" -> "Start" I'll buy it^^

Re: Allow user defined global variables

Posted: 19 May 2022 17:21
by admin
LOL -- ask me again after 23.10 is published. I'm up to my ears in the release process.

Re: Allow user defined global variables

Posted: 20 May 2022 12:43
by highend
Ok, you've asked for it :masked:

*BUMP*

I really need this, my VPN provider software doesn't let me use hostnames while connected (inside the local lan)...

Re: Allow user defined global variables

Posted: 20 May 2022 12:47
by admin
Wow. :biggrin: Next week...

Re: Allow user defined global variables

Posted: 20 May 2022 19:47
by eil
Hope "new" global vars would allow to migrate in separate file, making main .ini clearer. :ninja:

Re: Allow user defined global variables

Posted: 23 May 2022 14:39
by highend
Great stuff, defined my share as: \\<perm uk_nuc_01>\dlna\movies
and it works fine :tup:

Can we get the "On start" CEA as well please? I don't want to start new instances with command args (for a setup script loading)... :titter: