找回密码
 加入
搜索
楼主: haebong87

[AU3基础] [已解决] 求关注!提示下标用于非数组变量,该怎么解决。

 火.. [复制链接]
 楼主| 发表于 2011-7-14 11:51:26 | 显示全部楼层
顶上去。
Subscript used with non-Array variable.:
$result = StringCompare($nums[1],$nums1[1])
$result = StringCompare($nums[1],$nums1^ ERROR
>Exit code: 1    Time: 2.108

提示这个,能帮忙解决一下吗?
发表于 2011-7-14 12:20:59 | 显示全部楼层
num1非数组变量
 楼主| 发表于 2011-7-14 12:52:53 | 显示全部楼层
回复 32# netegg


    那应该怎么改呢?
发表于 2011-7-14 13:15:01 | 显示全部楼层
回复 33# haebong87
#include <array.au3>

$txt="苹果|1|2|"&@CRLF _
&"西瓜|1|3|"&@CRLF _
&"香蕉|2|4|"

;====将字符串定义成多维数组====
Local $arr_master=StringSplit($txt,@CRLF,2+1)
If @error Then Exit
Local $cols=StringSplit(StringTrimRight($arr_master[0],1),"|",2)
$cols=UBound($cols)
Local $array[UBound($arr_master)][$cols]
for $i=0 to UBound($arr_master)-1
        $temp=StringSplit(StringTrimRight($arr_master[$i],1),"|",2)
        for $n=0 to UBound($temp)-1
                $array[$i][$n]=$temp[$n]
        Next
Next
_ArrayDisplay($array)
;====定义数组结束====

;====判断====
for $i=0 to UBound($array)-2
        for $n=0 to UBound($array,2)-1
                if $array[$i][$n]=$array[$i+1][$n] then 
                        msgbox(0x40000,"",$array[$i][$n]&" = " & $array[$i+1][$n])
                Else
                        msgbox(0x40000,"",$array[$i][$n]&ChrW(8800) & $array[$i+1][$n])
                EndIf
        Next
Next
 楼主| 发表于 2011-7-14 13:17:31 | 显示全部楼层
回复 34# 3mile


    非常感谢!!!
 楼主| 发表于 2011-7-14 13:54:10 | 显示全部楼层
本帖最后由 haebong87 于 2011-7-14 15:02 编辑

能解释一下为什么用StringTrimRight吗?是要除掉回车吗? 还有我之前写的哪里为什么出错能解释一下吗?
 楼主| 发表于 2011-7-14 14:36:18 | 显示全部楼层
大哥,你弄的这个有些复杂啊,第一个西瓜和苹果不应该比较才对。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-10-1 23:32 , Processed in 0.091425 second(s), 14 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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