MrPook Posted July 31, 2007 Posted July 31, 2007 Hi there, i just tried to make a simple upgrade of an array script : here it is : #include <Array.au3> Local $arr[4] Dim $a1 _ArrayAdd($a1, "toto") _ArrayAdd($a1, "titi") Dim $a11[3] = [2,"toto1","titi1"] Local $a2[3] = [2, "a2-1","a2-2"] $arr[1] = $a1 $arr[2] = $a11 $arr[3] = $a2 $arr[0] = 3 Local $i , $j Local $dumy For $i = 1 to $arr[0] $dumy = $arr[$i] If IsArray($dumy) Then For $j = 1 to $dumy[0] - 1 _ArrayDisplay($dumy, "_ArrayDisplay() Test") Next Else ConsoleWrite("!UPS, What happened? Expected an array" & @LF) EndIf Next It seems it only wants to show me a11 and a2, why doesnt he wants to show me a1 ? (i think i dont know also how to use redim ...) Thanks for helping. Mr Pook
DW1 Posted July 31, 2007 Posted July 31, 2007 Because you didn't declare $a1 as an array #include <Array.au3> Local $arr[4] Dim $a1[1] _ArrayAdd($a1, "toto") _ArrayAdd($a1, "titi") Dim $a11[3] = [2,"toto1","titi1"] Local $a2[3] = [2, "a2-1","a2-2"] $arr[0] = 3 $arr[1] = $a1[1] $arr[2] = $a11[2] $arr[3] = $a2[2] Local $i , $j Local $dumy[$arr[0]] MsgBox (0, $arr[0],$arr[0]) MsgBox(0, $arr[1], $arr[2]) For $i = 1 to $arr[0] $dumy[$i - 1] = $arr[$i] Next If IsArray($dumy) Then _ArrayDisplay($dumy, "_ArrayDisplay() Test") Else ConsoleWrite("!UPS, What happened? Expected an array" & @LF) EndIf AutoIt3 Online Help
randallc Posted July 31, 2007 Posted July 31, 2007 Hi, I think he wants to make a number of arrays? ; _ArrayAddPook.au3 #include <Array.au3> Local $arr[4] Dim $a1[1], $a11[1], $a2[1] _ArrayAdd($a1, "toto") _ArrayAdd($a1, "titi") _ArrayDisplay($a1, "_ArrayDisplay() $a1") Dim $a11[3] = [2, "toto1", "titi1"] Local $a2[3] = [2, "a2-1", "a2-2"] $arr[1] = $a1 $arr[2] = $a11 $arr[3] = $a2 $arr[0] = 3 _ArrayDisplay($arr, "_ArrayDisplay() $arr - this will not display as each element is an array") Local $i, $j Local $dumy For $i = 1 To $arr[0] $dumy = $arr[$i] If IsArray($dumy) Then _ArrayDisplay($dumy, "_ArrayDisplay() $dumy Array=" & $i) Else ConsoleWrite("!UPS, What happened? Expected an array" & @LF) EndIf NextRandall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
MrPook Posted July 31, 2007 Author Posted July 31, 2007 Hi, I think he wants to make a number of arrays? ; _ArrayAddPook.au3 #include <Array.au3> Local $arr[4] Dim $a1[1], $a11[1], $a2[1] _ArrayAdd($a1, "toto") _ArrayAdd($a1, "titi") _ArrayDisplay($a1, "_ArrayDisplay() $a1") Dim $a11[3] = [2, "toto1", "titi1"] Local $a2[3] = [2, "a2-1", "a2-2"] $arr[1] = $a1 $arr[2] = $a11 $arr[3] = $a2 $arr[0] = 3 _ArrayDisplay($arr, "_ArrayDisplay() $arr - this will not display as each element is an array") Local $i, $j Local $dumy For $i = 1 To $arr[0] $dumy = $arr[$i] If IsArray($dumy) Then _ArrayDisplay($dumy, "_ArrayDisplay() $dumy Array=" & $i) Else ConsoleWrite("!UPS, What happened? Expected an array" & @LF) EndIf NextoÝ÷ Ù§u©eþ«¨µëajy2¢çè®Øb±ø«²Ø^§vz0ÚòyÜ"¶.¶IèÂ)à¶§ºfÞ®Ú®¶²²,Ûh¦ëbMújºÚÛkçm+ºÚ"µÍÈÐ^PYÛÚË]LÂÚ[ÛYH Ð^K]LÉÝÂ[H ÌÍØÌWB[H ÌÍØLVÌWK ÌÍØLLVÌWK ÌÍØLÌWBÐ^PY ÌÍØLK ][ÝÝÝÉ][ÝÊBÐ^PY ÌÍØLK ][ÝÝ]I][ÝÊBÐ^QÜ^J ÌÍØLK ][Ý×Ð^QÜ^J H ÌÍØLI][ÝÊB[H ÌÍØLLVÌ×HHÌ ][ÝÝÝÌI][ÝË ][ÝÝ]LI][Ý×BØØ[ ÌÍØLÌ×HHÌ ][ÝØLLI][ÝË ][ÝØLL][Ý×BÐ^PY ÌÍØ ÌÍØLJBÐ^PY ÌÍØ ÌÍØLLJBÐ^PY ÌÍØ ÌÍØLBÉÌÍØÌWHH ÌÍØLBÉÌÍØÌHH ÌÍØLLBÉÌÍØÌ×HH ÌÍØLÉÌÍØÌHHÂ×Ð^QÜ^J ÌÍØ ][Ý×Ð^QÜ^J H ÌÍØHÈÚ[ÝÜ^HÈXXÚ[[Y[È[^I][ÝÊBØØ[ ÌÍÚK ÌÍÚØØ[ ÌÍÙ[^BÜ ÌÍÚHHHÈ ÌÍØÌB ÌÍÙ[^HH ÌÍØÉÌÍÚWBYÐ^J ÌÍÙ[^JH[Ð^QÜ^J ÌÍÙ[^K ][Ý×Ð^QÜ^J H ÌÍÙ[^H^OI][ÝÈ [È ÌÍÚJB[ÙBÛÛÛÛUÜ]J ][ÝÉÌÌÎÕTËÚ][YÈ^XÝY[^I][ÝÈ [ÈB[Y^ but it didnt work, i think i messed it again because $arr is not displayed anymore. *sigh*
PsaltyDS Posted August 1, 2007 Posted August 1, 2007 but it didnt work, i think i messed it again because $arr is not displayed anymore. *sigh* You are declaring an array, then declaring it again, which is unnecessary. They are not being declared inside a function, so LOCAL is useless, just go with DIM. The count is not in $arr[0] automatically, you have to put there with Ubound(). This works: ; _ArrayAddPook.au3 #include <Array.au3> Dim $arr[1], $a1[1], $a2[3] = [2, "a2-1", "a2-2"] Dim $a11[3] = [2, "toto1", "titi1"] Dim $dumy _ArrayAdd($a1, "toto") _ArrayAdd($a1, "titi") _ArrayDisplay($a1, "_ArrayDisplay() $a1") _ArrayAdd($arr, $a1) _ArrayAdd($arr, $a11) _ArrayAdd($arr, $a2) $arr[0] = UBound($arr) - 1 For $i = 1 To $arr[0] $dumy = $arr[$i] If IsArray($dumy) Then _ArrayDisplay($dumy, "_ArrayDisplay() $dumy Array=" & $i) Else ConsoleWrite("!UPS, What happened? Expected an array" & @LF) EndIf 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
MrPook Posted August 2, 2007 Author Posted August 2, 2007 You are declaring an array, then declaring it again, which is unnecessary. They are not being declared inside a function, so LOCAL is useless, just go with DIM. The count is not in $arr[0] automatically, you have to put there with Ubound(). This works: ; _ArrayAddPook.au3 #include <Array.au3> Dim $arr[1], $a1[1], $a2[3] = [2, "a2-1", "a2-2"] Dim $a11[3] = [2, "toto1", "titi1"] Dim $dumy _ArrayAdd($a1, "toto") _ArrayAdd($a1, "titi") _ArrayDisplay($a1, "_ArrayDisplay() $a1") _ArrayAdd($arr, $a1) _ArrayAdd($arr, $a11) _ArrayAdd($arr, $a2) $arr[0] = UBound($arr) - 1 For $i = 1 To $arr[0] $dumy = $arr[$i] If IsArray($dumy) Then _ArrayDisplay($dumy, "_ArrayDisplay() $dumy Array=" & $i) Else ConsoleWrite("!UPS, What happened? Expected an array" & @LF) EndIf Next Thank you so much for helping, this was the tiny part where i was stuck, now everything is ok (so far) MrPook
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