Jump to content

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


Recommended Posts

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
Link to comment
Share on other sites

#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

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...