文档中有一个Splitting a Long Line into a Series of Shorter Ones 部分:
长线可以分成一组较小的线
提高可读性和可维护性。这并没有减少
脚本的执行速度,因为这些行在内存中合并
脚本启动的那一刻。
方法#1:以“and”、“or”、||、&&、逗号或a开头的行
period 会自动与它正上方的行合并(在
v1.0.46+,所有其他表达式运算符也是如此,除了
++ 和 --)。在以下示例中,第二行附加到第一行,因为它以逗号开头:
FileAppend, This is the text to append.`n ; A comment is allowed here.
, %A_ProgramFiles%\SomeApplication\LogFile.txt ; Comment.
同样,以下行将合并为一行
因为最后两个以“and”或“or”开头:
if (Color = "Red" or Color = "Green" or Color = "Blue" ; Comment.
or Color = "Black" or Color = "Gray" or Color = "White") ; Comment.
and ProductIsAvailableInColor(Product, Color) ; Comment.
三元运算符也是不错的选择:
ProductIsAvailable := (Color = "Red")
? false ; We don't have any red products, so don't bother calling the function.
: ProductIsAvailableInColor(Product, Color)
虽然上面示例中使用的缩进是可选的,但它可能会改进
通过指示哪些行属于它们上方的行来清晰。还有,它
不必为以
单词“AND”和“OR”;该程序会自动执行此操作。最后,
空行或 cmets 可以添加在任何一个之间或末尾
以上示例中的行。
方法#2:这个方法应该用于合并大量行
或者当线条不适合方法 #1 时。这种方法虽然
对于自动替换热字串特别有用,它也可以用于
使用任何命令或表达式。例如:
; EXAMPLE #1:
Var =
(
Line 1 of the text.
Line 2 of the text. By default, a line feed (`n) is present between lines.
)
; EXAMPLE #2:
FileAppend, ; The comma is required in this case.
(
A line of text.
By default, the hard carriage return (Enter) between the previous line and this one will be written to the file as a linefeed (`n).
By default, the tab to the left of this line will also be written to the file (the same is true for spaces).
By default, variable references such as %Var% are resolved to the variable's contents.
), C:\My File.txt
在上面的示例中,一系列线的边界为
顶部和底部由一对括号。这被称为
续部分。请注意,底线包含
FileAppend 在右括号之后的最后一个参数。这
练习是可选的;它是在这样的情况下完成的,以便逗号
将被视为参数分隔符而不是文字逗号。
请阅读文档链接了解更多详情。
所以你的例子可以改写如下:
If Day(Date) > 10
And Hour(Time) > 20 Then
MsgBox
(
It is after the tenth
and it is evening
)