AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Array help

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
utilael



Joined: 30 May 2009
Posts: 7

PostPosted: Wed Aug 26, 2009 7:59 pm    Post subject: Array help Reply with quote

I must be dumb, I have an array I'm using multiple times in a row and would like to simply delete it between uses so I can count up how big the array is by using:

Code:
Loop
{
   counter += 1
   if (InfoArray%counter% = "")
       break
}


If I have other values in it though it won't give me an accurate counting (i.e. first time around it had 9 different values, though the second time around I only fill up 4 it will still count up to 9). I'd imagine there's a way to delete variables but I can't find it for the life of me.

Any help would be greatly appreciated... and if there's a built in function or something that returns the size of an array that would help too Wink.

Thanks.
Back to top
View user's profile Send private message
HotKeyIt



Joined: 18 Jun 2008
Posts: 4652
Location: AHK Forum

PostPosted: Wed Aug 26, 2009 8:04 pm    Post subject: Reply with quote

You have to keep track of items in array yourself because this is actually not an array!
_________________
AHK_H (2alpha) AHF TT _Struct WatchDir Yaml _Input ObjTree RapidHotkey DynaRun Wink
Back to top
View user's profile Send private message
Guest






PostPosted: Wed Aug 26, 2009 8:55 pm    Post subject: Reply with quote

So, if you want to delete an array, might this help?
Code:
text = a, b, c, d, e, f, g, h
StringSplit, yourarray, text, `,, %A_Space%
;here you have an array called "yourarray" with 9 elements.

;in order to delete it, just assign an empty value
loop, %yourarray0%
   yourarray%A_Index% :=
yourarray0 :=

yourarray0 contains the number of elements by the way.
Back to top
Icarus



Joined: 24 Nov 2005
Posts: 851

PostPosted: Wed Aug 26, 2009 9:08 pm    Post subject: Reply with quote

utilael, from your description it seems like you only want to delete the array so you can count its size.

If thats really the case, I would suggest you take a different approach.
Arrays in AHK always keep their size in the ArrayName0 variable.

So, if you are creating this array using one of the built in AHK functions (like StringSplit), you already have the size in the 0 element.

If you are creating the array manually, make sure you put the count in the 0 element - this way, you do not need to delete, and do not need to count.
_________________
Sector-Seven - Freeware tools built with AutoHotkey
Back to top
View user's profile Send private message Visit poster's website
utilael



Joined: 30 May 2009
Posts: 7

PostPosted: Wed Aug 26, 2009 10:13 pm    Post subject: Reply with quote

Thanks for all your quick responses! I am using StringSplit and did not know about the Array0 containing the size; that's genius =). And you're correct Icarus, I don't really care about totally deleting the array, just getting it's size so I can grab the last value of it after doing a split.

Thanks again.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group