testing is alpha...

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
paik1002
Posts: 355
Joined: 28 Nov 2015, 02:45

testing is alpha...

10 Dec 2015, 03:06

I am having trouble understanding the following basic code:

Code: Select all

q::
{
    mystring1 = A
    mystring2 = ?
    mystring3 = 1

    if (mystring1 is alpha)
    {  
        msgbox %mystring1% is an alphabet
    }        
    
    if (mystring2 is alpha)
    {  
        msgbox %mystring2% is an alphabet
    }        

    if (mystring3 is alpha)
    {  
        msgbox %mystring3% is an alphabet
    }        
}
return
The result of executing the above code:
A is an alphabet
? is an alphabet
1 is an alphabet

What is happening here? Very confused.
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: testing is alpha...

10 Dec 2015, 03:12

Code: Select all

q::
{
    mystring1 = A
    mystring2 = ?
    mystring3 = 1
 
    if mystring1 is alpha
        msgbox %mystring1% is an alphabet      
 
    if mystring2 is alpha
        msgbox %mystring2% is an alphabet     
 
    if mystring3 is alpha
        msgbox %mystring3% is an alphabet    
}
return
Try it like this.
User avatar
Blackholyman
Posts: 1293
Joined: 29 Sep 2013, 22:57
Location: Denmark
Contact:

Re: testing is alpha...

10 Dec 2015, 03:13

try and remove the ()

Code: Select all

mystring1 = !
 
    if mystring1 is alpha
    {  
        msgbox %mystring1% is an alphabet
    }        
Also check out:
Courses on AutoHotkey

My Autohotkey Blog
:dance:
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: testing is alpha...

10 Dec 2015, 03:14

sry its late i forgot to add this:

Note: The operators "between", "is", "in", and "contains" are not supported in expressions.

HTH
paik1002
Posts: 355
Joined: 28 Nov 2015, 02:45

Re: testing is alpha...

10 Dec 2015, 03:26

O.K. removing the () did it. But still very strange that these operators are not supported inexpressions!
However, they were to be use in expressions, would there be other ways (tips & tricks?) of achieving it?
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: testing is alpha...

10 Dec 2015, 04:27

Using RegEx of some sort should be a way to test it. You can reference this recent thread: https://autohotkey.com/boards/viewtopic.php?f=5&t=11437 The way I went about it replacing the entire string is probably an inefficient way, but it works. (I'm rather very rubbish at RegEx.)

For alpha, this should work:

Code: Select all

string:="abckljakjalkdjfakljfa"
If !(x:=RegExReplace(string,"\w","")) ; if all characters are letters ("word characters"), then x will be null, and thus false. So then the logical-not (!) makes it true
MsgBox string is alpha
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: niCode and 218 guests