AutoHotkey Community

It is currently May 26th, 2012, 8:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Array help
PostPosted: August 26th, 2009, 8:59 pm 
Offline

Joined: May 30th, 2009, 7:38 pm
Posts: 7
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 ;).

Thanks.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 9:04 pm 
Offline

Joined: June 18th, 2008, 8:36 am
Posts: 4923
Location: AHK Forum
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:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 9:55 pm 
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.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 10:08 pm 
Offline

Joined: November 24th, 2005, 8:16 am
Posts: 851
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: August 26th, 2009, 11:13 pm 
Offline

Joined: May 30th, 2009, 7:38 pm
Posts: 7
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.


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: BrandonHotkey, joetazz, Leef_me, Mickers, tidbit, tomoe_uehara and 64 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group