aslani Posted December 5, 2007 Share Posted December 5, 2007 I can do 2D arrays without a sweat, but 3D arrays gets me all tangled up. Here's the situation (yes, I used the search feature and found nothing that can help me); I have a list of assemblies with proposed changes and this is how they are currently layed out. Local $assy_Number[2] = ["1234567001", "1234567002"] ; can be more Local $assy_Action[3] = ["A", "D", "C"] Local $assy_Details[6] = ["item", "p/n", "from", "to", "title", "ref des"]oÝ÷ ØÚ0y§!j˹réz¸Z³v¶*'±©ìy§!iËb¢xZ±×j)l6Á©í¶æ§jºÚÊØZµÆ§²í¶¬¢ëLÊÇ+pYiºYm欱é)î·««Zµ§-çyçl¶ZêeiÇÜ!Èij»lj·}÷µçDÅ©©ívßzïM5×bµé§ºfÞ¯]ij»gºfÞ¯]·ã»×M_®ª·--¢«r×tì,P5Ü7¥z×¢µé§ºfÞ¯]ij»gºfÞ¯]·ã»×M_®ª·-w¶ËDì,P5Ü(Z¢µé§ºfÞ¯]ij»gºfÞ¯]·ã»×M_®ª·-w¶Ë]r·°° @×MvßzïM6×bµé§ºfÞ¯]ij»gºfÞ¯]·ã»ÛM_®ª·--¢«r×tì,P5Ü7¥z×¢µé§ºfÞ¯]ij»gºfÞ¯]·ã»ÛM_®ª·-w¶ËDì,P5Ü(Z¢µé§ºfÞ¯]ij»gºfÞ¯]·ã»ÛM_®ª·-w¶Ë]r·°° @×E¢¶aDZjjexý¨¦x¢¶§jºÚÊX¤zØb±«¢+Ù¥´ÀÌØíÍÍå}±µ¹ÑÍlÀÌØíulÀÌØíulÀÌØít As it turns out, that's wrong. Now I'm stuck. I'm all confused, my head hurts. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
Fossil Rock Posted December 5, 2007 Share Posted December 5, 2007 Do you have a working script for the input yet? Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
weaponx Posted December 5, 2007 Share Posted December 5, 2007 I might be way off base here... expandcollapse popupDim $assy_Elements[2][4][7] $assy_Elements[0][0][0] = "1234567001" $assy_Elements[0][1][0] = "A" $assy_Elements[0][1][1] = "item" $assy_Elements[0][1][2] = "p/n" $assy_Elements[0][1][3] = "from" $assy_Elements[0][1][4] = "to" $assy_Elements[0][1][5] = "title" $assy_Elements[0][1][6] = "ref des" $assy_Elements[0][2][0] = "D" $assy_Elements[0][2][1] = "item" $assy_Elements[0][2][2] = "p/n" $assy_Elements[0][2][3] = "from" $assy_Elements[0][2][4] = "to" $assy_Elements[0][2][5] = "title" $assy_Elements[0][2][6] = "ref des" $assy_Elements[0][3][0] = "C" $assy_Elements[0][3][1] = "item" $assy_Elements[0][3][2] = "p/n" $assy_Elements[0][3][3] = "from" $assy_Elements[0][3][4] = "to" $assy_Elements[0][3][5] = "title" $assy_Elements[0][3][6] = "ref des" $assy_Elements[1][0][0] = "1234567002" $assy_Elements[1][1][0] = "A" $assy_Elements[1][1][1] = "item" $assy_Elements[1][1][2] = "p/n" $assy_Elements[1][1][3] = "from" $assy_Elements[1][1][4] = "to" $assy_Elements[1][1][5] = "title" $assy_Elements[1][1][6] = "ref des" $assy_Elements[1][2][0] = "D" $assy_Elements[1][2][1] = "item" $assy_Elements[1][2][2] = "p/n" $assy_Elements[1][2][3] = "from" $assy_Elements[1][2][4] = "to" $assy_Elements[1][2][5] = "title" $assy_Elements[1][2][6] = "ref des" $assy_Elements[1][3][0] = "C" $assy_Elements[1][3][1] = "item" $assy_Elements[1][3][2] = "p/n" $assy_Elements[1][3][3] = "from" $assy_Elements[1][3][4] = "to" $assy_Elements[1][3][5] = "title" $assy_Elements[1][3][6] = "ref des" $string = "" For $X = 0 to Ubound($assy_Elements, 1) - 1 $string &= $assy_Elements[$X][0][0] & @CRLF For $Y = 1 to Ubound($assy_Elements, 2) - 1 $string &= @TAB & $assy_Elements[$X][$Y][0] & @CRLF For $Z = 1 to Ubound($assy_Elements, 3) - 1 $string &= @TAB & @TAB & $assy_Elements[$X][$Y][$Z] & @CRLF Next Next Next MsgBox(0,"",$string)oÝ÷ ØZ½çèºwm«l¢gg¬ºw¬µç¹ªëk+j|(®J.µ·µêۺܨºf²mì(®H§¶«vÄá{'©l¡·jÌ¢·vnëZ¥¨§¶Þiاjëh×6Local $assy_Elements[2][2] = [["1234567001", ""], ["1234567002", ""]] ; can be more Local $assy_Action[3][2] = [["A",""], ["D",""], ["C",""]] Local $assy_Details[6] = ["item", "p/n", "from", "to", "title", "ref des"] $assy_Action[0][1] = $assy_Details $assy_Action[1][1] = $assy_Details $assy_Action[2][1] = $assy_Details $assy_Elements[0][1] = $assy_Action $assy_Elements[1][1] = $assy_Action MsgBox(0,"",debugNested($assy_Elements)) ;Recursive 3 dimensional Array Display Func debugNested($theArray, $level = 0) $string = "" Local $tabString = "" For $X = 0 to $level - 1 $tabString &= @TAB Next For $X = 0 to Ubound($theArray, 1) - 1 ;If nested array is more than one dimension If Ubound($theArray, 0) > 1 Then $string &= $tabString & $theArray[$X][0] & @CRLF If IsArray($theArray[$X][1]) Then $string &= debugNested($theArray[$X][1], $level + 1) & @CRLF EndIf Else $string &= $tabString & $theArray[$X] & @CRLF EndIf Next Return $string EndFunc Link to comment Share on other sites More sharing options...
randallc Posted December 5, 2007 Share Posted December 5, 2007 As it turns out, that's wrong. Now I'm stuck. I'm all confused, my head hurts. Hi,I think that is correct, but you may just be reading it incorrectly; show the script which made you think it was wrong!Best, randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 5, 2007 Share Posted December 5, 2007 Dim $assy_Elements[$a][$b][$c] As it turns out, that's wrong. Now I'm stuck. I'm all confused, my head hurts. How did that turn out wrong? You didn't say what was wrong about it. The only problem you have with those numbers is that AutoIt array are always 0-based, so when you declare with exactly the number of elements you need, they will be numbered 0 thru n-1. If you declare the array with [2][3][6], therefore the first element in the array is [0][0][0] and the last is [1][2][5]. 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 Link to comment Share on other sites More sharing options...
aslani Posted December 5, 2007 Author Share Posted December 5, 2007 I think weaponX sorted out my problem, I'll run that setup and give you a feedback later on. How did that turn out wrong? You didn't say what was wrong about it. The only problem you have with those numbers is that AutoIt array are always 0-based, so when you declare with exactly the number of elements you need, they will be numbered 0 thru n-1. If you declare the array with [2][3][6], therefore the first element in the array is [0][0][0] and the last is [1][2][5]. Yes that's what I have in mind. But my confusion starts on what value goes in other elements other than [0][0][0]. Let me used weaponX's example; $assy_Elements[0][0][0] = "1234567001" $assy_Elements[0][1][0] = "A" $assy_Elements[0][1][1] = "item" $assy_Elements[0][1][2] = "p/n" $assy_Elements[0][1][3] = "from" $assy_Elements[0][1][4] = "to" $assy_Elements[0][1][5] = "title" $assy_Elements[0][1][6] = "ref des" His example made it more sense to me now, but before this, I'm thinking that "A" should also be [0][0][0] also, since it's the first element it should be in indexed [0], same goes with "item". :/ So my first Dim was correct? weaponX have [2][4][7]. :/ I'll try this out and be back later, but atleast I see what's I'm doing wrong now. Thanks. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
aslani Posted December 5, 2007 Author Share Posted December 5, 2007 I might be way off base here... expandcollapse popupDim $assy_Elements[2][4][7] $assy_Elements[0][0][0] = "1234567001" $assy_Elements[0][1][0] = "A" $assy_Elements[0][1][1] = "item" $assy_Elements[0][1][2] = "p/n" $assy_Elements[0][1][3] = "from" $assy_Elements[0][1][4] = "to" $assy_Elements[0][1][5] = "title" $assy_Elements[0][1][6] = "ref des" $assy_Elements[0][2][0] = "D" $assy_Elements[0][2][1] = "item" $assy_Elements[0][2][2] = "p/n" $assy_Elements[0][2][3] = "from" $assy_Elements[0][2][4] = "to" $assy_Elements[0][2][5] = "title" $assy_Elements[0][2][6] = "ref des" $assy_Elements[0][3][0] = "C" $assy_Elements[0][3][1] = "item" $assy_Elements[0][3][2] = "p/n" $assy_Elements[0][3][3] = "from" $assy_Elements[0][3][4] = "to" $assy_Elements[0][3][5] = "title" $assy_Elements[0][3][6] = "ref des" $assy_Elements[1][0][0] = "1234567002" $assy_Elements[1][1][0] = "A" $assy_Elements[1][1][1] = "item" $assy_Elements[1][1][2] = "p/n" $assy_Elements[1][1][3] = "from" $assy_Elements[1][1][4] = "to" $assy_Elements[1][1][5] = "title" $assy_Elements[1][1][6] = "ref des" $assy_Elements[1][2][0] = "D" $assy_Elements[1][2][1] = "item" $assy_Elements[1][2][2] = "p/n" $assy_Elements[1][2][3] = "from" $assy_Elements[1][2][4] = "to" $assy_Elements[1][2][5] = "title" $assy_Elements[1][2][6] = "ref des" $assy_Elements[1][3][0] = "C" $assy_Elements[1][3][1] = "item" $assy_Elements[1][3][2] = "p/n" $assy_Elements[1][3][3] = "from" $assy_Elements[1][3][4] = "to" $assy_Elements[1][3][5] = "title" $assy_Elements[1][3][6] = "ref des" $string = "" For $X = 0 to Ubound($assy_Elements, 1) - 1 $string &= $assy_Elements[$X][0][0] & @CRLF For $Y = 1 to Ubound($assy_Elements, 2) - 1 $string &= @TAB & $assy_Elements[$X][$Y][0] & @CRLF For $Z = 1 to Ubound($assy_Elements, 3) - 1 $string &= @TAB & @TAB & $assy_Elements[$X][$Y][$Z] & @CRLF Next Next Next MsgBox(0,"",$string) Wow! This one worked perfectly. Thanks. [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 5, 2007 Share Posted December 5, 2007 This might save some typing on creating the $assy_Elements array: Dim $assy_Elements[2][4][7] Dim $avB[4] = ["", "A", "D", "C"] Dim $avC[7] = ["", "item", "p/n", "from", "to", "title", "ref des"] For $a = 0 To 1 $assy_Elements[$a][0][0] = "123456700" & $a For $b = 1 To 3 $assy_Elements[$a][$b][0] = $avB[$b] For $c = 1 To 6 $assy_Elements[$a][$b][$c] = $avC[$c] Next Next Next 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 Link to comment Share on other sites More sharing options...
Fossil Rock Posted December 5, 2007 Share Posted December 5, 2007 I was thinking along the very same lines .... Dim $assy_Number[2] = ["1234567001", "1234567002"] Dim $assy_Action[3] = ["A", "D", "C"] Dim $assy_Details[6] = ["item", "p/n", "from", "to", "title", "ref des"] Dim $assy_Elements[2][3][6] For $a = 0 To UBound($assy_Number) -1 $assy_Elements[$a][0][0] = $assy_Number[$a] For $b = 0 To UBound($assy_Action) -1 $assy_Elements[$a][$b][0] = $assy_Action[$b] For $c = 0 To UBound($assy_Details) -1 $assy_Elements[$a][$b][$c] = $assy_Details[$c] Next Next Next Agreement is not necessary - thinking for one's self is! Link to comment Share on other sites More sharing options...
aslani Posted December 6, 2007 Author Share Posted December 6, 2007 This might save some typing on creating the $assy_Elements array: Dim $assy_Elements[2][4][7] Dim $avB[4] = ["", "A", "D", "C"] Dim $avC[7] = ["", "item", "p/n", "from", "to", "title", "ref des"] For $a = 0 To 1 $assy_Elements[$a][0][0] = "123456700" & $a For $b = 1 To 3 $assy_Elements[$a][$b][0] = $avB[$b] For $c = 1 To 6 $assy_Elements[$a][$b][$c] = $avC[$c] Next Next NextoÝ÷ Ûú®¢×rÛ¦¢Ëh~Øh±éî·«±ªÞ§Úy«Ú®&â# .Û¬zØb²Øb²+!£Â¥vZ(X¤y«¢+Ù¥´ÀÌØíÍÍå}±µ¹ÑÍlÀÌØíáulÀÌØíåulÀÌØíét)¥´ÀÌØíÙ lÀÌØíÍÍå}Ñ¥½¹}ÅÑåtôlÀÌØíÐÅtíÑ¡¥ÌÝ¥±°ÁɽÁ½Ñä½È¸¸¹9áÐÍÅÕ¹)¥´ÀÌØíÙ lÀÌØíÍÍå}Ñ¥±}ÅÑåtôlÅÕ½ÐìÅÕ½Ðì°ÀÌØí¥Ñ´°ÀÌØíÁ¸°ÀÌØíɽ´°ÀÌØíѼ°ÀÌØíѥѱ°ÀÌØíÉÍtíÑ¡¥ÌÝ¥±°ÁɽÁ½Ñä½È¸¸¹9áÐÍÅÕ¹()½ÈÀÌØíôÀQ¼ÀÌØíà´Ä(ÀÌØíÍÍå}±µ¹ÑÍlÀÌØíulÁulÁtôÅÕ½ÐìÄÈÌÐÔØÜÀÀÅÕ½ÐìµÀìÀÌØí(½ÈÀÌØíôÄQ¼ÀÌØíä´Ä(ÀÌØíÍÍå}±µ¹ÑÍlÀÌØíulÀÌØíulÁtôÀÌØíÙ lÀÌØít(½ÈÀÌØíôÄQ¼ÀÌØíè´Ä(ÀÌØíÍÍå}±µ¹ÑÍlÀÌØíulÀÌØíulÀÌØítôÀÌØíÙ lÀÌØít(9áÐ(9áÐ)9á Ok I'm not sure if that's right 'cause I haven't tested it, but you get the idea on how this'll work in my script. So you think this is a better way? or the "long" way? [font="Georgia"]Chances are, I'm wrong.[/font]HotKey trouble?Stringregexp GuideAutoIT Current Version Link to comment Share on other sites More sharing options...
randallc Posted December 7, 2007 Share Posted December 7, 2007 Hi, Sorry to be off topic.. Can anyone look at my attempt at _ArrayDisplay3D, and suggest any better ideas? I'm trying to get it to be more useful than treeDisplay or MsgBox. Best, Randall expandcollapse popup; _ArrayDisplay3Df.au3 #include <_ArrayDebugDisplay.au3> Dim $assy_Elements[2][4][7] Dim $avB[4] = ["", "A", "D", "C"] Dim $avC[7] = ["", "item", "p/n", "from", "to", "title", "ref des"] For $a = 0 To 1 $assy_Elements[$a][0][0] = "123456700" & $a For $b = 1 To 3 $assy_Elements[$a][$b][0] = $avB[$b] For $c = 1 To 6 $assy_Elements[$a][$b][$c] = $avC[$c] Next Next Next _Arraydisplay3D($assy_Elements) _Arraydisplay3D($assy_Elements, 1) _Arraydisplay3D($assy_Elements, 0, 1) _Arraydisplay3D($assy_Elements, 1, 1) ;============================================================================= Func _Arraydisplay3D($avTest, $sNumbered = 0, $iTransposed = 0) If UBound($avTest, 0) = 3 Then Local $Extra = 0, $sHeader3 = "", $avTest2[(UBound($avTest)) * (UBound($avTest, 3) + 2)][UBound($avTest, 2)] For $r = 0 To UBound($avTest) - 1 $Extra += 1 $avTest2[($r) * UBound($avTest, 3) + $Extra][0] = "Dim1[" & $r & "]" $Extra += 1 For $c = 0 To UBound($avTest, 2) - 1 If $iTransposed Then $sHeader3 &= "|" & "Dim1" If Not $iTransposed And $r = 0 Then $sHeader3 &= "Dim2[" & $c & "]" & "|" For $a = 0 To UBound($avTest, 3) - 1 If $iTransposed Then $sHeader3 &= "|" & "Dim3[" & $a & "]" If $sNumbered Then $avTest2[($r) * UBound($avTest, 3) + $a + $Extra][$c ] &= "[" & $a & "] - " $avTest2[($r) * UBound($avTest, 3) + $a + $Extra][$c ] &= $avTest[$r][$c][$a] Next If $iTransposed Then $sHeader3 &= "|" Next Next _ArrayDebugDisplay($avTest2, "$avTester|" & $sHeader3, 0, $iTransposed, "|", "//");, 1);_ArrayDisplay1( $arGrid, "_ArrayDisplay() 2D Test" ,1,1,-1,-1,1) EndIf EndFunc ;==>_Arraydisplay3Dh ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW 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