It is currently May 3rd, 2024, 3:24 pm

How to use a variable to INDIRECTLY access another Variable?

Get help with creating, editing & fixing problems with skins
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

How to use a variable to INDIRECTLY access another Variable?

Post by bobgrosh »

I created some buttons to start, stop, display, and otherwise maniplate Live video streams I publish on one Livestream.com channel.

The problem is, I want to make those buttons work for several different channels, (upwards of 25 of them) rather than create (25 or more) variations, each customized to a single channel.

I understand Dynamic variables enough to make a working channel selector skin.
It has a button for each channel, and sets #DynamicChannelNumber# to 1,2, 3... etc. depending on the channel button pressed.

In the channel selector skin, and in the channel controls skin, I have something like this:

Code: Select all

[Variables]

1Channel=RainmeterTV
1URL=http://RainmeterTV.blogspot.com
1Tag=RainmeterTV
1USER=RainmeterGuest
1Password=retemniaR

2Channel=TallasseeTimes
2URL=http://TallasseeTV.com
2Tag=TallasseeTV
2USER=RainmeterGuest
2Password=retemniaR

3Channel=WestsideChurch
3URL=http://WestsideTallassee.com
3Tag=Westside
2USER=RainmeterGuest
2Password=retemniaR

DynamicChannelNumber=0

ThisChannel=None
ThisURL=None
ThisTag=None
ThisUser=None
ThisPassword=******

For each Channel selector button, I have this code:

Code: Select all


[selector1]
Meter=IMAGE

ImageName=icon#1Channel#.png
LeftMouseUpAction=!RainmeterSetVariable DynamicChannelNumber 1
DynamicVariables=1

[selector2]
Meter=IMAGE
ImageName=icon#2Channel#.png
LeftMouseUpAction=!RainmeterSetVariable DynamicChannelNumber 2
DynamicVariables=1
.
.
.
[selector25]
;etc.
The above just displays channel icons and sets the dynamic variable "DynamicChannelNumber" to a number (1-25) depending on the button pressed.
In the Channel Selector skin I have this code to display the currently selected channel:

Code: Select all

[measureThisConfig]
Measure=CALC
Formula=#DynamicChannelNumber#
dynamicVariables=1


[meterThisConfig]
Meter=STRING
measureName=MeasureThisConfig
Text= Current channel is: #DynamicChannelNumber# or %1
dynamicVariables=1
When Channel Selector button 12 is clicked the meter displays

Current channel is: 12 or 12
So I know both ways of accessing the dynamic variable works.

My problem is, how do i set the variables like "ThisChannel" ThisURL" etc to the correct #Channel or #URL value?

For example: If the button for [selector2] is clicked, How do I set the variable "ThisURL" to contain "http://TallasseeTV.com"

Or, for that matter, how would I change the code in other skins so that I could use something like:
IE: where DynamicChannelNumber has been set to two in the channel selector skin.)
Text=#DynamicChannelNumber#URL and have the text display or use the contents of the defined variable in #2USER#

I keep thinking that I just can't find the right syntax, the right combinations of quotes, brackets or parentheses around the value. On the other hand, maybe I just can't indirectly access a variable this way, or need to create some sort of array.

Then again, Maybe it is some sort of newbee mistake that I have gotten bogged down in,,, AGAIN!
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: How to use a variable to INDIRECTLY access another Varia

Post by Chewtoy »

It sounds like you could have some help from this: http://rainmeter.net/forum/viewtopic.php?f=15&t=6044
:)

Basically what I would do; Create 25 .inc files with all the variables you use, then in your actually skin you just rotate what .inc should be used.
So your selector will just have a [!RainmeterWriteKeyValue Variables 1.inc] and a [!RainmeterRefresh]
This means you will only have one skin, but can cycle through how many variables you like.
I don't think, therefore I'm not.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: How to use a variable to INDIRECTLY access another Varia

Post by santa_ryan »

Using the calc is fairly pointless. Just point directly to the variable, and get rid of the calc. Unless you were just using it for testing purposes (Which i do believe you were)

Im think what your asking is "How do I use multiple bangs in a single action?" and "How do I reference a variable from a variable?"

Both are very easy to do...
Answering the first question, you need to use the !Execute bang

!Execute
Special !bang that can be used to combine several !bangs together. The !bangs are separated with '[' and ']'-chars. You can also launch applications with this (!Execute ["C:\Windows\Notepad.exe"])
And answering the second question, you just insert #*VariableName*# into another variable.

