Sign in to follow this  
Followers 0
bald1

Two dimensional arrays and data assigning

5 posts in this topic

Hey, quick question!

Is it impossible to assign data to two dimensional arrays on more than one line?

Like so:

global $f00[4][3] = [[1,2,5],[2,4,3],[3,3,6],[2,6,2]]

As opposed to:

global $f00[4][3]
$f00[0][3] = [...]
$f00[1][3]
$f00[2]..
$f00[3]... something like this, tried a few different ways of doing it..

It errors out with syntax error when i do the latter. Im aware it might be a "bracket order error". Havent been able to find any example of this usage to verify. It's not a huge problem to use the "all on one line solution", however, it'd be easier for readability and to use ";" after each array data block to keep track of their data contents type :D

Thanks in advance!

Share this post


Link to post
Share on other sites



Is it impossible to assign data to two dimensional arrays on more than one line?

Like so:

global $f00[4][3] = [[1,2,5],[2,4,3],[3,3,6],[2,6,2]]

Use line continuation, a blank followed by an underscore.

global $f00[4][3] = [ _
  [1,2,5], _
  [2,4,3], _
  [3,3,6], _
  ['you can have', _
   'many, many', _
   'lines'] _
]

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Share this post


Link to post
Share on other sites

global $f00[4][3] = [[1,2,5], _
[2,4,3],[3,3,6], _ 
[2,6,2]]

A _ symbol means the interpreter should continue on the next line as if it were the current line... Or something.

Share this post


Link to post
Share on other sites

THanks for your fast replies :D

Share this post


Link to post
Share on other sites

you should be able to use your latter method aswell, if I am understanding the question correctly.

When u first declare an array as $array[3] you need to keep in mind when later calling it the enumeration starts at 0 not 1 so...

;This will Work
global $f00[4][3]
$f00[0][0] = '1 of 3'
$f00[0][1] = '2 of 3'
$f00[0][2] = '3 of 3'
MsgBox(0,'',$f00[0][2])

;This will ERROR out
global $f00[4][3]
$f00[0][1] = '1 of 3'
$f00[0][2] = '2 of 3'
$f00[0][3] = '3 of 3'
MsgBox(0,'',$f00[0][3])

There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly

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