Hi,
I have variables x1 - x20 and a variable y which takes values from 1 to 20.
Now, I'd like to set variable z to the value of x1-20 depending on status of y.
[!setVariable z x#y#] sets z to the name of the variable, but of course not to the value... :/
Is there any syntax to achieve this, or do I need to take the long way with some IfMatch... ?
It is currently April 25th, 2024, 10:38 am
Referencing to a variable using a variable in its name :/
-
- Posts: 39
- Joined: May 24th, 2020, 7:04 am
- Location: Switzerland
Referencing to a variable using a variable in its name :/
I think maybe no problem.
-
- Posts: 31
- Joined: June 17th, 2020, 3:08 am
Re: Referencing to a variable usng a variable in its name :/
I'm not sure I quite understand, but I think this could help? [!SetVariable z #x1##y1#]
All variables usually are surrounded by #, but they have a different syntax if they're nested. If this isn't it, then maybe look at nested variables: https://docs.rainmeter.net/manual/variables/nesting-variables/
All variables usually are surrounded by #, but they have a different syntax if they're nested. If this isn't it, then maybe look at nested variables: https://docs.rainmeter.net/manual/variables/nesting-variables/
-
- Posts: 39
- Joined: May 24th, 2020, 7:04 am
- Location: Switzerland
Re: Referencing to a variable using a variable in its name :/
Hi and thanks,
Yeah, I looked into these, but didn't get to something working. Also your suggestion can't work here.
I want to set z to the value of any x1-x20, whereas the number to be picked is the y variable.(There's no y1 or y2)
So the used syntax cannot include a specific x1 or x13...
Yeah, I looked into these, but didn't get to something working. Also your suggestion can't work here.
I want to set z to the value of any x1-x20, whereas the number to be picked is the y variable.(There's no y1 or y2)
So the used syntax cannot include a specific x1 or x13...
I think maybe no problem.
-
- Posts: 31
- Joined: June 17th, 2020, 3:08 am
Re: Referencing to a variable using a variable in its name :/
What's the use case?
Also, I'm kind of slow so if, for example, y=20 then x=20 and then z=2020??
Also, I'm kind of slow so if, for example, y=20 then x=20 and then z=2020??
-
- Posts: 39
- Joined: May 24th, 2020, 7:04 am
- Location: Switzerland
Re: Referencing to a variable using a variable in its name :/
Nope, example:
x1=5
x2=345
x3=65
x4=111
etc... these are user variables in an .inc file.
When y=3, I want to set z to the value of x3, when y=1 i want to set z to the value of x1.
x1=5
x2=345
x3=65
x4=111
etc... these are user variables in an .inc file.
When y=3, I want to set z to the value of x3, when y=1 i want to set z to the value of x1.
I think maybe no problem.
-
- Posts: 31
- Joined: June 17th, 2020, 3:08 am
Re: Referencing to a variable using a variable in its name :/
Then I'm pretty sure you're going to have to use IfConditions...
or
Should work in theory, but it's very late so I didn't test it. Also, if this has to be dynamic, I'd probably find a way to "merge" x and y if possible (though it might not be)
Code: Select all
[MeasureY]
Measure=Calc
Formula=#y#
IfCondition=MeasureY=1
IfTrueAction=[!SetVariable z x[MeasureY]]
Code: Select all
IfTrueAction=[!SetVariable z x#y#]
-
- Posts: 39
- Joined: May 24th, 2020, 7:04 am
- Location: Switzerland
Re: Referencing to a variable using a variable in its name :/
Yeah, I'm also afraid I'll have to go the long way...
Thanks anyway, have a nice eve.
Thanks anyway, have a nice eve.
I think maybe no problem.
-
- Moderator
- Posts: 1252
- Joined: February 16th, 2012, 3:32 am
- Location: Berlin, Germany
Re: Referencing to a variable using a variable in its name :/
Pflosch,
Like Halloyo said you would rather need here to use Nesting Variables.
If I got you right what you want to achive will look like this:
[!SetVariable z [#X[#Y]]]
Works for me:
Like Halloyo said you would rather need here to use Nesting Variables.
If I got you right what you want to achive will look like this:
[!SetVariable z [#X[#Y]]]
Works for me:
You do not have the required permissions to view the files attached to this post.
-
- Posts: 39
- Joined: May 24th, 2020, 7:04 am
- Location: Switzerland
Re: Referencing to a variable using a variable in its name :/
Wow, I tried every syntax of nesting I could figure, didn't come to that.
Was fiddling around an hour or so....
Thanks heaps, thatz x-actly it YMMD
Was fiddling around an hour or so....
Thanks heaps, thatz x-actly it YMMD
I think maybe no problem.
-
- Moderator
- Posts: 1252
- Joined: February 16th, 2012, 3:32 am
- Location: Berlin, Germany
Re: Referencing to a variable using a variable in its name :/
You are welcome!