kjactive 1 Posted May 5, 2005 I have a litle trouble about multidimentional arrays - I want to make room with a global declare and make the variables later on like this - but get instant error messages... Global $Var[10][7] // every mother variable has a room for 7 sub variables $Var[3][3] = 'King' $Var[3][2] = 'burger' ConsoleWrite($Var[3][2] & ' ' & $var[3][3] & @CR) // would be 'Burger King' Is this posible in AutoIt3 or how do I do Multi arrays in autoit... Is there a Dr. Watson around - Please responce.... Kjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc... Share this post Link to post Share on other sites
scriptkitty 1 Posted May 5, 2005 (edited) Maybe this can explain it: dim $var[2][3]; multi dimentional for $x= 0 to 1; $x has 2 elements, 0 and 1 for $y=0 to 2; $y has [3] elements, 0,1,2 $var[$x][$y]=$x & "," & $y & @crlf &"this is the information" ; I placed the values in each Next Next msgbox(1,"data is in","") ; replace a few values $Var[0][0] = 'King' $Var[1][1] = 'burger' for $x= 0 to 1 for $y=0 to 2 msgbox(1,"data var[" & $x & "][" & $y&"]",$var[$x][$y]) Next Next msgbox(1,"your output",$Var[1][1] & ' ' & $var[0][0] & @CR) Edited May 5, 2005 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Share this post Link to post Share on other sites
SvenP 0 Posted May 5, 2005 I have a litle trouble about multidimentional arrays - I want to make room with a global declare and make the variables later on like this - but get instant error messages...Global $Var[10][7] // every mother variable has a room for 7 sub variables$Var[3][3] = 'King'$Var[3][2] = 'burger'ConsoleWrite($Var[3][2] & ' ' & $var[3][3] & @CR) // would be 'Burger King'Is this posible in AutoIt3 or how do I do Multi arrays in autoit...Is there a Dr. Watson around - Please responce....Kjactive <{POST_SNAPBACK}>What kind of error message do you get? When I run your code (only replacing the // by ; !!) it shows me the expected message 'burger King' . No error message at all.Regards,-Sven Share this post Link to post Share on other sites
kjactive 1 Posted May 6, 2005 (edited) Well this was an example script to get it right - the trouble come when I want to dynamic create multidimentional variables as this... Global $tre[99][7] ; does this mean that there are 99 main entries and every main has 7 sub - this do not produce an error but I can't make it work later in the script that is rather large to include here... $tre[$a] = MakeTree() // example BUT this line don't get it right!!!!! ;================================================================== ;MakeTree: Make the internal tree structure and return the value ;================================================================== Func MakeTree() // just example function Return _ArrayCreate(_Word($tmp[1],1), $tmp[3], $tmp[4], $tmp[5], $tmp[6], $style, $extend, StringReplace(StringMid($tmp[1],10),'"','')) EndFunc Is there aDr. Watson around as to explane me about why this won't work, what am I doing wrong... Kjactive Edited May 6, 2005 by kjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc... Share this post Link to post Share on other sites
scriptkitty 1 Posted May 6, 2005 (edited) well for startersFunc MakeTree(); (use; not //) just example function Return _ArrayCreate(_Word($tmp[1],1), $tmp[3], $tmp[4], $tmp[5], $tmp[6], $style, $extend, StringReplace(StringMid($tmp[1],10),'"','')) EndFuncReturn will return you imediately to where you called the function, and set that variable to the result you gave it.so look at this:$x=myfunc(); $x will always be 1 func myfunc() return 1 $x=979873454345 endfuncGlobal $tre[99][7] ; does this mean that there are 99 main entries and every main has 7 subYes, so you will have $tre[0][0] to $tre[98][6] that is 99 with each having 7 subs$tre[0][0]$tre[0][1]$tre[0][2].....$tre[98][0]$tre[98][1]$tre[98][2]$tre[98][3]$tre[98][4]$tre[98][5]$tre[98][6]Now for a big thing, you have to call out arrays as multidimentional if they are.$tre[$a] is a single dimention variable$tre[$a][0] is a multi dimention variable.Bad code:Dim $var[99][7] $var[11]=5Has to be:Dim $var[99][7] $var[11][0]=5 $var[11][1]=5 $var[11][2]=5 $var[11][3]=7 Edited May 6, 2005 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Share this post Link to post Share on other sites
kjactive 1 Posted May 6, 2005 Thanks - Okay I have to declare all, one by one but do they have to be initiated with a value at the declare... kjactive Au3PP 4.1 - Autoit3 preprocessor, optimize speed, performance to scripts and do executes....[/url]Au3Calibur - Create libraries of commonly used code excerptsWords manipulate UDF, functions that is lent from the rexx language, topics and index file includedCustomDialog UDF to include custom made dialogs like a extended colorpick requester to scripts...[url="ftp://fritidshjemmet.com/Autoit3/SysColor.zip"]SysColor UDF a low level color library to manipulate RGB and Hex values...Shell32 UDF to Automate Windows® operating tasks from native dialog and Wizards browsers... Optimized the CodeWicard with options to generate browser code etc... Share this post Link to post Share on other sites
Nutster 3 Posted May 10, 2005 I have submitted an ability to do a multi-dimensional array initialization to JP. Check out the next beta release. David NuttallNuttall Computer ConsultingAn Aquarius born during the Age of AquariusAutoIt allows me to re-invent the wheel so much faster.I'm off to write a wizard, a wonderful wizard of odd... Share this post Link to post Share on other sites