golfjrr Posted February 8, 2005 Share Posted February 8, 2005 After much hair pulling, I've simplified this down to the bear bones.. When my programs started acting funny after updating it took quite a bit to figure out what was causing the problem.. Simple Program: $junk = "" $x = stringisspace ( $junk ) Ok on 3.0.102 $x will = 1 as it should be according to the documentation Run exact same code on 3.1.0 and: $X = 0 What gives? Needless to say this is causing some major problems... Regardless how how it should work. It should be the same on both versions or did I miss something? I didn't see any changes in the release notes for the stringisspace function... Link to comment Share on other sites More sharing options...
Valik Posted February 8, 2005 Share Posted February 8, 2005 It was changed. An empty string can't have a space because its empty. Link to comment Share on other sites More sharing options...
golfjrr Posted February 8, 2005 Author Share Posted February 8, 2005 It was changed. An empty string can't have a space because its empty.<{POST_SNAPBACK}>It would have been nice to see that in the release notes. I guess it's back to the old version for now.... I have dozens of scripts that were coded (for better or for worse) assuming (since it worked that way) that a null string would be detected by stringisspace as nothing or whitespace. Needless to say with the unannounced change these scripts fail in droves... Link to comment Share on other sites More sharing options...
phillip123adams Posted February 8, 2005 Share Posted February 8, 2005 I guess it's back to the old version for now.... <{POST_SNAPBACK}>Don't go back. How about a work around?$junk = "" $x = StringIsSpace($junk & " ") MsgBox(4096, "Test 1", $x)Or, how about a UDF$junk = "" $x = _StringIsSpaceOrEmpty($junk) MsgBox(4096, "Test 2", $x) Func _StringIsSpaceOrEmpty($s) return StringIsSpace($s & " ") EndFunc Phillip Link to comment Share on other sites More sharing options...
golfjrr Posted February 8, 2005 Author Share Posted February 8, 2005 Thanks for the replies. I also apolgize for the knee jerk reaction, but I was in a bit of a panic when everything quit working. I was particularily frustrated as I am always careful about upgrading/making sure it isn't gonna cause any problems by checking the changes/release notes. I ended up creating a UDF and just replacing all my calls to my function. This should solve this issue. Link to comment Share on other sites More sharing options...
CyberSlug Posted February 8, 2005 Share Posted February 8, 2005 Devs, why isn't there an optional paramter such as StringIsSpace("string" , $AlsoReturnTrueIfStringIsNull ) Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
SlimShady Posted February 8, 2005 Share Posted February 8, 2005 @Cyberslug Because it doesn't make sense. An empty string contains no characters. Link to comment Share on other sites More sharing options...
CyberSlug Posted February 8, 2005 Share Posted February 8, 2005 (edited) @CyberslugBecause it doesn't make sense.An empty string contains no characters.<{POST_SNAPBACK}>My hunch is people want to use StringIsSpace to determine if the string contains any text. Perhaps you have a text file and you want to remove any lines that are blank or contain only whitespaceIt would make sense to remove any lines where StringIsSpace($line) is true.Of course, this statement misses blank lines......I typically use If StringStripWS($string, 8) = "" Then ... to avoid confusion.Anyway, just my two cents.Edit: I guess you could also use $line = "" Or StringIsSpace($line) Edited February 8, 2005 by CyberSlug Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig! Link to comment Share on other sites More sharing options...
Administrators Jon Posted February 8, 2005 Administrators Share Posted February 8, 2005 Devs, why isn't there an optional paramter such asStringIsSpace("string" , $AlsoReturnTrueIfStringIsNull )Wasn't it you that reported StringIsSpace returning true for "" as a bug? IIRC it was some regular Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
SlimShady Posted February 8, 2005 Share Posted February 8, 2005 Wasn't it you that reported StringIsSpace returning true for "" as a bug? IIRC it was some regular <{POST_SNAPBACK}>That would be me :"> Link to comment Share on other sites More sharing options...
golfjrr Posted February 8, 2005 Author Share Posted February 8, 2005 My hunch is people want to use StringIsSpace to determine if the string contains any text. Perhaps you have a text file and you want to remove any lines that are blank or contain only whitespaceIt would make sense to remove any lines where StringIsSpace($line) is true.Of course, this statement misses blank lines......I typically use If StringStripWS($string, 8) = "" Then ... to avoid confusion.Anyway, just my two cents.Edit: I guess you could also use $line = "" Or StringIsSpace($line)<{POST_SNAPBACK}>Your hunch is correct. Technically of course a null string doesn't contain any white space, but practically in every way I have used it, it means the same thing. I.E. there is nothing there. I want to do something else/not process it. The workarounds are not difficult. Perhaps in my case it was an undocumented feature/friendly bug. At any rate I just made my own simple function and did a mass edit where I was calling StringIsSpace to call my function. Granted there are no doubt 10 ways from Sunday to accomplish this... Func StringIsEmpty ( $sstring ) local $sstring if stringisspace ($sstring) or $sstring = "" then return 1 return 0 endfunc Link to comment Share on other sites More sharing options...
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