ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Other Software > Developer's Corner

autohotkey arrays

(1/2) > >>

justice:
I'm always fighting with them can you tell me what's the easiest way to maintain a list of strings, add a listitem, remove a listitem, return a listitem? For example I'd like to keep a list of hidden window titles and then unhide one and remove it from the list. Autohotkey makes it really hard, I usually build a concatenated string and split them into an array but then when i want to return a value but am not sure where its position is it's near impossible.

Any ideas?

jgpaiva:
I agree, it's a pain in the *** to use ahk's arrays..
Here's how I usually do it:

--- ---loop,%loopIter%
{
   TempVar := ArrayVar%A_Index%        ;store ArrayVar[i] in temp variable
   msgbox,TempVar                      ;use temp variable
   ArrayVar%A_Index% := A_Index * 4    ;store value in ArrayVar[i]
}

justice:
So with your example if I want to remove one item i have to look through the whole array and check a condition, breaking the loop if condition is true. Hm

jgpaiva:
justice: notice that in terms of removing, ahk's arrays are pretty much like any other arrays: there's no way to do so :)
What you can do it loop through the whole array, get the element you want, and then move all the elements that follow that one to the previous position.
If you're intentions are to add and remove elements (which are not the last element of the array), you're probably better off with a comma-separated list.

Target:
not sure if this is exactly what you want, (or even if it does what you want  :-[) but there's a minimize to tray script in the help file that i think does this - search on tray

I've been using this script for some time though I've not studied the code  :-[ :-[   

Navigation

[0] Message Index

[#] Next page

Go to full version