Arrrghmatey Posted July 14, 2005 Posted July 14, 2005 I need to read a large amount of information from a file and place it in an array. (I'll then use it for coordinates) However, since I do not know the amount of items I will have, I'd like to place it in a vector. This possible/feasible in Autoit?
w0uter Posted July 14, 2005 Posted July 14, 2005 AFAIK autoit doesnt have vector's. I think you best ReDim array's. My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
Arrrghmatey Posted July 14, 2005 Author Posted July 14, 2005 If I have well over a hundred items that need to be placed in the array, would this technique use excessive system resources/memory or be slow? I'm really new to this, but the speed of this is important. I don't want it to lag more than a second or two....
w0uter Posted July 14, 2005 Posted July 14, 2005 maby it would be faster if you created a REALLY BIG array. after your done filling it you want. you can redim it 1'ce to the right size. (aint vector's slow btw ?) My UDF's:;mem stuff_Mem;ftp stuff_FTP ( OLD );inet stuff_INetGetSource ( OLD )_INetGetImage _INetBrowse ( Collection )_EncodeUrl_NetStat_Google;random stuff_iPixelSearch_DiceRoll
Arrrghmatey Posted July 14, 2005 Author Posted July 14, 2005 (aint vector's slow btw ?)<{POST_SNAPBACK}>Yes, you are right, but they are faster than redimming it every single time you add a new element. As far as I understand, a vector is just a data structure wrapped around an array. Usually when the array is full, a new array is created that is twice the size of the original, so it is not redimmed constantly.I think I solved my problem by creating a quick and dirty addItem function:$Array[0] = $Array[0] + 1 If $array[0] > UBound($array) Then ReDim $array[$array[0] * 2] $array[$array[0]] = $newValue EndIfI don't need to delete any items, so I don't really need a full blown vector. Does this look right?
Arrrghmatey Posted July 14, 2005 Author Posted July 14, 2005 Ok, I just want to say that I am a complete idiot. I just found a function that does EXACTLY what I wanted. IniReadSection does it, and ini files look MUCH better than my config format. I guess it pays to read ALL of the documentation first. I am still learning so I didn't know what an ini file was until now. I feel silly
Nutster Posted July 16, 2005 Posted July 16, 2005 What I tend to do is ReDim with a fairly large number each time. Dim $nLast = -1 ; Last element that is active Dim $vArray[99] ; Set array to 99 element ... ; Add new element ($new_data) to array $nLast += 1 if UBound($vArray) -1 < $nLast Then ReDim $vArray[$nLast + 99] Endif $vArray[$nLast] = $new_data ... ; Finished loading, redim to proper size ReDim $vArray[$nLast+1] David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
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