找回密码
 加入
搜索
查看: 4830|回复: 11

[AU3基础] (已解决)关于“=”号前的“&”符的意思 求问

  [复制链接]
发表于 2010-7-22 22:02:48 | 显示全部楼层 |阅读模式
本帖最后由 jinyue115 于 2010-8-9 10:37 编辑
Opt('MustDeclareVars', 1)

Example1()
Example2()

; example1
Func Example1()
; Sample script with three user-defined functions
; Notice the use of variables, ByRef, and Return

Local $foo = 2
Local $bar = 5
msgBox(0,"Today is " & today(), "$foo equals " & $foo)
swap($foo, $bar)
msgBox(0,"After swapping $foo and $bar", "$foo now contains " & $foo)
msgBox(0,"Finally", "The larger of 3 and 4 is " & max(3,4))
EndFunc   ;==>Example1

Func swap(ByRef $a, ByRef $b)  ;swap the contents of two variables
        Local $t
        $t = $a
        $a = $b
        $b = $t
EndFunc

Func today()  ;Return the current date in mm/dd/yyyy form
        return (@MON & "/" & @MDAY & "/" & @YEAR)
EndFunc

Func max($x, $y)  ;Return the larger of two numbers
        If $x > $y Then
                return $x
        Else
                return $y
        EndIf
EndFunc

;End of sample script 1

; example2
Func Example2()
; Sample scriptusing @NumParams macro
        Test_Numparams(1,2,3,4,5,6,7,8,9,10,11,12,13,14)
EndFunc   ;==>Example2

Func Test_Numparams($v1 = 0, $v2 = 0, $v3 = 0, $v4 = 0, $v5 = 0, $v6 = 0, $v7 = 0, $v8 = 0, $v9 = 0, _
        $v10 = 0, $v11 = 0, $v12 = 0, $v13 = 0, $v14 = 0, $v15 = 0, $v16 = 0, $v17 = 0, $v18 = 0, $v19 = 0)
        Local $val
        For $i = 1 To @NumParams
                $val &= Eval("v" & $i) & " "
        Next
        MsgBox(0, "@NumParams example", "@NumParams =" & @NumParams & @CRLF & @CRLF & $val)
EndFunc
 
;End of sample script 2
 
 楼主| 发表于 2010-7-22 22:03:51 | 显示全部楼层
关于第50行的$val &= Eval("v" & $i) & " "
疑问
求大侠给个解释 谢谢
发表于 2010-7-22 23:29:54 | 显示全部楼层
&= 意思是 连接后面的字符串

$a = '我'
$b = '们'
$a &= $b ;$a 现在的值为 '我们'
发表于 2010-7-23 08:45:56 | 显示全部楼层
$a &= $b 等同于 $a = $a & $b
我是这么理解的
 楼主| 发表于 2010-7-23 11:34:18 | 显示全部楼层
奥 明白了  谢谢楼上的俩位
我原来只知道$a+=1 是$a=$a+1的意思
现在知道了 连接符合也可以这样用
不知道还有没有这样的了
发表于 2010-7-23 11:56:28 | 显示全部楼层
奥 明白了  谢谢楼上的俩位
我原来只知道$a+=1 是$a=$a+1的意思
现在知道了 连接符合也可以这样用
不知 ...
jinyue115 发表于 2010-7-23 11:34

http://www.autoitx.com/Doc/html/intro/lang_operators.htm
发表于 2010-7-23 12:13:38 | 显示全部楼层
本帖最后由 netegg 于 2010-7-23 12:16 编辑

$a+=$b大概意思是$a累加$b。。。。
$a&=$b相当于类似意思的字符串操作
 楼主| 发表于 2010-7-25 00:09:29 | 显示全部楼层
Thanks for your replies !
发表于 2010-7-28 00:34:33 | 显示全部楼层
路过,学了一招
发表于 2010-7-29 13:41:44 | 显示全部楼层
似懂非懂
发表于 2010-7-29 22:02:05 | 显示全部楼层
学习哈
 楼主| 发表于 2011-4-20 10:30:49 | 显示全部楼层
感谢各位了
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-2 08:38 , Processed in 0.088648 second(s), 20 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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