It is currently December 15th, 2019, 6:24 am

how to output [Variables] randomly?

Help with creating, editing & fixing problems with skins
gkmaz9
Posts: 31
Joined: August 26th, 2019, 10:42 am

how to output [Variables] randomly?

gkmaz9 » November 3rd, 2019, 10:20 am

I'm a novice about Rainmeter.
I want to randomly output the A1 to A4 values in [Variables]

If you just output A3, you should also output B3.
It should not be B4.


I tried this method for that.

------------------------------------------------------
[Random]
Measure=Calc
Formula=Random
LowBound=1
HighBound=4

[OutPut1]
Meter=String
MeasureName=random
Text=#A%1#

This doesn't work. It is output as "#A1#" ~ "#A4#".
------------------------------------------------------
Meter=String
Text=#A3#

This works The output is "Healthy".
------------------------------------------------------

1. How should I write it in "text=" to make it work properly?

2. If the method is wrong, what should I do?




Variables.inc

Code: Select all

[Variables]
A1=Sweet
A2=Delicious
A3=Healthy
A4=Iced

B1=Apple
B2=Banana
B3=Orange
B4=Pear



Random.ini

Code: Select all

[Rainmeter]
Update=10000000
DynamicWindowSize=1

[Metadata]
PART.2 PRACTICE

[Variables]
@include=#@#Variables.inc

[Random Botton]
Meter=String
SolidColor=255,255,255,100
x=470
Y=50
W=30
H=30
LeftMouseUpAction=[!Refresh][!Update][!Redraw]

[Random]
Measure=Calc
Formula=Random
LowBound=1
HighBound=4

