It is currently May 3rd, 2024, 10:57 am

X Y string position based up on other measure value

Get help with creating, editing & fixing problems with skins
atuum
Posts: 6
Joined: April 24th, 2012, 9:07 am

X Y string position based up on other measure value

Post by atuum »

I want to change my X position if some measure have "one" inside it (the number)
But can't find any "contains" for the syntax here
Can you guide me to the right way?
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: X Y string position based up on other measure value

Post by Mordasius »

I suspect you could use Substitute to get the X position. It would help if you gave us some idea of the range and format of number values you are expecting from the measure you want to use to change the X value..
atuum
Posts: 6
Joined: April 24th, 2012, 9:07 am

Re: X Y string position based up on other measure value

Post by atuum »

Code: Select all

[Rainmeter]
Update=1000

[TimeMeasure]
Measure=Time
Format=%S

[TimeText]
Meter=String
MeasureName=TimeMeasure
X=5
Y=5
W=100
H=25
FontColor=255,255,255,255
Text="Seconds: %1"
Simple example. How to change X position of string if TimeMeasure returns "1" inside of it? And change it back if there is no "1" inside TimeMeasure
To make it clearer I mean all numbers with 1 inside.. like 21;12;11;41;15 etc.
User avatar
Mordasius
Posts: 1173
Joined: January 22nd, 2011, 4:23 pm
Location: GMT +8

Re: X Y string position based up on other measure value

Post by Mordasius »

atuum wrote:To make it clearer I mean all numbers with 1 inside.. like 21;12;11;41;15 etc.
Something like this might work:

Code: Select all

[Variables]
XposOnes=111
XposNoOnes=0

[TimeMeasure]
Measure=Time
Format=%S
Substitute="01":"#XposOnes#", "10":"#XposOnes#", "11":"#XposOnes#", "12":"#XposOnes#", "13":"#XposOnes#", "14":"#XposOnes#", "15":"#XposOnes#", "16":"#XposOnes#", "17":"#XposOnes#", "18":"#XposOnes#", "19":"#XposOnes#", "21":"#XposOnes#","31":"#XposOnes#", "41":"#XposOnes#", "51":"#XposOnes#"
DynamicVariables=1 

[ChangeXpos]
Measure=Calc
Formula=([TimeMeasure]*1)
IfBelowValue=#XposOnes#
IfBelowAction=[!SetVariable  Xpos #XposNoOnes#]
IfEqualValue=#XposOnes#
IfEqualAction=[!SetVariable  Xpos #XposOnes#]
DynamicVariables=1 
You'll need to change XposOnes=111 and XposNoOnes=0 to the values you want then you can use [ChangeXpos] to set the X position based on the seconds with and without '1's in them.

EDIT2: I knew there would be a neater Substitute= way (like that provided by Kaelri below).

EDIT3: Carrying on as usual one step behind everyone else :)
Last edited by Mordasius on November 12th, 2012, 2:59 pm, edited 3 times in total.
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: X Y string position based up on other measure value

Post by Kaelri »

Code: Select all

RegExpSubstitute=1
Substitute="^[^1]*$":"#No#","(.*)1(.*)":"#Yes#"
#No# represents the value if there is no "1" character in the string, and #Yes# represents the value if "1" is found. These both need to be actual numbers in the final formula.

The catch is that the "No" value cannot contain a "1" character itself, because then it will be matched by the second substitute rule (as if there was a "1" in the original value). That means if you want, say, X=10 or X=21 when there is no "1", you'll have to work around this a little bit. The cleanest example would be to use a conditional in your formula:

Code: Select all

RegExpSubstitute=1
Substitute="^[^1]*$":"0","(.*)1(.*)":"1"

Code: Select all

X=([TimeMeasure] = 1 ? #Yes# : #No#)
EDIT: Sorry, Mordasius, you must have edited your post while I was writing this. Your solution works, but it would still have the issue with #XposOnes# being potentially matched by the other conditions.

EDIT 2: Although I guess that doesn't really matter in this case, since it will be replaced with itself. Nevermind, carry on. :)
atuum
Posts: 6
Joined: April 24th, 2012, 9:07 am

Re: X Y string position based up on other measure value

Post by atuum »

Thank you all for your time! Maybe I will stop modifying my skin.. pretty satisfied with the result, but most important I'm don't understand anything already :D