LeftMouseUpAction=!Execute [!RainmeterSetVariable DynamicChannelNumber 2][!RainmeterSetVariable ThisURL #2URL#]

Heres an example skin for you to use to see the effect using your examples that you posted:

Code: Select all

[variables]
1Channel=RainmeterTV
1URL=http://RainmeterTV.blogspot.com
1Tag=RainmeterTV
1USER=RainmeterGuest
1Password=retemniaR

2Channel=TallasseeTimes
2URL=http://TallasseeTV.com
2Tag=TallasseeTV
2USER=RainmeterGuest
2Password=retemniaR

;-----------------------------------------------------------------------
;DO NOT TOUCH THESE....!!!! EVER!!!!! >=|
;Deleteting These Variable Keys/Values Will Result In A Skin Malfunction
;YOU HAVE BEEN WARNED!!!!!

DynamicChannelNumber=N/A
ThisChannel=No Channel Selected Yet
ThisURL=No Channel Selected Yet
ThisTag=No Channel Selected Yet
ThisUser=No Channel Selected Yet

;DO NOT TOUCH THESE....!!!! EVER!!!!! >=|
;Deleteting These Variable Keys/Values Will Result In A Skin Malfunction
;YOU HAVE BEEN WARNED!!!!!
;-----------------------------------------------------------------------


[selector1]
Meter=IMAGE
ImageName=icon#1Channel#.png
LeftMouseUpAction=!Execute [!RainmeterSetVariable DynamicChannelNumber 1][!RainmeterSetVariable ThisChannel #1Channel#][!RainmeterSetVariable ThisURL #1URL#][!RainmeterSetVariable ThisTag #1Tag#][!RainmeterSetVariable ThisUser #1USER#][!RainmeterUpdate]
DynamicVariables=1

[selector2]
Meter=IMAGE
ImageName=icon#2Channel#.png
LeftMouseUpAction=!Execute [!RainmeterSetVariable DynamicChannelNumber 2][!RainmeterSetVariable ThisChannel #2Channel#][!RainmeterSetVariable ThisURL #2URL#][!RainmeterSetVariable ThisTag #2Tag#][!RainmeterSetVariable ThisUser #2USER#][!RainmeterUpdate]
DynamicVariables=1

[meterThisConfig]
Meter=STRING
Y=5R
Text=Current channel is: #DynamicChannelNumber# - #ThisChannel##CRLF#Current URL is: #ThisURL##CRLF#Current tag is: #ThisTag##CRLF#Current user is: #ThisUser#
dynamicVariables=1
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

Thanks

Post by bobgrosh »

Thank You Chew Toy
Thank You Santa

Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you Thank you

WOW, I am so impressed by you guys.

I'll comment more later, got to try out these ideas.

Santa, you were right, I was just testing out the calc in hopes that I would maybe figure out how to just insert #*VariableName*# into another variable.
Your example :

Code: Select all

LeftMouseUpAction=!Execute [!RainmeterSetVariable DynamicChannelNumber 2][!RainmeterSetVariable ThisURL #2URL#]
was EXACTLY what I was looking for.

It seems I GREATLY understated the problem.
I only gave a small example. In reality, for each channel I need four times that number of parameters. Twenty five channels turns out to be a low estimate, I just received an addition list of FIFTY more channels for next years HS football season.

I totally left out that in addition to the dozen different functions I want buttons for, I also have as many as 6 computers and 15 cameras PER CHANNEL. On my desktops, I'll not only want to specify a channel, but also see all the computers/cameras involved in that channel, AND CAMERA/COMPUTER SELECTOR BUTTONS FOR THEM.

It gets worse....
I can't monitor all the ACTIVE channels on one computer here. My PC's can only display videos from about 4 or 5 channels at a time. Last season, I used four computers here to monitor and control a max of SIX games at the same time. Next Year I might have 30 games on at the same time.

BTW, I REALLY REALLY REALLY appreciate the excellent example of how to use multiple bangs with !Execute. I saved and indexed it on my personal blog where I can refer to it often. There are plenty of places I will need to do just that.

However, doing it that way in this case was just what I wanted to avoid, it seems like a maintenance nightmare. I'd eventually need four times as many bangs per line and 50 times as many lines. At my age, I'd surely type one digit wrong and never find it for the rest of my life. (Your other answer solves this particular issue perfectly.)

I was also considering chew's solution. In some other parts of this Theme, I think Chew's solution might be better from the standpoint of maintenance for parts of my theme, IE scoreboards for the games, list of camera operators and their account settings, etc. I Plan to be able to put blocks of variables in a dropbox so they can be distributed out to the 35 or so computers at the remote sites. My goal is to have some of the skins in my studio scheme reused on the screens of the camera operators. I like the idea of the skins being so easily portable and reusable while all the variables can be maintained here at one central location.

BTW

Totally off topic, but, has anyone made a RSS reader that reads football scores off of any of the popular sports pages?

THANKS AGAIN, Rainmeter is the best.

Bob
User avatar
Chewtoy
Moderator
Posts: 995
Joined: June 10th, 2009, 12:44 pm
Location: Sweden

Re: How to use a variable to INDIRECTLY access another Varia

Post by Chewtoy »

bobgrosh wrote:Totally off topic, but, has anyone made a RSS reader that reads football scores off of any of the popular sports pages?
Don't know how popular it is (not really a sports person), but there is this http://rainmeter.net/forum/viewtopic.php?f=27&t=7714

Glad you got the rest working out okay.
And if you are going to have to have that many channels operating, I really recommend that StyleSheet solution. It will keep your nightmares to a minimum as you won't get a wall of text when opening up a file and trying to find just the right line to edit.
Just have your bang that switches to the correct .inc and bam. That's done. You can even have THAT in it's own .inc! ;)
Will also be easier to organize what channel has what, as you can name the .inc to the channel name and so on without any troubles. So finding what file to edit is simple.
I don't think, therefore I'm not.
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: How to use a variable to INDIRECTLY access another Varia

Post by santa_ryan »

Hehe...

As for your "I can mistype stuff and it becomes a nightmare", you can use autoit or the likes, or you can use a stylesheet (A Much MUCH better solution)

As for autoit, You could easily make a script that basically copies and pastes a given block of code replacing any given "String" (like $ReplaceWithNumber$) for something like a number that counts up, and using a For Loop to keep track of your current "Repeat Number". Then you can just input the number of repeats you want via cmd argument and the code block and have it output the results to file.

As for your Off Topic question,
If the sports site you want has an RSS feed, then its quite easy and all of the default rainmeter suites come with an RSS reader.
If the sports site you want doesn't have an RSS feed, then you can make a webparse, but only if the data is HTML, XML, or the likes, and can be parsed straight out of the source code.
If the information is displayed in flash, java, shockwave (if that still exists :lol: ) or some other such language, then its not possible.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.
User avatar
bobgrosh
Posts: 134
Joined: May 1st, 2011, 10:33 pm

Re: How to use a variable to INDIRECTLY access another Varia

Post by bobgrosh »

Chewtoy wrote:
And if you are going to have to have that many channels operating, I really recommend that StyleSheet solution. It will keep your nightmares to a minimum as you won't get a wall of text when opening up a file and trying to find just the right line to edit.
At first glance, I did not see the possibilities.
Now I have had a chance to look at it a little more, yes, there are some things I need to do that it would be a huge help for.

I am still just starting to get comfortable with the code. I knew there would have been better approach I would have taken in some other language. Every suggestion you guys make just opens up more options.

Thanks.

Cool RSS sports reader, I just wanted to see an example. I will have to write something a little different for High-school sports. Sscores come in from lots of different sources including a regional HS sports site that has RSS, several individuals and radio announcers that twitter them, some that are called in to my camera operators and will have to be typed in, and finally, some that are posted as overlays on the flash videos during the game.

BTW, I don't believe it is impossible to glean a LOT of info from flash, It is full of metadata that includes over the shoulder graphics and ticker text that scrolls along the bottom of the screen.
Might be a while before I get to that, though. First I have to extract data direct from the video source. That will let me make meters and histograms for frame drops, frame rate, audio and video bandwidth, etc. Can't really see all that on the receiving end when data is dropped by the carrier.

Thanks Guys, Please understand if I don't respond to all your comments, I just got a check from a client for a new touch screen station with 3 cameras on it and a bunch of extras. I have to get the hardware ordered and I want to deliver it with Rainmeter as the desktop in three weeks.

My TODO list just grows faster than my out-box.

I'll still read every suggestion. They are greatly appreciated.


Bob
User avatar
santa_ryan
Posts: 397
Joined: June 22nd, 2010, 4:11 am

Re: How to use a variable to INDIRECTLY access another Varia

Post by santa_ryan »

Not a problem, Im out for summer tomorrow, and im going to be making tools to make my life easier in rainmeter. I'm going to upload them when im done. They could be of great use to you.

The most notable one is going to be RainRepeater. It's explained in my last post.

I often have a lot of meters with only a number changed counting up, (My Total Control dock and a few others) and so this will help speed up dev time.
I have three rules when I'm trying to help you.
  • Don't get mad when you don't understand something
  • Be VERY specific with what you ask for.
    The more specific you are, the higher the quality of support you receive.
  • Do not just copy and paste what I put in examples and come back saying it doesn't work.
    It does work, but I purposely left blanks that you need to fill for your specific needs.