NELyon Posted July 16, 2006 Share Posted July 16, 2006 Is it possible to create an array when you don't know how much data is in the array? I am creating an array with a LLLLOOOONNNNGGG list of things, and i don't know how much there is... Link to comment Share on other sites More sharing options...
Nomad Posted July 16, 2006 Share Posted July 16, 2006 (edited) Is it possible to create an array when you don't know how much data is in the array? I am creating an array with a LLLLOOOONNNNGGG list of things, and i don't know how much there is...I believe you can accomplish this with _ArrayAdd, but I've never used it personally. You could also just make the array a lot bigger than you would possibly need, then resize it after it's as full as it's going to get, I've done that before. Nomad Edit: I've never used _ArrayAdd because the only situations like this I've encountered were already eating up a lot of time, so I didn't want to eat up more time by calling a function inside of the loop. It was faster to just make the array huge, like $Array[1000000], and use a variable in the loop which counted each time it looped, that way I could instantly determine the last index of the array which was written to, and make another loop based on that to transfer the array data to a new array which was exactly the right size. I hope that made sense. Edited July 16, 2006 by Nomad Link to comment Share on other sites More sharing options...
GaryFrost Posted July 16, 2006 Share Posted July 16, 2006 also Dim and ReDim SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 16, 2006 Share Posted July 16, 2006 (edited) Is it possible to create an array when you don't know how much data is in the array? I am creating an array with a LLLLOOOONNNNGGG list of things, and i don't know how much there is... I use _ArrayAdd() a lot, and that is just a UDF implementation of ReDim. For convienence and convention sake, keep the first index ($Array[0]) for the count. Mine generally look like this: #include <array.au3> Global $aAnimals[1] = [0] While 1 $NewAnimal = InputBox($aAnimals[0] & " Animals so far...", "Enter a new animal: ") If @error Then ExitLoop _ArrayAdd($aAnimals, $NewAnimal) $aAnimals = Ubound($aAnimals) - 1 Wend _ArrayDisplay($aAnimals, "Your list of " & $aAnimals[0] & " animals:")oÝ÷ ØíêÞƧyçm¢Ë^¦Øk¢è!¶®¶²Ê¬¶)ev÷öÙÞyÛhz0jvíg¡£ hÆ®¶sb6æ6ÇVFRfÇC¶'&æS2fwC° ¤vÆö&Âb33c¶æÖÇ5³ÒҳХvÆR¢b33c´æWtæÖÂÒçWD&÷b33c¶æÖÇ5³ÒfײgV÷C²æÖÇ26òf"âââgV÷C²ÂgV÷C´VçFW"æWræÖâgV÷C²¢bW'&÷"FVâWDÆö÷¢ô'&FBb33c¶æÖÇ2Âb33c´æWtæÖ¢b33c¶æÖÇ5³ÒÒV&÷VæBb33c¶æÖÇ2Ò¥vVæ@¤f÷"b33c¶ÒFòb33c¶æÖÇ5³Ð¢×6t&÷cBÂgV÷C´æÖÂÆ7Fæw2gV÷C²ÂgV÷C´æÖÂgV÷C²fײb33c¶fײgV÷C²÷WBöbgV÷C²fײb33c¶æÖÇ5³ÒfײgV÷C²3¢gV÷C²fײb33c¶æÖÇ5²b33c¶ÒÂ"¤æW Edit: Tweaked a typo per AlanR, below... Edited August 22, 2006 by PsaltyDS 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...
AlanR Posted August 22, 2006 Share Posted August 22, 2006 (edited) Just trawling through posts here, trying to pick up some tips. Shouldn't the line:$aAnimals = Ubound($aAnimals) - 1read as:$aAnimals[0]= Ubound($aAnimals) - 1? Alan Edited August 22, 2006 by AlanR Link to comment Share on other sites More sharing options...
GaryFrost Posted August 22, 2006 Share Posted August 22, 2006 Just trawling through posts here, trying to pick up some tips. Shouldn't the line:$aAnimals = Ubound($aAnimals) - 1read as:$aAnimals[0]= Ubound($aAnimals) - 1? Alan yep SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. 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