datatek Posted January 23, 2009 Posted January 23, 2009 Hello, I would like my script to react to the fact that a string is empty, or at least < a certain number of characters. If this is the case, the script should perform something (IF --> Else). How would I implement this? Thankyou for your much needed help.
billthecreator Posted January 23, 2009 Posted January 23, 2009 (edited) If StringLen(GuiCtrlRead($input)) > 5 Then ;do something here elseif StringLen(GuiCtrlRead($input)) = 0 Then ;do something here endif Edited January 23, 2009 by billthecreator [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap
datatek Posted January 23, 2009 Author Posted January 23, 2009 If StringLen(GuiCtrlRead($input)) > 5 Then ;do something here elseif StringLen(GuiCtrlRead($input)) = 0 Then ;do something here endif Thank you for your quick reply. ATM my code is If StringLen(GuiCtrlRead($variable) < 1 Then send("{ESC}") elseif StringLen(GuiCtrlRead($variable)) > 0 Then [Rest of script] I get the error message If StringLen(GuiCtrlRead($variable) < 1 Then If StringLen(GuiCtrlRead($variable) < 1 ^ ERROR and the program exits.
billthecreator Posted January 23, 2009 Posted January 23, 2009 Thank you for your quick reply. ATM my code is If StringLen(GuiCtrlRead($variable) < 1 Then send("{ESC}") elseif StringLen(GuiCtrlRead($variable)) > 0 Then [Rest of script] I get the error message If StringLen(GuiCtrlRead($variable) < 1 Then If StringLen(GuiCtrlRead($variable) < 1 ^ ERROR and the program exits. are you closing the () If StringLen(GuiCtrlRead($variable)) < 1 Then [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap
capo Posted January 23, 2009 Posted January 23, 2009 and if the $variable isn't a GUI edit box or whatever. then it should just be: If StringLen($variable) < 1 Then send("{ESC}") elseif StringLen($variable) > 0 Then
BrettF Posted January 23, 2009 Posted January 23, 2009 Probably faster to go: $len = StringLen ("String") Switch $len Case 0 ;Empty Case 1 To 5 ;Len 1 to 5 EndSwitch or $len = StringLen ("String") Select Case $len > 0 ;... Blah blah blah EndSelect Cheers Vist my blog!UDFs: Opens The Default Mail Client | _LoginBox | Convert Reg to AU3 | BASS.au3 (BASS.dll) (Includes various BASS Libraries) | MultiLang.au3 (Multi-Language GUIs!)Example Scripts: Computer Info Telnet Server | "Secure" HTTP Server (Based on Manadar's Server)Software: AAMP- Advanced AutoIt Media Player | WorldCam | AYTU - Youtube Uploader Tutorials: Learning to Script with AutoIt V3Projects (Hardware + AutoIt): ArduinoUseful Links: AutoIt 1-2-3 | The AutoIt Downloads Section: | SciTE4AutoIt3 Full Version!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now