找回密码
 加入
搜索
查看: 4485|回复: 9

[AU3基础] [已解决],#forceref的含义

  [复制链接]
发表于 2010-7-29 20:59:07 | 显示全部楼层 |阅读模式
本帖最后由 529304mnm 于 2010-8-3 21:19 编辑

如题,论坛上有人问但是没有解决。大侠们帮忙啊!
发表于 2010-7-29 21:19:24 | 显示全部楼层
同问,一直没搞懂#forceref有何意义。
或者只是如;注释符号、#Engion那样,仅起到一个注释的作用?~
发表于 2010-7-29 23:52:56 | 显示全部楼层
要忽略的参数吧,猜的
发表于 2010-7-30 04:25:41 | 显示全部楼层
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
我测试过一些例子,也没发现哪里有什么区别
发表于 2010-7-31 21:15:29 | 显示全部楼层
我测试过一些例子,也没发现哪里有什么区别
lynfr8 发表于 2010-7-30 04:25



    看来就如我说,忽略(不使用的)变量
我一直是这样用的…
发表于 2010-7-31 21:37:49 | 显示全部楼层
强制作为参考参数(即后面跟随的参数只是占个位置,屁用没有)
发表于 2010-7-31 23:48:03 | 显示全部楼层
本帖最后由 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的注释去掉,再编译就没有错误出现了。

评分

参与人数 1贡献 +5 收起 理由
lynfr8 + 5

查看全部评分

发表于 2010-8-1 03:05:41 | 显示全部楼层
如果这样说,这个函数基本没啥用啊.....
发表于 2010-8-1 03:29:24 | 显示全部楼层
是给编译器看的
发表于 2010-8-1 08:38:11 | 显示全部楼层
本帖最后由 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行中!!!
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-23 11:13 , Processed in 0.086572 second(s), 27 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表