Sign in to follow this  
Followers 0
hot202

Simple problem edit 2D Array

5 posts in this topic

Hi i cant work this out. Im sure its something really easy that im missing.

If i have a array like this how do i edit

row2 two ["05","e3","68","hh","04","50","02"]

$Arr2d[4][7] = [["01","00","00","00","04","00","01"], _ ; [1]
["02","00","00","00","04","00","02"], _ ; [2]
["03","00","00","00","04","00","03"], _ ; [3]
["04","00","00","00","04","00","04"]]; [4]

Thanks guys

Share this post


Link to post
Share on other sites



#include <Array.au3>

Local $Arr2d[4][7] = [["01", "00", "00", "00", "04", "00", "01"], _ ; [0]
  ["02", "00", "00", "00", "04", "00", "02"], _ ; [1]
  ["03", "00", "00", "00", "04", "00", "03"], _ ; [2]
  ["04", "00", "00", "00", "04", "00", "04"]]; [3]

Local $temp[7] = ["05", "e3", "68", "hh", "04", "50", "02"]

For $i = 0 To 6
 $Arr2d[1][$i] = $temp[$i]
Next


_ArrayDisplay($Arr2d)


Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

thankyou :x

Edit:

i tryed to make it into a Func but it dont seem to work.

#include <Array.au3>

local $Arr2d[4][7] = [["01", "00", "00", "00", "04", "00", "01"], _ ; [0]
  ["02", "00", "00", "00", "04", "00", "02"], _ ; [1]
  ["03", "00", "00", "00", "04", "00", "03"], _ ; [2]
  ["04", "00", "00", "00", "04", "00", "04"]]; [3]
_ArrayDisplay($Arr2d)

_2DArrayEdit($Arr2d,"1","05","e3","68","hh","04","50","02")

Func _2DArrayEdit($aArray,$aLine,$1,$2,$3,$4,$5,$6,$7)
local $temp[7] = [$1,$2,$3,$4,$5,$6,$7]

For $i = 0 To 6
 $aArray[$aLine][$i] = $temp[$i]
Next
Return $aArray
EndFunc

_ArrayDisplay($Arr2d)
Edited by hot202

Share this post


Link to post
Share on other sites

you are returning a new array

#include <Array.au3>

local $Arr2d[4][7] = [["01", "00", "00", "00", "04", "00", "01"], _ ; [0]
  ["02", "00", "00", "00", "04", "00", "02"], _ ; [1]
  ["03", "00", "00", "00", "04", "00", "03"], _ ; [2]
  ["04", "00", "00", "00", "04", "00", "04"]]; [3]
_ArrayDisplay($Arr2d)

$Arr2d = _2DArrayEdit($Arr2d,"1","05","e3","68","hh","04","50","02")

Func _2DArrayEdit($aArray,$aLine,$1,$2,$3,$4,$5,$6,$7)
local $temp[7] = [$1,$2,$3,$4,$5,$6,$7]

For $i = 0 To 6
 $aArray[$aLine][$i] = $temp[$i]
Next
Return $aArray
EndFunc

_ArrayDisplay($Arr2d)

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites

Or you do it ByRef:

#include <Array.au3>

Local $Arr2d[4][7] = [["01", "00", "00", "00", "04", "00", "01"], _ ; [0]
  ["02", "00", "00", "00", "04", "00", "02"], _ ; [1]
  ["03", "00", "00", "00", "04", "00", "03"], _ ; [2]
  ["04", "00", "00", "00", "04", "00", "04"]]; [3]

_ArrayDisplay($Arr2d)
_2DArrayEdit($Arr2d, "1", "05", "e3", "68", "hh", "04", "50", "02")
_ArrayDisplay($Arr2d)


Func _2DArrayEdit(ByRef $aArray, $aLine, $1, $2, $3, $4, $5, $6, $7)
 Local $temp[7] = [$1, $2, $3, $4, $5, $6, $7]

 For $i = 0 To 6
  $aArray[$aLine][$i] = $temp[$i]
 Next
EndFunc   ;==>_2DArrayEdit

Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs, and the Universe
trying to produce bigger and better idiots.
So far, the Universe is winning.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0