It is currently April 27th, 2024, 11:33 pm

!setvariable help needed

Get help with creating, editing & fixing problems with skins
Laaglander
Posts: 15
Joined: April 25th, 2015, 9:45 pm

!setvariable help needed

Post by Laaglander »

Hello,

I have a question.
I have 2 skins. 1 of those needs to sent his data to the other one.

From the sending script

Code: Select all

[MeasureSentValue]
[!SetVariable MeasureSentValue "[MeasureSending]" "D:\Users\xxxxx\Documents\Rainmeter\Skins\crypto_eigen\crypto_eigen.ini"]
recieving script

Code: Select all

[MeasureSentValue]
Measure=String
MeasureName=MeasureSentValue

[MeterSentValue]
Meter=String
MeasureName=MeasureSentValue
Text="geinvesteerd van de 2de: [MeasureSentValue]"
X=5
Y=20r
FontSize=13
FontColor=#FFFFFF#
DynamicVariables=1
but this isnt working.. How should i do it?

Mischa
Last edited by balala on December 24th, 2023, 3:10 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are posting codes. It's the </> button.
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: !setvariable help needed

Post by Yincognito »

Laaglander wrote: December 24th, 2023, 3:03 am Hello,

I have a question.
I have 2 skins. 1 of those needs to sent his data to the other one.

From the sending script

[MeasureSentValue]
[!SetVariable MeasureSentValue "[MeasureSending]" "D:\Users\xxxxx\Documents\Rainmeter\Skins\crypto_eigen\crypto_eigen.ini"]

recieving script

[MeasureSentValue]
Measure=String
MeasureName=MeasureSentValue

[MeterSentValue]
Meter=String
MeasureName=MeasureSentValue
Text="geinvesteerd van de 2de: [MeasureSentValue]"
X=5
Y=20r
FontSize=13
FontColor=#FFFFFF#
DynamicVariables=1

but this isnt working.. How should i do it?

