 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Thu Jan 31, 2008 5:21 am Post subject: Arrays and Lists |
|
|
Hey,
I'm on and off AHK but recently needed to create something involving lists and arrays. I searched around the site but couldn't really find what I needed.
All I want to do is create a list a-z and access the letters stored in the list.
Basically,
[a,b,c,d,e,f,g..z]
How would I go about creating that array and getting the 5th element out of it or something?
A link to a tutorial I might have missed or code would be fine. Thanks
-leg _________________ http://bux.to/?r=legault |
|
| Back to top |
|
 |
ManaUser
Joined: 24 May 2007 Posts: 906
|
Posted: Thu Jan 31, 2008 5:42 am Post subject: |
|
|
There's more than one way to do it of course, but here's a quick example:
| Code: | WholeArray := "abcdefghijklmnopqrstuvwxyz"
Loop Parse, WholeArray
Array%A_Index% := A_LoopField
MsgBox %Array5%
i = 3
MsgBox % Array%i% |
That should display "e" and then "c".
Here's what the help file has to say about arrays in general, in case you haven't read that:
http://www.autohotkey.com/docs/misc/Arrays.htm |
|
| Back to top |
|
 |
SKAN
Joined: 26 Dec 2005 Posts: 6264
|
Posted: Thu Jan 31, 2008 5:42 am Post subject: |
|
|
Here is a common method using a pseudo-array
| Code: | Loop 26
Element%A_Index% := Chr( 65+A_Index-1 )
Loop {
Random, RND, 1, 26
MsgBox, 0, % "Element " RND, % Element%RND%
} |
My preferred method to achieve the same result would be:
| Code: | Chrs := "ABCDEFGHIJKLMNOPQRSTUVXYZ"
Loop {
Random, RND, 1, 26
MsgBox, 0, Element %RND%, % Chr( NumGet(Chrs,RND-1,"UChar") )
} |
 |
|
| Back to top |
|
 |
leggah
Joined: 14 Oct 2007 Posts: 44
|
Posted: Thu Jan 31, 2008 6:29 am Post subject: |
|
|
mmm Looks like string parsing rather than lists, but as long as it works xD
Thanks MU, Skan
-leg _________________ http://bux.to/?r=legault |
|
| 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
|