Jump to content

Recommended Posts

Posted

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...

Posted

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...

Posted

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

Posted

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.

Posted (edited)

@Cyberslug

Because 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 whitespace

It 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 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!
  • Administrators
Posted

Devs, why isn't there an optional paramter such as

StringIsSpace("string" , $AlsoReturnTrueIfStringIsNull )

Wasn't it you that reported StringIsSpace returning true for "" as a bug? IIRC it was some regular :lmao:

o:)


 

Posted

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 whitespace

It 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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...