Page 1 of 1

Defining Global Variables on Start-up

Posted: 17 Apr 2022 19:11
by WirlyWirly
I posted in another thread asking if there might be a way to create a custom <MyVariable>, with the same scope and functionality of <xypath>/<xyicons>/<xydata>/etc.

My particular use case was described in my post, but essentially I'd like to turn a repetitive string that I use throughout XY (CFA/Scripts/Toolbar/etc) into its own variable.

A simple .ini file in the XY folder could suffice, a more advanced option might be a .xys script that is run at XY start-up to allow the user to generate more complex variables. These variables could then be used across XY in the GUI and scripts, just like <xypath>/<xydata>/etc.

Re: Defining Global Variables on Start-up

Posted: 17 Apr 2022 20:31
by eil
I'd propose you to investigate aliases, may help in your variable desire. Plus, there is a way to run script on start, you'll just need to run XY through .lnk with parameters.

Re: Defining Global Variables on Start-up

Posted: 17 Apr 2022 21:17
by highend
Aliases work in CFAs?

Another way would be an environment variable for the current user. The only current problem: XY only reads some standard environment variables, not all defined. Maybe a feature wish to change that?

Re: Defining Global Variables on Start-up

Posted: 17 Apr 2022 23:25
by eil
highend wrote: 17 Apr 2022 21:17 Aliases work in CFAs?
Don't know, just remembered smth along the lines. If they don't, This could be good idea for new feature - alias support everywhere.(and that would be quite a "user defined variable")

Re: Defining Global Variables on Start-up

Posted: 17 Apr 2022 23:29
by highend
The problem is: Alias definitions begin with @

How should XY definitely know if something inside a string is an alias or a simple folder name part?

Alias: @scripts=<xydata>

CFA:
txt>::load "R:\tmp\@scripts\notme.xys";

Re: Defining Global Variables on Start-up

Posted: 18 Apr 2022 16:21
by eil
highend wrote: 17 Apr 2022 23:29 The problem is: Alias definitions begin with @

How should XY definitely know if something inside a string is an alias or a simple folder name part?
IMO, i'd just make @name be treated like $name(how it kinda is now, but not everywhere), and @-at_start not interpreted any other way.