找回密码
 加入
搜索
查看: 1608|回复: 4

[AU3基础] 双重循环的问题“代码已贴上请指点”(自己已解决了)

[复制链接]
发表于 2012-1-2 19:13:21 | 显示全部楼层 |阅读模式
本帖最后由 lsszmj 于 2012-1-3 11:23 编辑

1.update.ver文件
[HOSTS]
Other=200@http://um10.eset.com/eset_upd/v4/, 200@http://93.184.71.27/eset_upd/v4/, 200@http://um12.eset.com/eset_upd/v4/, 200@http://um13.eset.com/eset_upd/v4/, 200@http://um14.eset.com/eset_upd/v4/, 200@http://62.67.184.68/eset_upd/v4/, 200@http://um16.eset.com/eset_upd/v4/, 200@http://90.183.101.10/eset_upd/v4/, 200@http://um18.eset.com/eset_upd/v4/, 200@http://89.202.149.36/eset_upd/v4/

1051=200@http://um10.eset.com/eset_upd/v4/sky/, 200@http://93.184.71.27/eset_upd/v4/sky/, 200@http://um12.eset.com/eset_upd/v4/sky/, 200@http://um13.eset.com/eset_upd/v4/sky/, 200@http://um14.eset.com/eset_upd/v4/sky/, 200@http://62.67.184.68/eset_upd/v4/sky/, 200@http://um16.eset.com/eset_upd/v4/sky/, 200@http://90.183.101.10/eset_upd/v4/sky/, 200@http://um18.eset.com/eset_upd/v4/sky/, 200@http://89.202.149.36/eset_upd/v4/sky/

Prerelease-other=200@http://um10.eset.com/eset_upd/v4/pre/, 200@http://93.184.71.27/eset_upd/v4/pre/, 200@http://um12.eset.com/eset_upd/v4/pre/, 200@http://um13.eset.com/eset_upd/v4/pre/, 200@http://um14.eset.com/eset_upd/v4/pre/, 200@http://62.67.184.68/eset_upd/v4/pre/, 200@http://um16.eset.com/eset_upd/v4/pre/, 200@http://90.183.101.10/eset_upd/v4/pre/, 200@http://um18.eset.com/eset_upd/v4/pre/, 200@http://89.202.149.36/eset_upd/v4/pre/

BetaV4-other=200@http://um10.eset.com/eset_upd/v4/pre/, 200@http://93.184.71.27/eset_upd/v4/pre/, 200@http://um12.eset.com/eset_upd/v4/pre/, 200@http://um13.eset.com/eset_upd/v4/pre/, 200@http://um14.eset.com/eset_upd/v4/pre/, 200@http://62.67.184.68/eset_upd/v4/pre/, 200@http://um16.eset.com/eset_upd/v4/pre/, 200@http://90.183.101.10/eset_upd/v4/pre/, 200@http://um18.eset.com/eset_upd/v4/pre/, 200@http://89.202.149.36/eset_upd/v4/pre/
BetaV42-other=200@http://um10.eset.com/eset_upd/v4/pre/, 200@http://93.184.71.27/eset_upd/v4/pre/, 200@http://um12.eset.com/eset_upd/v4/pre/, 200@http://um13.eset.com/eset_upd/v4/pre/, 200@http://um14.eset.com/eset_upd/v4/pre/, 200@http://62.67.184.68/eset_upd/v4/pre/, 200@http://um16.eset.com/eset_upd/v4/pre/, 200@http://90.183.101.10/eset_upd/v4/pre/, 200@http://um18.eset.com/eset_upd/v4/pre/, 200@http://89.202.149.36/eset_upd/v4/pre/
BetaV5-other=200@http://um10.eset.com/eset_upd/v5/beta/, 200@http://93.184.71.27/eset_upd/v5/beta/, 200@http://um12.eset.com/eset_upd/v5/beta/, 200@http://um13.eset.com/eset_upd/v5/beta/, 200@http://um14.eset.com/eset_upd/v5/beta/, 200@http://62.67.184.68/eset_upd/v5/beta/, 200@http://um16.eset.com/eset_upd/v5/beta/, 200@http://90.183.101.10/eset_upd/v5/beta/, 200@http://um18.eset.com/eset_upd/v5/beta/, 200@http://89.202.149.36/eset_upd/v5/beta/
2.循环ping[HOSTS]字段中的服务器,我用二重循环。但是只能执行一次循环,第一重第二次时下面代码提示错误
Local $a_Address = StringSplit($var[$i][1], ",")
自己已解决了,具体代码如下:
[hide]

_Ping()
Exit


Func _Ping()
        Local $UpdateDir = @ScriptDir & "\update.ver"
        If Not (FileExists($UpdateDir)) Then Exit;Return -1
        Local $var = IniReadSection($UpdateDir, "HOSTS")
        If @error Then
                MsgBox(4096, "", "错误, 读取INI文件失败.")
        Else
                For $i = 1 To $var[0][0]
                        Local $a_Address = StringSplit($var[$i][1], ",")
                        For $j = 1 To $a_Address[0]
                                Local $k = StringInStr($a_Address[$j], "//")
                                ;MsgBox(4096, "", "//的位置: " & $k , 1)
                                Local $p = StringInStr($a_Address[$j], "/e")
                                ;MsgBox(4096, "", "/e的位置: " & $p , 1)
                                Local $Server = StringMid($a_Address[$j], $k + 2, $p - ($k+2))
                                ;MsgBox(4096, "", "次序: " & $j & @CRLF & "网址: " & $Server, 2)
                                Local $var1 = Ping($Server)
                                If $var1 Then; 还可以:  If @error = 0 Then ...
                                        MsgBox(0, "测试"&$j&"状态-成功", "收发时间间隔:" & $var1 & "毫秒",2)
                                Else
                                        MsgBox(0, "状态-失败", "错误代码:" & @error,2)
                                EndIf
                        Next
                Next
        EndIf
EndFunc   ;==>_Ping
[/hide]
发表于 2012-1-2 20:32:46 | 显示全部楼层
MsgBox前面加上;肯定是不对的,AU3中的;只用于注释...
发表于 2012-1-2 21:02:03 | 显示全部楼层
我这里测试正常。10次可以循环,有两次提示MsgBox(0, "状态-失败", "错误代码:" & @error,2)
是因为PING不通的原因。所以,代码正常。。
 楼主| 发表于 2012-1-3 11:03:14 | 显示全部楼层
本帖最后由 lsszmj 于 2012-1-3 11:13 编辑

回复 3# 半芯蕃茄
问题已解决,变量$var重复了
 楼主| 发表于 2012-1-3 11:26:22 | 显示全部楼层
回复 2# 邪恶海盗
兄弟,谢谢的回答!MsgBox前面加上;,目的是不让MsgBox执行,没有任何问题。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-1 01:19 , Processed in 0.092962 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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