Sign in to follow this  
Followers 0
CrewXp

How to specify multiple expressions in a IF statem

15 posts in this topic

How do I specify multiple statements in a IF statement?

I want the program to do a certain thing if $name = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y, or z

If not (Else), then it does something. I know how to do the rest. I just don't know how to tell If to look for the 26 letters. Thx

Share this post


Link to post
Share on other sites



hello,

just for this case, you can use this way :

$dec=asc($name)
if $dec>=97 or $dec<=122 then

Share this post


Link to post
Share on other sites

How do I specify multiple statements in a IF statement?

I want the program to do a certain thing if $name = a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y, or z

If not (Else), then it does something. I know how to do the rest. I just don't know how to tell If to look for the 26 letters. Thx

<{POST_SNAPBACK}>

one way is:

If StringInStr("|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|", "|" & $name & "|") then
; true
Else
; false
EndIf

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

#include <GUIConstants.au3>

GUICreate("Test", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1, 

$name = GUICtrlCreateInput ( "", 10,  5, 300, 20)

GUISetState () 

$test = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",")

While 1
   For $i = 1 To $test[0]
      If GUICtrlRead($name) = $test[$i] Then
      ;Insert Code Here
      EndIf
   Next
Wend

Edit: Always one step ahead JdeB lol.

Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

oops sorry, it's :

$dec=asc($name)
if $dec>=97 and $dec<=122 then

Share this post


Link to post
Share on other sites

If you can accept numbers as well, StringIsAlNum() would work too


Writing AutoIt scripts since
_DateAdd("d", -2, _NowCalcDate())

Share this post


Link to post
Share on other sites

thats not really what he meant...

To have multiple ways for it to be true then do something like this

$Var = 9
$UglyVar = 25987235923857092385

If $UglyVar = 1 Or $Var = 9 Then MsgBox ( 0, 'aoskjfhkajs', 'sljdfhaslkdjf' )

[font="Times"] If anyone remembers me, I am back. Maybe to stay, maybe not.----------------------------------------------------------------------------------------------------------[/font][font="Times"]Things I am proud of: Pong! in AutoIt | SearchbarMy website: F.R.I.E.S.A little website that is trying to get started: http://thepiratelounge.net/ (not mine)[/font][font="Times"] ----------------------------------------------------------------------------------------------------------[/font][font="Arial"]The newbies need to stop stealing avatars!!! It is confusing!![/font]

Share this post


Link to post
Share on other sites

I have this, but a problem

HotKeySet("{F6}", "_222Customt")
Func _222Customt()
$alpha = 1
$name = 1
While $alpha = 1
Send("^a")
Sleep(50)
Send("{END}")
Sleep(50)
Send("{SHIFTDOWN}")
Sleep(50)
Send("{LEFT}")
Sleep(50)
Send("{SHIFTUP}")
Sleep(200)
Send("^c")
Sleep(200)
Send("^c")
Sleep(200)
Send("^c")
Sleep(200)
$name = ClipGet()
MsgBox(0, "Value of $name is:", $name)
If $name = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",") then
Exit
Else
Send("{DEL}")
EndIf
WEnd
EndFunc ;==>_Exit

It deletes the characters at the end of the text in teh text box because it's not a letter. Its a space or a blank line. But when it finds the letters it's supposed to, it doesn't stop like its supposed to. It tells me it copied one of those letters in the msgbox i made, but it keeps going. Whats wrong?

Share this post


Link to post
Share on other sites

If $name = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",") then
Exit

<{POST_SNAPBACK}>

This isn't a correct statement........

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

How can I correct it then... I want it to be If $name = a or b or c or... so on. I've tried every one of the above, but I dont think I'm doing it righ

Share this post


Link to post
Share on other sites

Burrup's example should work just fine


Start -> Programs -> AutoIt v3 -> AutoIt Help File -> Index -> (The Function you are asking about)----- Links -----DllStruct UDFsRSA Crypto UDFs

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