Mischa
There are some problems with your codes:
1) In your case, both your sending script and your receiving script transfer data between measures that are named the same (i.e. [MeasureSentValue]). Now, since those scripts should be different .ini files placed in different folders (aka different skins), this is not a problem, but it will confuse you a bit (a more logical naming would have been [MeasureSentValue] in your sending script and [MeasureReceivedValue] in your receiving script, but we'll go with your current naming for the time being).
2) In your case, while sending the value of a variable is entirely possible if you wanted to, this is not the case since in your code, the receiving element is a measure and not a variable. Therefore, you should use !SetOption here, and not !SetVariable, while also taking into account that !SetOption will need to know the name of the option you're setting as well (so it will have one more parameter compared to !SetVariable).
3) Since you'd be using [MeasureSentValue] in a bang to refer to its value, that measure should have a DynamicVariables=1 line added to it.
4) Without a Measure=SomeMeasureTypeHere option, the [MeasureSentValue] from your sending script will be invalid and not represent a measure in the first place, so you should make sure that you define a Measure=... option in that section, e.g. Measure=String to match the receving measure's type.
5) Unless your sending code actually has a valid [MeasureSending] measure that you didn't post here, that part is invalid as well, since the only measure in the sending script that you posted is called [MeasureSent] (see the 1) point about the naming confusion)
6) Finally, the last parameter of your incorrect !SetVariable bang (and the correct !SetOption bang for this code) should be the config name of your skin, and not its path. In your case, that will simply be "crypto_eigen" (i.e. the folders that come after your "D:\...\Skins\" skins' folder in your path).
7) Since your receiving element is a measure, that measure would optionally have to be updated and your receiving skin be redrawn in order to see the change right away (otherwise the change will be visible based on the receiving skin's Update value from its [Rainmeter] section, by default 1000 ms aka 1 second)

So, your codes should be along these lines...

Sending Skin:

Code: Select all

[MeasureSendingValue]
Measure=String
String=I'm The Value Sent From A Measure In Another Skin!
OnUpdateAction=[!SetOption MeasureRecevingValue String "[MeasureSendingValue]" "crypto_eigen"]
DynamicVariables=1

[SomeMeter]
Meter=String
MeasureName=MeasureSendingValue
Text="A Skin Must Have At Least One Valid Meter: [MeasureSendingValue]"
X=5
Y=20r
FontSize=13
FontColor=255,255,255,255
DynamicVariables=1
Receiving Skin:

Code: Select all

[MeasureReceivingValue]
Measure=String
String=I'm The Current Value Of The Receiving Measure!

[MeterReceivingValue]
Meter=String
MeasureName=MeasureReceivingValue
Text="geinvesteerd van de 2de: [MeasureReceivingValue]"
X=5
Y=20r
FontSize=13
FontColor=255,255,255,255
DynamicVariables=1
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Laaglander
Posts: 15
Joined: April 25th, 2015, 9:45 pm

Re: !setvariable help needed

Post by Laaglander »

thank you so much for your responce.

first why they are almost called the same way is that i use the skinn twice. The first one ran out of room and i thought it would be easier to dublicat the skin and us it a second time, but de data collected from the second one "must" be get somehow in the first one to make ik more readeble and will be intergraded more when i got this working.. the way i thought i could check this is to write it out in the first one.

the sent value is indeed a number from a formula. so yes you are correct is is a measure and not a variable, gled you point this out to help me understand this scripting.. i am still and always be learning this.

the skin is almost called the same but for the second one i added a 2. My thoughts were i have to sent it to the correct ini and that was the path, when i did this with #@#\crypto_eigen\crypto_eigen.ini it add a extra \crypto_eigen2, for that my sollution was the complete path.

i will came back when i did you suggestions
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: !setvariable help needed

Post by Yincognito »

Laaglander wrote: December 24th, 2023, 7:22 pm thank you so much for your responce.

first why they are almost called the same way is that i use the skinn twice. The first one ran out of room and i thought it would be easier to dublicat the skin and us it a second time, but de data collected from the second one "must" be get somehow in the first one to make ik more readeble and will be intergraded more when i got this working.. the way i thought i could check this is to write it out in the first one.

the sent value is indeed a number from a formula. so yes you are correct is is a measure and not a variable, gled you point this out to help me understand this scripting.. i am still and always be learning this.

the skin is almost called the same but for the second one i added a 2. My thoughts were i have to sent it to the correct ini and that was the path, when i did this with #@#\crypto_eigen\crypto_eigen.ini it add a extra \crypto_eigen2, for that my sollution was the complete path.

i will came back when i did you suggestions
Sure thing. I'm sure there is an easier way to do what you wanted without duplicating skins because one of them "ran out of room" (not sure what this means), but alright, go ahead and test the approach. ;-)
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Laaglander
Posts: 15
Joined: April 25th, 2015, 9:45 pm

Re: !setvariable help needed

Post by Laaglander »

well put this 8 times on your screen :D

Code: Select all

;-----------------------------------------1------------------------------------

[MeasurePrice1]
Measure=Plugin
Plugin=WebParser
URL=https://pro-api.coinmarketcap.com/v1/cryptocurrency/quotes/latest?symbol=#CryptoS1#&convert=EUR&CMC_PRO_API_KEY=#APIKey#
RegExp="price":(\d+\.\d{1,10})"
StringIndex=1
UpdateRate=#RefreshRate#

[MeasureTotalValue1]
Measure=Calc
Formula=MeasurePrice1*#Amount1#

[MeasureProfit1]
Measure=Calc
Formula=MeasureTotalValue1-#Cost1#

[MeasureProfitSign1]
Measure=Calc
Formula=MeasureProfit1
IfBelowValue=0
IfBelowAction=[!SetOption MeterProfit1 FontColor "#ColorDown#"][!SetOption "MeterProfitImage1" "ImageName" "#@#/Images/Down.png"][!Redraw]
IfAboveValue=0
IfAboveAction=[!SetOption MeterProfit1 FontColor "#ColorUp#"][!SetOption "MeterProfitImage1" "ImageName" "#@#/Images/Up.png"][!Redraw]

[MeterCoin1]
Meter=String
Text="#CryptoL1#"
X=5
Y=1r
FontSize=15
FontColor=#FFFFFF#
SolidColor=0,0,0,1
Padding=0,0,0,0
StringAlign=Left
AntiAlias=1

[MeterAmount1]
Meter=String
Text="Je hebt #Amount1# #CryptoL1#"
X=5
Y=26r
FontSize=10
FontColor=#FFFFFF#
SolidColor=0,0,0,1
Padding=0,0,0,0
StringAlign=Left
AntiAlias=1

[MetersingleValue1]
Meter=String
Text="De huidige waarde van #CryptoL1#: [MeasurePrice1] Euro"
X=5
Y=15r
FontColor=#FFFFFF#
DynamicVariables=1

[MeterCost1]
Meter=string
Text="Kosten met kopen: #Cost1# Euro"
x=5
y=15r
FontSize=10
FontColor=#FFFFFF#
SolidColor=0,0,0,1
Padding=0,0,0,0
StringAlign=LeftDynamicVariables=1

[MeterTotalValue1]
Meter=String
MeasureName=MeasureTotalValue1
Text="De totale waarde van    #CryptoL1#: [MeasureTotalValue1] Euro"
X=5
Y=15r
FontColor=#FFFFFF#
DynamicVariables=1

[MeterProfitImage1]
Meter=Image
ImageName=#@#/Images/Steady.png
x=#Col1XPos#
y=20r

[MeterProfit1]
Meter=String
MeasureName=MeasureProfit1
Text="winst: [MeasureProfit1] Euro"
X=#Col2XPos#
Y=-4r
FontColor=#FFFFFF#
DynamicVariables=1
Last edited by balala on December 25th, 2023, 7:07 am, edited 1 time in total.
Reason: Please use <code> tags whenever are posting codes. It's the </> button.
Laaglander
Posts: 15
Joined: April 25th, 2015, 9:45 pm

Re: !setvariable help needed

Post by Laaglander »

wait.. i could play with the x and y ofcourse.. is that what you ment?
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: !setvariable help needed

Post by Yincognito »

Laaglander wrote: December 24th, 2023, 9:17 pm wait.. i could play with the x and y ofcourse.. is that what you ment?
Yes. You could keep a single instance of your general measures (e.g. those getting overall data), then just duplicate your particular measures (e.g. those getting individual data) and meters (e.g. those displaying individual data) under different names and using different option values. Obviously, when it comes to meters, some of those options are the X and Y ones.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Laaglander
Posts: 15
Joined: April 25th, 2015, 9:45 pm

Re: !setvariable help needed

Post by Laaglander »

LOL BRILLIANT. Why didnt i think about that? :D i trying that first :P
User avatar
Yincognito
Rainmeter Sage
Posts: 7178
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: !setvariable help needed

Post by Yincognito »

Laaglander wrote: December 25th, 2023, 2:17 am LOL BRILLIANT. Why didnt i think about that? :D i trying that first :P
Excellent! Easy to overlook simple solutions when you're just starting. This is mostly about copy pasting and changing the bits that differentiate things (like getting Crypto1, Crypto2, and so on). Ideally, if possible, you'd have a single WebParser measure that gets all needed data, then just subsequently extract the parts you need using StringIndex and/or StringIndex2:
https://docs.rainmeter.net/manual/measures/webparser/
Of course, if you're not sure how to do that or you think that you're complicating things, you could have more WebParsers that each get one instance, though this would poll the said site more often than probably needed.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16182
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: !setvariable help needed

Post by balala »

Yincognito wrote: December 24th, 2023, 3:09 pm There are some problems with your codes:
Little bit late in this party, but in fact there is one more, which has not been mentioned in your list: even if [MeasureSentValue] of the sending skin would be a "real" measure (having a Measure=... option), adding a bang just like that in its code, get's nothing working. That bang (in this case the !SetVariable) not being included into an option, just being posted there, is never executed (even if it'sd correct, even less if it's not).