如果表达式不起作用 [英] If Expressions Don't Work

查看:58
本文介绍了如果表达式不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在获取表达式是否起作用时遇到问题.问题是,即使旁边的表达式应返回FALSE值,也将使用第一个if语句.

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.

例如,当我运行此脚本时,应确保%X%在运行两次时的值为10. (第一个是5,第二个是10).然后,%length%在第二次运行中的值将为2.

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.

我在第二次运行中得到的消息框显示"InputVar的长度为2.-1-2",直到第19次运行一直显示"InputVar的长度为2--1-19". .然后,当它命中20(通过22)时,它会说"InputVar的长度是3.-1-20".

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".

我在做什么错了?

^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

推荐答案

我编辑了原始帖子.检查第一行.

I edited the original post. Check the first line.

(解决了!在将它与2的值进行比较时,我需要摆脱%length%中的%.)

(Solved! I needed to get rid of the % in %length% when comparing it against the value of 2.)

而且,BGM,您是否知道您需要等待一天才能将自己的答案标记为正确答案?我明天不会回来:)

And, BGM, did you know you have to wait a day to mark your own answer as the correct answer? I won't be back tomorrow :)

这篇关于如果表达式不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