Burrup's example should work just fine

<{POST_SNAPBACK}>

Correct, I have now commented it for you.

#include <GUIConstants.au3>

GUICreate("Test", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1,

$name = GUICtrlCreateInput ( "", 10,  5, 300, 20)

GUISetState ()

$test = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",")
While 1
;$test[0] contains the number or string above which is 26, the alphabet
;$test[1] is the first string, which is letter "a"
;$test[2] is the second string, which is letter "b", 3 = "c", 4 = "d" and so on...
; so below we start the count at $i = 1, because its the first letter, and we go
;"to" $test[0] which is how many there are
   For $i = 1 To $test[0]
; It now checks the input box to see if any letters are in the input box
      If GUICtrlRead($name) = $test[$i] Then
;Insert Code Here
;If it finds any letter it will do the where "Insert code here" is located
      EndIf
   Next
Wend
Edited by Burrup

[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

I tested the script and it works great! When I type a letter in the GUI, it exits like I told it to. But I don't need a GUI. I need the things to be done in the program. But again... It doesn't work.

HotKeySet("{ESC}", "_Exit")
Func _Exit()
   Exit
EndFunc;==>_Exit

HotKeySet("{F2}", "_2Exit")
Func _2Exit()
#include <GUIConstants.au3>
$name = 1
;While $alpha = 1
Send("^a")
Sleep(50)
Send("{END}")
Sleep(50)
Send("{SHIFTDOWN}")
Sleep(50)
Send("{LEFT}")
Sleep(50)
Send("{SHIFTUP}")
Sleep(200)
Send("^c")
Sleep(200)
Send("^c")
Sleep(200)
Send("^c")
Sleep(200)
$name = ClipGet()
;GUICreate("Test", 320,120, @DesktopWidth/2-160, @DesktopHeight/2-45, -1,)

;$name = GUICtrlCreateInput ( "", 10,  5, 300, 20)

;GUISetState ()

$test = StringSplit("a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z",",")
While 1
;$test[0] contains the number or string above which is 26, the alphabet
;$test[1] is the first string, which is letter "a"
;$test[2] is the second string, which is letter "b", 3 = "c", 4 = "d" and so on...
; so below we start the count at $i = 1, because its the first letter, and we go
;"to" $test[0] which is how many there are
   For $i = 1 To $test[0]
; It now checks the input box to see if any letters are in the input box
      If $name = $test[$i] Then
;Insert Code Here
Exit
MsgBox(0, "WORKNumber of People in the box: ", $name)
Else
;Else Code Here
MsgBox(0, "Number of People in the box: ", $name)
Send("{DEL}")
Send("{SHIFTDOWN}")
Sleep(50)
Send("{LEFT}")
Sleep(50)
Send("{SHIFTUP}")
Sleep(200)
Send("^c")
Sleep(200)
Send("^c")
Sleep(200)
Send("^c")
Sleep(200)
$name = ClipGet()
;Send("{DEL}")
;If it finds any letter it will do the where "Insert code here" is located
      EndIf
   Next
Wend
EndFunc;==>_Exit
While 1
Wend

As you can tell from above, if it selects a letter, it should stop. But if it isn't a letter (a space or return charcter), then it keeps deleting those characters until it finds a letter.

Here is what I am working with, except its lower-case:

Edited by CrewXp

Share this post


Link to post
Share on other sites

I think you will have to use WinGetText () so you can first get the text of the window if it isnt a GUI one. Then you can split up what it returns.


[u]Old Projects:[/u]A3MORGB2Hex[u]Old Functions:[/u]_TimeAdd/_TimeSub_AddComma_BubbleSort _RippleSort "He who does not understand your silence will probably not understand your words." - Elbert Hubbard.

Share this post


Link to post
Share on other sites

What exactly are you trying to do?

If you are just trying to remove white space from a bunch of text, I recommend copying the text into a text editor (such as SciTe or TextPad that supports regular expression searchs and replacements.


Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!

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  
Followers 0