找回密码
 加入
搜索
查看: 2817|回复: 3

[AU3基础] 求助;子脚本使用了非数组变量 错误,

  [复制链接]
发表于 2011-6-25 13:40:11 | 显示全部楼层 |阅读模式
求助;子脚本使用了非数组变量 错误
第一次执行就出 子脚本使用了非数组变量 错误,但是第2次运行就不提示了啊,可以正常运行啊

附代码

Dim $randoms, $asResult

Randomd()

Func Randomd()
        InetGet("http://tv.tudou.com/albumtop/top/listRank.html?cid=30&type=0", @TempDir & "\2.html", 1, 1)
        $sString = FileRead(@TempDir & "\2.html")
        $sRegExp = 'target="new">[^<]+</a></div></td>'
        $asResult = StringRegExp($sString, $sRegExp, 3)
        For $i = 0 To UBound($asResult) - 1 Step 1
                $asResult[$i] = StringMid($asResult[$i], StringInStr($asResult[$i], '>') + 1, StringInStr($asResult[$i], '<') - StringInStr($asResult[$i], '>') - 1)
        Next
        $randoms = Random(1, UBound($asResult), 1)
        ;MsgBox(4096, "Program files are in:", $asResult[$randoms])
EndFunc   ;==>Randomd


请哪位大大帮助我看看是怎么回事啊!!
发表于 2011-6-25 14:06:13 | 显示全部楼层
当$asResult不是数组(没有匹配到符合正则的字符串)时就会出现这样的情况,加个If IsArray($asResult) Then来判断下呗
Dim $randoms, $asResult

Randomd()

Func Randomd()
        InetGet("http://tv.tudou.com/albumtop/top/listRank.html?cid=30&type=0", @TempDir & "\2.html", 1, 1)
        $sString = FileRead(@TempDir & "\2.html")
        $sRegExp = 'target="new">[^<]+</a></div></td>'
        $asResult = StringRegExp($sString, $sRegExp, 3)
                If IsArray($asResult) Then
                        For $i = 0 To UBound($asResult) - 1 Step 1
                $asResult[$i] = StringMid($asResult[$i], StringInStr($asResult[$i], '>') + 1, StringInStr($asResult[$i], '<') - StringInStr($asResult[$i], '>') - 1)
            Next
            $randoms = Random(1, UBound($asResult), 1)
                EndIf
        ;MsgBox(4096, "Program files are in:", $asResult[$randoms])
EndFunc   ;==>Randomd
 楼主| 发表于 2011-6-25 15:39:45 | 显示全部楼层
不行啊!!!还是不行啊!!!!!
子脚本使用了非数组变量 错误
发表于 2011-6-27 16:45:19 | 显示全部楼层
InetGet("http://tv.tudou.com/albumtop/top/listRank.html?cid=30&type=0", @TempDir & "\2.html", 1, 1)
这里如果你网不够快的后面的代码会因为文件没下完要出错
改成
InetGet("http://tv.tudou.com/albumtop/top/listRank.html?cid=30&type=0", @TempDir & "\2.html", 1, 0)
试下
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-9-21 04:38 , Processed in 0.090693 second(s), 21 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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