billthecreator Posted January 14, 2012 Posted January 14, 2012 I have a search bar that doesn't proceed unless it has text. If $SearchRead<> "" Or StringRegExp($SearchRead, '[:blank:]') = 0 Then I've tried StringInString, and that doesn't work either. Am I missing something? Thanks [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap
ripdad Posted January 14, 2012 Posted January 14, 2012 (edited) If $SearchRead And Not StringIsSpace($SearchRead) Then Edited January 14, 2012 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
Robjong Posted January 14, 2012 Posted January 14, 2012 (edited) Hi, although the snippet ripdad posted using StringIsSpace is correct I prefer to use StringStripWS which is a little bit faster, and while we are being overzealous, the snippet can also be used without the "$SearchRead And" part. If StringStripWS($SearchRead, 8) Then ... Edit: fixed AutoIt tags Edited January 14, 2012 by Robjong
billthecreator Posted January 14, 2012 Author Posted January 14, 2012 Thank you! Just what I needed. [font=Microsoft Sans Serif]My Scripts: From Most recent to least.[/font]Countdown GUI | QLOCK TWO | FlipClock | Slot Machine My UDF:_GenerateRandomNoRepeat | _GuiSnap
ripdad Posted January 14, 2012 Posted January 14, 2012 Robjong, nice "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
ripdad Posted March 30, 2012 Posted March 30, 2012 (edited) Hi Robjong,Regarding this snippet:If StringStripWS($SearchRead, 8) Then ...What if remaining contents of string ... is the number zero?--I don't know if you'd change anything - but this function is my shot at it:If StringExists('0') Then MsgBox(0, "StringExists('0')", 1) If StringExists(0) Then MsgBox(0, "StringExists(0)", 1) ; Func StringExists($s_String, $iChars = 10);<-- number of characters to grab (including WS) Return StringLen(StringStripWS(StringLeft($s_String, $iChars), 8)) EndFuncbreakdown:StringLeft - grabs a small sample to be tested. No need to test all of it.StringStripWS - (same as intended)StringLen - mainly determines if a zero exist.--thanks and take care!--EDITI gave it some more thought for those that have to KNOW if it's a zero.Somebody let me know if there's anything you'd change or do different or better. Thanks.If StringExists('0') Then MsgBox(0, "StringExists('0')", '@extended=' & @extended & ', Return=1') If StringExists(0) Then MsgBox(0, "StringExists(0)", '@extended=' & @extended & ', Return=1') ; Func StringExists($s_String, $iChars = 10);<-- number of characters to grab (including WS) $s_String = StringStripWS(StringLeft($s_String, $iChars), 8) If StringLen($s_String) Then If $s_String = 0 Then Return SetError(0, 1, 1); string is a 0 - @extended=1, return=1 Else Return SetError(0, 0, 1); is string - @extended=0, return=1 EndIf EndIf Return SetError(0, 0, 0); no string - @extended=0, return=0 EndFunc Edited March 30, 2012 by ripdad "The mediocre teacher tells. The Good teacher explains. The superior teacher demonstrates. The great teacher inspires." -William Arthur Ward
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