If Expressions Don't Work
I'm having a problem with getting if expressions to work. The problem is
that the first if statement is used, even if the expression beside should
return a value of FALSE.
For example, when I run this script, it should be that %X% would have a
value of 10 by the time it has run twice. (First is 5, second is 10).
%length% would then incidentally have a value of 2 on the second run.
The message box that I get on the second run says "The length of InputVar
is 2. - One - 2" all the way up through the 19th run which says "The
length of InputVar is 2. - One - 19". Then when it hits runs 20 (through
22), it says "The length of InputVar is 3. - One - 20".
What am I doing wrong?
^1::
X:=0
Y:=0
Loop, 22
{
Y:=++Y
X:=5+X
InputVar:=X
StringLen, length, InputVar
if (%length%<2)
{
MsgBox, 1, Length, The length of InputVar is %length%. - One - %Y%, 2
}
else if (%length%==2)
{
MsgBox, 1, Length, The length of InputVar is %length%. - Two - %Y%, 2
}
else if (%length%>2)
{
MsgBox, 1, Length, The length of InputVar is %length%. - Three - %Y%, 2
}
else
{
MsgBox, 1, Length, The length of InputVar is %length%. - Unknown - %Y%, 2
}
Sleep 500
}
Return
;These are the written numbers I should expect to be paired up with %Y%.
;One - 1
;Two - 2-19
;Three - 20-22
No comments:
Post a Comment