如果表达式不起作用

时间:2013-08-11 21:49:07

标签: autohotkey

我遇到了让表达式工作的问题。问题是使用了第一个if语句,即使旁边的表达式应该返回值FALSE。

例如,当我运行此脚本时,应该是%X%在运行两次时的值为10。 (首先是5,第二是10)。然后%length%偶然会在第二次运行时具有值2。

我在第二次运行中得到的消息框说“InputVar的长度是2. - 一 - 2”一直到第19次运行,其中说“InputVar的长度为2. - One - 19” 。然后当它达到20(到22)的运行时,它表示“InputVar的长度是3. - 一 - 20”。

我做错了什么?

^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

1 个答案:

答案 0 :(得分:0)

我编辑了原帖。检查第一行。

  

(已解决!我需要在将它与2的值进行比较时除去%length%中的%。)

编辑:而且,BGM,你知道你必须等一天才能将自己的答案标记为正确的答案吗?我明天不会回来的。)