[已解决],#forceref的含义
本帖最后由 529304mnm 于 2010-8-3 21:19 编辑如题,论坛上有人问但是没有解决。大侠们帮忙啊! 同问,一直没搞懂#forceref有何意义。
或者只是如;注释符号、#Engion那样,仅起到一个注释的作用?~ 要忽略的参数吧,猜的 http://www.autoitscript.com/forum/index.php?showtopic=39310
It tells Au3Check not to report on when a variable isn't used and option -w5 is selected . AutoIt3 Syntax Checker v1.54 Copyright © Tylo 2006
Usage: Au3Check [-q][-d] [-u file] [-w[-] n].. [-v[-] n].. [-I dir].. file.au3
-q : quiet (only error/warn output)
-d : as Opt("MustDeclareVars", 1)
-I dir : additional directories for searching include files
-w 1 : already included file (on)
-w 2 : missing #comments-end (on)
-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)
-v 1 : show include paths/files (off)
-v 2 : show lexer tokens (off)
-v 3 : show unreferenced UDFs and global variables (off)
Exit codes:
0 : success - no errors or warnings
1 : warning(s) only
2 : syntax error(s)
3 : usage or input error我测试过一些例子,也没发现哪里有什么区别 我测试过一些例子,也没发现哪里有什么区别
lynfr8 发表于 2010-7-30 04:25 http://www.autoitx.com/images/common/back.gif
看来就如我说,忽略(不使用的)变量
我一直是这样用的… 强制作为参考参数(即后面跟随的参数只是占个位置,屁用没有) 本帖最后由 C.L 于 2010-7-31 23:56 编辑
回复 4# lynfr8
It tells Au3Check not to report on when a variable isn't used and option -w5 is selected .
正解
下面提供一段代码
#AutoIt3Wrapper_Run_AU3Check=Y
#AutoIt3Wrapper_Au3Check_Parameters = -w 5
hello (2)
Func hello($hello)
;~ #forceref $hello
msgbox(0,"","Hello World!")
EndFunc先将#forceref注释了,将这段代码编译成exe时,au3check 会出现错误提示:
C:\Users\xx\Desktop\test.au3(7,18) : WARNING: $hello: declared, but not used in func.
Func hello($hello)
~~~~~~~~~~~~~~~~~^
而将#forceref $hello的注释去掉,再编译就没有错误出现了。 如果这样说,这个函数基本没啥用啊..... 是给编译器看的 本帖最后由 lchl0588 于 2010-8-1 19:01 编辑
来自某个网页
#Include <GuiListView.au3>
$Form1 = GUICreate("AForm1", 452, 199, 177, 118)
$ListView1 = GUICtrlCreateListView("1|2|3", 10, 10, 431, 156)
$ListView1_0 = GUICtrlCreateListViewItem("1", $ListView1)
$ListView1_1 = GUICtrlCreateListViewItem("item2", $ListView1)
$ListView1_2 = GUICtrlCreateListViewItem("item3", $ListView1)
$ListView1_3 = GUICtrlCreateListViewItem("item4", $ListView1)
$ListView1_4 = GUICtrlCreateListViewItem("item5", $ListView1)
$dd = GUICtrlCreateInput("",10,179)
Global Const $WM_NOTIFY = 0x004E
GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events")
GuiSetState()
Do
Until GUIGetMsg()=-3
Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam)
Const $NM_FIRST = 0
Const $NM_CLICK = ($NM_FIRST - 2)
Const $NM_HOVER = ($NM_FIRST - 13)
#forceref $hWndGUI, $MsgID, $wParam
Local $tagNMHDR, $event, $hwndFrom, $code
$tagNMHDR = DllStructCreate("int;int;int", $lParam) ;NMHDR (hwndFrom, idFrom, code)
If @error Then Return
$event = DllStructGetData($tagNMHDR, 3)
If $event = $NM_CLICK Then
GUICtrlSetData($dd,"鼠标选中:"&_GUICtrlListViewGetItemText($ListView1, _GUICtrlListViewGetSelectedIndices($ListView1)))
EndIf
$tagNMHDR = 0
$event = 0
$lParam = 0
EndFunc
看下25行中!!!
页:
[1]