A more elegant way to get variables dynamically Topic is solved

Propose new features and changes
crocodile
Posts: 98
Joined: 28 Dec 2020, 13:41

A more elegant way to get variables dynamically

01 Mar 2023, 11:48

The current method is

Code: Select all

t:="A_Args"

if isset(%t%)
	out := %t%
Can we add a function to get the variable from the string? e.g. out := getvar(t)
Descolada
Posts: 1174
Joined: 23 Dec 2021, 02:30

Re: A more elegant way to get variables dynamically  Topic is solved

02 Mar 2023, 09:39

I don't see why that would be necessary. If you want to assign the value of %t% to out, but choose a default value (e.g. "") if it's unset, you can use out := %t% ?? "". Or perhaps define a function that does that: Deref(var, default:="") => %var% ?? default. If you don't want to use a default value, then you just push your impending "unset variable" error further down the line:

Code: Select all

if isset(%t%)
	out := %t%
if %t% evaluates to unset, then out will be unset, and once you try to access it you will get an error (instead of getting it right away with %t%.
crocodile
Posts: 98
Joined: 28 Dec 2020, 13:41

Re: A more elegant way to get variables dynamically

04 Mar 2023, 07:05

Thank you. I ignored this new command.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 7 guests