本帖最后由 lynfr8 于 2009-7-10 16:24 编辑
数组的建立有几种方法:
1.Dim 声明再赋值
例子:
Dim$Array1[12]=[3, 7.5, "string"], $array[5] = [8, 4, 5, 9, 1]
Dim $Grid[2][4]=[["Paul", "Jim", "Richard", "Louis"], [485.44, 160.68, 275.16, 320.00]]
Dim $Test[5] = [3, 1, StringSplit("Abe|Jack|Bobby|Marty", "|"), Cos(0)]
或者:Dim $avArray[4]
$avArray[0] = "刘德华"
$avArray[1] = "张学友"
$avArray[2] = "黎明"
$avArray[3] = "郭富城"
2._ArrayCreate也挺方便的 【创建数组UDF函数】#include <Array.au3>
Dim $avArray
$avArray = _ArrayCreate("JPM", "Holger", "Jon", "Larry", "Jeremy", "Valik", "Cyberslug", "Nutster", "Tylo", "JdeB")
_ArrayDisplay( $avArray, "建立数组的udf" )
Exit
数组的数量不是无限的,而是有限制的: 最大64维 和/或 共1600万个元素
至于数组的修改,给个例子借鉴下:#include <Array.au3>
Dim $avArray[4]
$avArray[0] = "刘德华"
$avArray[1] = "张学友"
$avArray[2] = "黎明"
$avArray[3] = "郭富城"
_ArrayDisplay( $avArray, "原来的数组" )
_ArrayDelete( $avArray,1)
_ArrayInsert( $avArray,1,"歌神")
_ArrayDisplay( $avArray, "更新后的数组" )
Exit
把_ArrayDelete、_ArrayInsert
放在循环里面就行了
自己动手研究下,实践过消化掉了才是真正属于自己学到的. |