Jump to content
Sign in to follow this  
jimmyjmmy

how to assign 'a' to 'z' to an array

Recommended Posts

jimmyjmmy

Hi,

How do I assign the value of 'a' to 'z' to an array? Thanks

Share this post


Link to post
Share on other sites
PsaltyDS

Look at

For Next

Chr()

You forgot the RegExp... $avArray = StringRegExp("abcdefghijklmnopqrstuvwxyz", ".", 3)

:P


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites
BrettF

#include <Array.au3>
;Outputs A-Z
Dim $array[26]
For $i = 0 to 25
    $array[$i] = Chr (65+$i) 
Next
_ArrayDisplay ($array)

;Outputs a-z
Dim $array[26]
For $i = 0 to 25
    $array[$i] = Chr (97+$i) 
Next
_ArrayDisplay ($array)

;Outputs random case.

Dim $array[26]
For $i = 0 To 25
    $cap = Random (0, 1, 1)
    If $cap = 1 Then
        $pre = 65
    Else
        $pre = 97
    EndIf
    $array[$i] = Chr ($pre+$i) 
Next
_ArrayDisplay ($array)

Cheers,

Brett

:P

Share this post


Link to post
Share on other sites
jimmyjmmy

Thank You so much everybody for the help.

Share this post


Link to post
Share on other sites
spudw2k

Ok, I had to do some performance testing. :P

On my laptop (Celeron 1.7Ghz) here were my results.

PsaltyDS' Method

Zedna's Method

BrettF's Method

To be honest, my first attempt looked exactly like BrettF's. I really need to get it in my head to check out the RegExpr functions when I deal with strings; but it appears in this particular case a good 'ol stringsplit does the trick.

a_z_test.au3

Edited by spudw2k

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×