rbriddickk84 wrote:Greetings!
I just thinking about this limiting thing, as i working on my clock skin.
I just making an alarm clock option for the main clock, an i want to limit the selectable options for the time.
For example i want to limit the minutes between 00 - 59. But with InputText plugin there are a lots of exception handling needed, and would make a simple alarm clock an insane amount of coding and refreshing actions with external file of use.
I was thinking a lot about some simpler method to limit the selectable options list somehow.
Sorry for posting in the wrong topic!
With the use of 1 IfMatch and 1 IfCondition tests on the value returned by the $UserInput$, you can limit the input to any number range and eliminate invalid text inputs.
I will post my input measure and hours test measure so you can see what I am doing.
When a minute time is input by the user, I set the variable Time1Min to the "$UserInput$", then in a string measure, I substitute to add leading zeroes, and test the string to see if it is 1 or 2 digits using the IfMatch. If it does not match digits (meaning it is text or a combination text/numbers), then I reset the variable to the default value and use !CommandMeasure to ask for the input again.
If it passes that test, then I use IfCondition to test to see if the digits are within the range I want to accept, if they are not, then the variable is set to the default, and !CommandMeasure will ask for the input again.
Code: Select all
[mItems]
Measure=Plugin
Plugin=InputText
SolidColor=0,0,0,255
FontColor=255,255,255,255
FontFace=#FontName#
FontSize=((#FontHeight#-1)*#MyScale#)
X=(12*#MyScale#)
Y=(25*#MyScale#)
H=(22*#MyScale#)
W=(140*#MyScale#)
Command1=[!SetVariable Item1 "$UserInput$"] Y=(5*#MyScale#) DefaultValue="#Item1#"
Command2=[!SetVariable Time1Hrs "$UserInput$"] W=(24*#MyScale#) DefaultValue=#Time1Hrs#
Command3=[!SetVariable Time1Min "$UserInput$"] W=(24*#MyScale#) X=(40*#MyScale#) DefaultValue=#Time1Min#
[mInputHrs1]
Measure=String
String=#Time1Hrs#
RegExpSubstitute=1
Substitute="^(\d$)":"0\1"
DynamicVariables=1
IfMatch=\d{1,2}
IfNotMatchAction=[!SetVariable Time1Hrs 00][!CommandMeasure "mItems" "ExecuteBatch 2"]
IfCondition=(#Time1Hrs#>=0)&&(#Time1Hrs#<=12)
IfFalseAction=[!SetVariable Time1Hrs 00][!CommandMeasure "mItems" "ExecuteBatch 2"]
IfConditionMode=1
[mInputMin1]
Measure=String
String=#Time1Min#
RegExpSubstitute=1
Substitute="^(\d$)":"0\1"
DynamicVariables=1
IfMatch=\d{1,2}
IfNotMatchAction=[!SetVariable Time1Min 00][!CommandMeasure "mItems" "ExecuteBatch 3"]
IfCondition=(#Time1Min#>=0)&&(#Time1Min#<=59)
IfFalseAction=[!SetVariable Time1Min 00][!CommandMeasure "mItems" "ExecuteBatch 3"]
IfConditionMode=1
This should let you limit the input to just numbers in a range you specify. There will be errors in the log by the If Condition if text is entered as the variable; IfCondition only recognizes numbers.
Let me know if this helps