 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
utilael
Joined: 30 May 2009 Posts: 7
|
Posted: Wed Aug 26, 2009 7:59 pm Post subject: Array help |
|
|
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. |
|
| Back to top |
|
 |
HotKeyIt
Joined: 18 Jun 2008 Posts: 4652 Location: AHK Forum
|
|
| Back to top |
|
 |
Guest
|
Posted: Wed Aug 26, 2009 8:55 pm Post subject: |
|
|
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
|
Posted: Wed Aug 26, 2009 9:08 pm Post subject: |
|
|
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 |
|
 |
utilael
Joined: 30 May 2009 Posts: 7
|
Posted: Wed Aug 26, 2009 10:13 pm Post subject: |
|
|
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 |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|