Jump to content
Sign in to follow this  
KyleC

2dimensional array issues

Recommended Posts

KyleC

need help with this. can't seem to get my 2 dimensional arrya to work right.

#include <File.au3>
#include<string.au3>
#include<Array.au3>

dim $rec[21]
dim $table[21]
$i = 1
$j = 0
$rec = _StringExplode("13221    12/6/2010 0:00:00   ANDREW  ZWERNEMANN  ANN ZWERNEMANN      262 NORMAN DR   RAMSEY  NJ  07446-2615  (201) 934-8411  6   11  11  1110    31      A       ANNZMOM@VERIZON.NET ",chr(09))
$table[0] = $rec
ConsoleWrite("table contains  ;  " & $table[0][0] & @CRLF)

Gives this error:

C:\Documents and Settings\kylec\Desktop\AutoIt\Scratch\array.au3 (11) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

ConsoleWrite("table contains ; " & $table[0][0] & @CRLF)

ConsoleWrite("table contains ; " & ^ ERROR

Share this post


Link to post
Share on other sites
iamtheky

Think this might be closer to what you were after. It was not delimiting the string by horizontal tab, so i rigged it. Im sure there is a cleaner way.

#include <File.au3>
#include<string.au3>
#include<Array.au3>

Dim $rec , $table

$rec = _StringExplode("13221    12/6/2010 0:00:00   ANDREW  ZWERNEMANN  ANN ZWERNEMANN      262 NORMAN DR   RAMSEY  NJ  07446-2615  (201) 934-8411  6   11  11  1110    31      A       ANNZMOM@VERIZON.NET ", " ")

$blanks = _ArrayFindAll ($rec , "")

for $i = ubound ($blanks) - 1 to 0 step -1
    _ArrayDelete ($rec , $blanks[$i])
Next

_ArrayDisplay ($rec , "REC")

$table = $rec

_ArrayDisplay ($table, "TABLE")
Edited by iamtheky

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

Share this post


Link to post
Share on other sites
PsaltyDS

Storing an array as an element in another array does not make it a 2D array. The term of art would be a "nested array".

You would have to copy the array back out of $table[0] to its own variable to reference the data, which would still be a 1D array.

:huh2:


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.