niubbone Posted June 1, 2010 Share Posted June 1, 2010 Can a Multidimensional array be with different sizes? It's possible to declare them? Like this: $s[1][2]=[1,2] $s[2][3]=[3,4,5] instead of the usual $s[2][3] with 2 rows of 3 elements? Link to comment Share on other sites More sharing options...
jaberwacky Posted June 1, 2010 Share Posted June 1, 2010 (edited) Your syntax is wrong... $s[2][3] = [[1,2],[3,4,5]] // then you can redim it like this redim $s[2][2] Edited June 1, 2010 by jaberwocky6669 Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
MHz Posted June 1, 2010 Share Posted June 1, 2010 Your syntax is wrong... $s[2][3] = [[1,2],[3,4,5]] // then you can redim it like this redim $s[2][2] Pist...Use a declaration keyword to declare an array else you may get a syntax error. Link to comment Share on other sites More sharing options...
Ascend4nt Posted June 1, 2010 Share Posted June 1, 2010 niubbone, you can only have one size at any given time , though you can redim it to fit more or less elements. However, if you absolutely need to have varying dimensions, you can put arrays inside an array, though you have to ask yourself if its worth it or if you can think of a better way. My contributions: Performance Counters in Windows - Measure CPU, Disk, Network etc Performance | Network Interface Info, Statistics, and Traffic | CPU Multi-Processor Usage w/o Performance Counters | Disk and Device Read/Write Statistics | Atom Table Functions | Process, Thread, & DLL Functions UDFs |Â Process CPU Usage Trackers | PE File Overlay Extraction | A3X Script Extract | File + Process Imports/Exports Information | Windows Desktop Dimmer Shade | Spotlight + Focus GUI - Highlight and Dim for Eyestrain Relief | CrossHairs (FullScreen) |Â Rubber-Band Boxes using GUI's (_GUIBox) | GUI Fun! | IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) | Magnifier (Vista+) Functions UDF | _DLLStructDisplay (Debug!) | _EnumChildWindows (controls etc) | _FileFindEx | _ClipGetHTML | _ClipPutHTML + ClipPutHyperlink | _FileGetShortcutEx | _FilePropertiesDialog | I/O Port Functions | File(s) Drag & Drop | _RunWithReducedPrivileges | _ShellExecuteWithReducedPrivileges | _WinAPI_GetSystemInfo | dotNETGetVersions | Drive(s) Power Status | _WinGetDesktopHandle | _StringParseParameters | Screensaver, Sleep, Desktop Lock Disable | Full-Screen Crash Recovery Wrappers/Modifications of others' contributions: _DOSWildcardsToPCRegEx (original code: RobSaunder's) | WinGetAltTabWinList (original: Authenticity) UDF's added support/programming to: _ExplorerWinGetSelectedItems | MIDIEx UDF (original code: eynstyne) (All personal code/wrappers centrally located at Ascend4nt's AutoIT Code) Link to comment Share on other sites More sharing options...
niubbone Posted June 1, 2010 Author Share Posted June 1, 2010 (edited) Thanks to all. Well, the redim may be what i was looking for. Don't worry about all the syntax errors, I know them and by the way the error check won't let me run the script if there are any It was just to make the situation more clear. Anyway, I need that 2d array because of this function (which I still need to work because it's not working properly): #include <array.au3> $Multi=ColloquioDomande() _ArrayDisplay($Multi,"PORCO") Func ColloquioDomande() Local $Domande[5]=["doma","domb","domc","domd","dome"] Local $Risposte[20]=["a","b","c","d","a1","b1","c1","d1","a2","b2","c2","d2","a3","b3","c3","d3","a4","b4","c4","d4"] Local $DomandeDifferenti[4] Local $RisposteMischiate[4] For $z=1 to 4 Local $GiroDomande=Random(1,Ubound($Domande)-1,1) $DomandeDifferenti[$z-1]=$Domande[$GiroDomande] _ArrayDelete($Domande,$GiroDomande) Select Case $GiroDomande=0 Local $Risp1=$Risposte[0],$Risp2=$Risposte[1],$Risp3=$Risposte[2],$Risp4=$Risposte[3] Case $GiroDomande=1 Local $Risp1=$Risposte[4],$Risp2=$Risposte[5],$Risp3=$Risposte[6],$Risp4=$Risposte[7] Case $GiroDomande=2 Local $Risp1=$Risposte[8],$Risp2=$Risposte[9],$Risp3=$Risposte[10],$Risp4=$Risposte[11] Case $GiroDomande=3 Local $Risp1=$Risposte[12],$Risp2=$Risposte[13],$Risp3=$Risposte[14],$Risp4=$Risposte[15] Case $GiroDomande=4 Local $Risp1=$Risposte[16],$Risp2=$Risposte[17],$Risp3=$Risposte[18],$Risp4=$Risposte[19] EndSelect Local $RisposteInOrdine[4]=[$Risp1,$Risp2,$Risp3,$Risp4] For $i=1 to 4 Local $GiroRispInOrdine=Random(1,Ubound($RisposteInOrdine)-1,1) $RisposteMischiate[$i-1]=$RisposteInOrdine[$GiroRispInOrdine] _ArrayDelete($RisposteInOrdine,$GiroRispInOrdine) Next Next Local $MultiDomERisp[2][16]=[[$DomandeDifferenti[0],$DomandeDifferenti[1],$DomandeDifferenti[2],$DomandeDifferenti[3]], _ [$RisposteMischiate[0],$RisposteMischiate[1],$RisposteMischiate[2],$RisposteMischiate[3]]] Return $MultiDomERisp EndFunc Quick Explanation: This program should extract from 2 arrays given a question and 4 answers for each question, always checking that the previous question and answer have not been already extracted amd, to scramble the answers everytime to put them in a different order. Questions are $Domande and answers are $Risposte. The results are given into 2 arrays which, as far as i know, cannot be returned with a single Return at the end of the functionm therefore i have to store them in a multidimensional array and make a return whichi gives the multidimensional array as result of the function. That's why i need it. But if you know a better solution i'm all ears. Thanks Edited June 1, 2010 by niubbone Link to comment Share on other sites More sharing options...
jaberwacky Posted June 1, 2010 Share Posted June 1, 2010 Pist...Use a declaration keyword to declare an array else you may get a syntax error. goodness me oh my... Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? 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