AutoIt 语法检查器 (Au3Check)
语法检查完整语言.
检查所有使用的符号:
报告使用非定义宏错误.
如果变量在定义之前使用, Au3Check 将发出警告.
这时程序可能仍然是正确的, 如下所示:
For $i=1 To 2
If $i=2 Then msgbox(0, "确定", $hello);
Local $hello = "再见"
Next
然而, 这不是良好的编程风格, Au3Check 将发出警告: $hello is possible used before it
is declared ($hello 可能是声明之前已使用).
同样的, 全局变量最好不要在声明之前使用.
如果使用高级代码, 也会出现警告.
如果变量在使用前没有明确的直接或间接声明, Au3Check 都将发出错误警告.
函数可以在定义后不调用. Au3Check
检查被调用函数参数的正确编号.
同时还检查 ByRef 调用的参数和变量 (不能是左值[注:赋值符号左边值], 表达式).
最后报告非定义的函数.
要管理一些警告/错误, 不能避免可以包含在该脚本中的一些具体命令.
命令
--------------
可用于插件(plugin)函数, 如下例:
#ignoreFunc PluginFunc1
Local $handle = PluginOpen("example.dll")
PluginFunc1(0.1, 0.2) ; 将调用有 2 个参数的插件(plugin)函数
PluginClose($handle)
可用于插件(plugin)函数, 如下例:
Func Test_Numparams($v1 = 0, $v2 = 0, $v3 = 0,
$v4 = 0, $v5 = 0, $v6 = 0, $v7 = 0, $v8 = 0, $v9 = 0)
#forceref $v1, $v2, $v3, $v4, $v5, $v6, $v7, $v8, $v9
Local $val
For $i = 1 To @NumParams
$val &= Eval("v" & $i) & " "
Next
MsgBox(0, "@NumParams 示例", "@NumParams =" & @NumParams &
@CRLF & @CRLF & $val)
EndFunc
可用于 Assign() 函数后面, 如下例:
$n = Assign("y", 3)
#forcedef $y
$n = $y ;===> $y = 3
此命令行实用程序可以作为编辑器附加调用. 它与 AutoIt3.exe 在同一目录.
SciTe4AutoIt3 编辑器提供了这样的环境.
用法
--------
-q : quiet (only error/warn output) -
- - 静态 (仅输出错误/警告)
-d : 等价于 Opt("MustDeclareVars", 1)
-w 1: already included file (on) - - - 已包含文件 (打开)
-w 2: missing #comments-end (on) - - - 缺少 #comments-end (打开)
-w 3: already declared var (off) - - - 变量已声明 (关闭)
-w 4: local var used in global scope (off) - - - 局部变量在全局范围内使用
(关闭)
-w 5: local var declared but not used (off) - - - 本地变量已声明, 但未使用
(关闭)
-w 6: warn when using Dim (off) - - - 使用 Dim 时警告 (关闭)
-w 7: warn when passing Const or expression on ByRef param(s) (on)
- - - 传递常量或表达式到 ByRef 时警告 (打开)
-I dir: additional directories for searching include files - - -
搜索其他目录的包含文件
-v 1: show include paths/files (off) - - - 显示包含路径/文件 (关闭)
-v 2: show lexer tokens (off) - - - 显示词法标记 (关闭)
-v 3: show unreferenced UDFs and global variables (off) - - - 显示未引用
UDF 和全局变量 (关闭)
退出代码:
0: 成功: 没有错误或警告
1: 警告
2: 语法错误
3: 使用或输入错误
如何不检查
--------------------------
基本运行信息:
- 不检查数组维数, 或索引. 这只能是完成运行时.
- 逻辑错误, 函数的非法参数, 与除数为 0.