McGod Posted July 8, 2007 Share Posted July 8, 2007 I have a 2d array for a map I want to quickly fill the array with data, below is what I tried with no success. Is there anyway of doing this without having to do $Map[0][0] = "x" $Map[0][1] = "x" etc.. Global $Map1[31][35] $Map1[0] = [ "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x" ] [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
Siao Posted July 8, 2007 Share Posted July 8, 2007 Might want to take a look at this topic:http://www.autoitscript.com/forum/index.ph...c=48964&hl= "be smart, drink your wine" Link to comment Share on other sites More sharing options...
McGod Posted July 8, 2007 Author Share Posted July 8, 2007 I made a quick handy function that does the job, it will use a seperator and split x|x|x|x|x|x|x|x into an 1d array then reDim the array and stick it in there. ;~ Global $Map1[31][35] Global $Map1[1][35] ;~ $Map1[0] = [ "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x", "x" ] $Map1 = _Array2DAddRow($Map1, "x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x|x", "|") _Array2D($Map1) Func _Array2DAddRow($Arr, $row, $seperator='') Local $rows = StringSplit($row, $seperator) If UBound($Arr, 2) <= $rows[0] Then ReDim $Arr[UBound($Arr,1)+1][$rows[0]] Else ReDim $Arr[UBound($Arr,1)+1][UBound($Arr,2)] EndIf $d = UBound($Arr,1)-2 For $i = 0 To $rows[0] -1 Step 1 $Arr[$d][$i] = $rows[$i+1] Next Return $Arr EndFunc Func _Array2d ($array, $title="Title") If IsArray ( $array ) = 0 Then Return 0 Local $Buffer For $i = 0 To UBound ( $array, 1) -1 Step 1 For $a = 0 To UBound ( $array, 2) -1 Step 1 $Buffer &= "[" & $i & "][" & $a & "] = " & $array[$i][$a] & @CRLF Next Next MsgBox ( 1, "Title", $Buffer ) EndFunc [indent][center][u]Formerly Chip[/u][/center]~UDFs~[/indent][u]IRC.au3 - Allows you to connect to IRC ServersINetCon.au3 - Connects/Disconnects/Check Status of InternetHardware Key - Creates a unique hardware hashScriptComm - Allows you to communicate between scripts using WM_COPYDATA[/u][indent]~Programs~[/indent][indent]SimonAu3ForumsIRC Bot~Web Site~Web Autoit Example[/indent][indent][b][/b][/indent][u][/u] Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now