rasim Posted January 15, 2008 Posted January 15, 2008 Hello! First example of array ReDim: #include <Array.au3> Dim $aNewArray[1] For $i = 1 To 2 $aNewArray[0] += 1 ReDim $aNewArray[$aNewArray[0] + 1] $aNewArray[$aNewArray[0]] = $i Next _ArrayDisplay($aNewArray)oÝ÷ Ùj+Ê+ç-Úw^Å©©æ®¶sb6æ6ÇVFRfÇC´'&æS2fwC° ¤FÒb33c¶æWt'&³Ð ¤f÷"b33c¶¢ÒFò b33c¶æWt'&µT&÷VæBb33c¶æWt'&ÒÒ³Ò &TFÒb33c¶æWt'&²T&÷VæBb33c¶æWt'&ҲРb33c¶æWt'&µT&÷VæBb33c¶æWt'&ÒÒÒb33c¶ ¤æW@ ¥ô'&F7Æb33c¶æWt'& Not work. Where wrong?
randallc Posted January 15, 2008 Posted January 15, 2008 Hi, Try; For $i = 1 To 2 $aNewArray[0]=UBound($aNewArray-1) ReDim $aNewArray[UBound($aNewArray) + 1] $aNewArray[UBound($aNewArray)-1] = $i Next _ArrayDisplay($aNewArray)Best, Randall ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
rasim Posted January 15, 2008 Author Posted January 15, 2008 randallcThanks for help, but i should like to know why 2-nd example don`t work correct.
WolfWorld Posted January 15, 2008 Posted January 15, 2008 #include <Array.au3> Dim $aNewArray[1] For $j = 1 To 2 $aNewArray[UBound($aNewArray) - 1] += 1 ;here it $aNewArray[1] not $aNewArray[0] ReDim $aNewArray[(UBound($aNewArray) - 1) + 1] $aNewArray[UBound($aNewArray) - 1] = $j;here it $aNewArray[1] not $aNewArray[0] Next _ArrayDisplay($aNewArray) Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets!
rasim Posted January 15, 2008 Author Posted January 15, 2008 athiwatcYou are tested yourself code before posting? Your example don`t work.
WolfWorld Posted January 15, 2008 Posted January 15, 2008 (edited) This one work, and sorry for the upper one i thongh i got it so i didn't test it #include <Array.au3> Dim $aNewArray[1] For $j = 1 To 2 ReDim $aNewArray[UBound($aNewArray) + 1] $aNewArray[UBound($aNewArray) - 1] = $j Next $aNewArray[0] = UBound($aNewArray) - 1 _ArrayDisplay($aNewArray)oÝ÷ Ù«¢+Ø¥¹±Õ±ÐíÉÉä¹ÔÌÐì()¥´ÀÌØí9ÝÉÉålÅt()½ÈÀÌØí¨ôÄQ¼È($ÀÌØí9ÝÉÉåmU ½Õ¹ ÀÌØí9ÝÉÉ䤴ÀÌØí©tôU ½Õ¹ ÀÌØí9ÝÉÉä¤(%I¥´ÀÌØí9ÝÉÉåmU ½Õ¹ ÀÌØí9ÝÉÉ䤬Åt($ÀÌØí9ÝÉÉåmU ½Õ¹ ÀÌØí9ÝÉÉ䤴ÅtôÀÌØí¨)9áÐ(()}ÉÉå¥ÍÁ±ä ÀÌØí9ÝÉÉä¤ The problem with your is UBound($aNewArray) - 1 Doesn't always make 0 Edited January 15, 2008 by athiwatc Main project - Eat Spaghetti - Obfuscate and Optimize your script. The most advance add-on.Website more of GadGets!
therks Posted January 16, 2008 Posted January 16, 2008 I know this is resolved already, but I just had to mention I don't understand why you had (UBound($aNewArray) - 1) + 1 Considering all you do is add and subtract 1 so it's the same number. My AutoIt Stuff | My Github
weaponx Posted January 16, 2008 Posted January 16, 2008 Lets not forget the uselessness of this piece: $aNewArray[uBound($aNewArray) - $j] = UBound($aNewArray) Which is the same as: $aNewArray[0] = UBound($aNewArray)
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