[OutPut1]
Meter=String
MeasureName=Random
Text=[color=#FF0040]"#A%1# #A4#"[/color]
FontSize=12
FC=255,255,255,255
AntiAlias=1
X=0
Y=100

[OutPut2]
Meter=String
MeasureName=Random
Text=[color=#FF0040]"#B%1# #B3#"[/color]
FontSize=12
FC=255,255,255,255
AntiAlias=1
X=0
Y=200


Last edited by gkmaz9 on November 3rd, 2019, 11:18 am, edited 1 time in total.
mak_kawa
Posts: 371
Joined: December 30th, 2015, 9:47 am

Re: how to output [Variables] randomly?

mak_kawa » November 3rd, 2019, 10:57 am

Nested variables should be written in adequate nesting expression. For example, following code does work.

Code: Select all

[Rainmeter]
Update=1000
BackgroundMode=2
SolidColor=192,192,192,192

[Variables]
A1=Apple
A2=Banana
A3=Orange
A4=Pear

[Random]
Measure=Calc
Formula=Random
LowBound=1
HighBound=4

[OutPut1]
Meter=String
Text=[#A[&Random]]
DynamicVariables=1
mak_kawa
Posts: 371
Joined: December 30th, 2015, 9:47 am

Re: how to output [Variables] randomly?

mak_kawa » November 3rd, 2019, 11:07 am

Forgot the URL of concerned document page.
Nesting Variables
gkmaz9
Posts: 31
Joined: August 26th, 2019, 10:42 am

Re: how to output [Variables] randomly?

gkmaz9 » November 3rd, 2019, 11:17 am

I am immature and keep forgetting this part.
Thank you for your help.
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: how to output [Variables] randomly?

balala » November 3rd, 2019, 7:42 pm

gkmaz9 wrote:
November 3rd, 2019, 10:20 am
I'm a novice about Rainmeter.
mak_kawa solved the problem and there is nothing to be said related to this solution. However if you1re a "novice" I have a few additional comments related to the original code:
  • Update=10000000 ([Rainmeter] section)? OMG! One update per 10,000,000 seconds = more then 115 days! Although not forbidden, doesn't make too much sense. In such cases I'd use better the Update=-1 option, which makes the skin being updated only on loading / refreshing. Much logical than updating it once per 115 days.
  • Although not forbidden, nor a good idea is to use spaces into section names. Can cause a lot of problems on long terms. That's why I'd rename the [Random Botton] meter as [RandomBotton]. Much better.
  • Coloring sections of a code posted with </Code> tags are not allowed on this forum. That's why for instance the Text options of both String meters are looking like

    Code: Select all

    [OutPut1]
    ...
    Text=[color=#FF0040]"#A%1# #A4#"[/color]
  • There is no need to add quotations around the options. For instance they are not needed into the Text options of the String meters. That's why Text="#A%1# #A4#" should be Text=#A%1# #A4#, which is enough. Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=26350&p=137628&hilit=quote+enclose+option#p137628
  • If you refresh a skin, any other operation is completely useless. For instance the [!Update] and [!Redraw] bangs are useless in the LeftMouseupAction option of the [Random Botton] meter, because they are posted together with a [!Refresh] bang. When you refresh a skin it is completely rebuilt, no need to additionally update and redraw it.
  • A FC option doesn't exist, you can't use it. It makes no sense. For example you've used a such option into the [OutPut1] and [OutPut2] meters. I'm not sure what your intention was. You wanted to set the color of the strings? If so, you have to use FontColor options instead of FC.
  • The key why your initial approach didn't work and were needed to use nesting variables is that variables are resolved before measures. Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=20865&p=111469&hilit=variables+resolved+before+measures#p111469.
Yincognito
Posts: 684
Joined: February 27th, 2015, 2:38 pm

Re: how to output [Variables] randomly?

Yincognito » November 3rd, 2019, 8:57 pm

balala wrote:
November 3rd, 2019, 7:42 pm
  • Update=10000000 ([Rainmeter] section)? OMG! One update per 10,000,000 seconds = more then 115 days!
...and you thought me updating two little skins once every hour was too much, eh? :lol:
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: how to output [Variables] randomly?

balala » November 3rd, 2019, 9:07 pm

Yincognito wrote:
November 3rd, 2019, 8:57 pm
...and you thought me updating two little skins once every hour was too much, eh? :lol:
Right. :handtohead:
However if I remember it well, we were talking about updating a webParser measure, not the skin. That was done once per hour (or am I wrong remembering this?).
Finally how often are you updating the skin is entirely up to you. It's just a question of what is reasonable.
Yincognito
Posts: 684
Joined: February 27th, 2015, 2:38 pm

Re: how to output [Variables] randomly?

Yincognito » November 3rd, 2019, 9:19 pm

balala wrote:
November 3rd, 2019, 9:07 pm
Right. :handtohead:
However if I remember it well, we were talking about updating a webParser measure, not the skin. That was done once per hour (or am I wrong remembering this?).
Finally how often are you updating the skin is entirely up to you. It's just a question of what is reasonable.
Yeah, I know - but I just meant it as a funny comparison between the two circumstances. Something like ... "now you saw what a long update period really means" ;-)
User avatar
balala
Rainmeter Sage
Posts: 9267
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: how to output [Variables] randomly?

balala » November 3rd, 2019, 9:22 pm

Yincognito wrote:
November 3rd, 2019, 9:19 pm
Yeah, I know - but I just meant it as a funny comparison between the two circumstances. Something like ... "now you saw what a long update period really means" ;-)
:thumbup:
gkmaz9
Posts: 31
Joined: August 26th, 2019, 10:42 am

Re: how to output [Variables] randomly?

gkmaz9 » November 16th, 2019, 10:09 am

balala wrote:
November 3rd, 2019, 7:42 pm
mak_kawa solved the problem and there is nothing to be said related to this solution. However if you1re a "novice" I have a few additional comments related to the original code:
  • Update=10000000 ([Rainmeter] section)? OMG! One update per 10,000,000 seconds = more then 115 days! Although not forbidden, doesn't make too much sense. In such cases I'd use better the Update=-1 option, which makes the skin being updated only on loading / refreshing. Much logical than updating it once per 115 days.
  • Although not forbidden, nor a good idea is to use spaces into section names. Can cause a lot of problems on long terms. That's why I'd rename the [Random Botton] meter as [RandomBotton]. Much better.
  • Coloring sections of a code posted with </Code> tags are not allowed on this forum. That's why for instance the Text options of both String meters are looking like

    Code: Select all

    [OutPut1]
    ...
    Text=[color=#FF0040]"#A%1# #A4#"[/color]
  • There is no need to add quotations around the options. For instance they are not needed into the Text options of the String meters. That's why Text="#A%1# #A4#" should be Text=#A%1# #A4#, which is enough. Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=26350&p=137628&hilit=quote+enclose+option#p137628
  • If you refresh a skin, any other operation is completely useless. For instance the [!Update] and [!Redraw] bangs are useless in the LeftMouseupAction option of the [Random Botton] meter, because they are posted together with a [!Refresh] bang. When you refresh a skin it is completely rebuilt, no need to additionally update and redraw it.
  • A FC option doesn't exist, you can't use it. It makes no sense. For example you've used a such option into the [OutPut1] and [OutPut2] meters. I'm not sure what your intention was. You wanted to set the color of the strings? If so, you have to use FontColor options instead of FC.
  • The key why your initial approach didn't work and were needed to use nesting variables is that variables are resolved before measures. Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=20865&p=111469&hilit=variables+resolved+before+measures#p111469.
To post the question I have simplified the skin.
In this process, There was a mistake in some of them.


It is this.

[Variables]
FS=13
FF=Open Sans Regular
FC=255,255,255,255

[Meter]
FontSize=#FS#
FontFace=#FF#
FontColor=#FC#

and...
"#A%1# #A4#"
" " is an expression for easier understanding.
But it was misleading.

According to your adivce,I delete "[!Update][!Redraw]" and...
"Update = 10000000" is modified.