It is currently April 27th, 2024, 3:58 pm

!WriteKeyValue does not work in InputText.dll Measure

Report bugs with the Rainmeter application and suggest features.
Frasier
Posts: 7
Joined: August 10th, 2012, 3:38 pm

!WriteKeyValue does not work in InputText.dll Measure

Post by Frasier »

Hi!

I'm trying to save the user entered value to the config file, but it simply does not work. This is the code (part of it of course):

;--------------------------------------------------------
[Variables]
Calc=0
Text1a=

[MeasureInput]
Measure=Plugin
Plugin=InputText.dll
X=10
Y=112
H=18
W=190
FontColor=#color.Highlight#
SolidColor=#color.Skin1#
FontFace=Aller
StringStyle=Bold
FontSize=10
FocusDismiss=1
UpdateDivider=86400
DefaultValue=
Command1=!SetVariable Calc "$UserInput$"
Command2=!WriteKeyValue Variables Text1a #Calc#
Command3=!Refresh #CURRENTCONFIG#
;--------------------------------------------------------

The edit field appears and works, the variable "Calc" is set correctly (if I delete Command3), but WriteKeyValue does not do anything! If I use the exact same commands elsewhere in the skin (e.g. in a LeftMouseUpAction), it works fine.

What seems to be the problem here? How can I save data entered by the user to disk? I've now tried to solve this problem for hours, but nothing seems to work.

Thanks!
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: !WriteKeyValue does not work in InputText.dll Measure

Post by Kaelri »

Try specifying the filename:

Code: Select all

Command2=!WriteKeyValue Variables Text1a "#Calc#" "#CURRENTPATH##CURRENTFILE#"
Frasier
Posts: 7
Joined: August 10th, 2012, 3:38 pm

Re: !WriteKeyValue does not work in InputText.dll Measure

Post by Frasier »

Thanks, this seems to do the trick! Great!

However, there's now another problem: how do I write the result of a formula to the ini file? Here's the code:

;------------------------------------

[Variables]
Text1a=1+2
Text1b=[MeasureCalc]
Text2a=
Text2b=

; MEASURES ====================================
[MeasureCalc]
Measure=Calc
Formula=#Text1a#
DynamicVariables=1

[MeasureInput]
Measure=Plugin
Plugin=InputText.dll
X=10
Y=112
H=18
W=190
FontColor=#color.Highlight#
SolidColor=#color.Skin1#
FontFace=Aller
StringStyle=Bold
FontSize=10
FocusDismiss=1
UpdateDivider=86400
DefaultValue=
Command1=!WriteKeyValue Variables Text1a "$UserInput$" "#CURRENTPATH##CURRENTFILE#"
Command2=!WriteKeyValue Variables Text1b [MeasureCalc] "#CURRENTPATH##CURRENTFILE#"
Command3=!Refresh #CURRENTCONFIG#

;------------------------------------

When the user enters a formula, I'd like to save it in Text1a and the result in Text1b. However, Text1b always contains "[MeasureCalc]" instead of the real value, in this case "3". A meter, that displays Text1b, correctly shows "3". So how can I get this "real" result and save it to disk?

This all seems very illogical to me and the manual does not really provide enough info, so sorry for bothering you...

Thanks for helping me out!
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: !WriteKeyValue does not work in InputText.dll Measure

Post by Kaelri »

This is a little trickier. The reason it doesn't work now is because InputText is not one of the plugins that support dynamic variables. There are a few workarounds you could do; probably the easiest would be to activate another measure that can use DVs.

Code: Select all

[MeasureInput]
Measure=Plugin
Plugin=InputText.dll
X=10
Y=112
H=18
W=190
FontColor=#color.Highlight#
SolidColor=#color.Skin1#
FontFace=Aller
StringStyle=Bold
FontSize=10
FocusDismiss=1
UpdateDivider=86400
DefaultValue=
Command1=!WriteKeyValue Variables Text1a "$UserInput$" "#CURRENTPATH##CURRENTFILE#"
Command2=!ActivateMeasure WriteVariable

[WriteVariable]
Measure=Calc
Disabled=1
DynamicVariables=1
Formula=1
IfEqualValue=1
IfEqualAction=[!WriteKeyValue Variables Text1b "[MeasureCalc]" "#CURRENTPATH##CURRENTFILE#"][!Refresh]
There's probably a more elegant way that I just can't think of right now.
Frasier
Posts: 7
Joined: August 10th, 2012, 3:38 pm

Re: !WriteKeyValue does not work in InputText.dll Measure

Post by Frasier »

Thanks! It works with "!EnableMeasure" ("!ActivateMeasure" doesn't seem to have any effect).

Thanks for your help!
User avatar
Kaelri
Developer
Posts: 1721
Joined: July 25th, 2009, 4:47 am

Re: !WriteKeyValue does not work in InputText.dll Measure

Post by Kaelri »

Whoops. I think I need some juice and crackers.

Glad you got it working, my absentmindedness notwithstanding. :)