Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: Kathar on February 04, 2018, 10:22:12 AM

Title: Trouble Comparing Empty Strings (String Compare returning Not Equal) [SOLVED]
Post by: Kathar on February 04, 2018, 10:22:12 AM
Hi, me again! (sorry :P) - just a quick one! Basically I need to do a check to see if a string is empty/blank, but whenever I do this, the check/comparison always returns as Not Equal. I've tried the String is Empty or Null Action, and also tried making a default empty String variable and checking against that with String Compare, but no luck. Any body got any ideas why this might be happening? Thanks a lot!
Title: Re: Trouble Comparing Empty Strings (String Compare always returning Not Equal)
Post by: djaydino on February 04, 2018, 07:48:59 PM
Hi.
I am not sure why (can't test right now)
But maybe you can use "Get String Length" and then an "int Compare" to see if length is 0"
Title: Re: Trouble Comparing Empty Strings (String Compare always returning Not Equal)
Post by: Kathar on February 05, 2018, 06:21:01 AM
Hi.
I am not sure why (can't test right now)
But maybe you can use "Get String Length" and then an "int Compare" to see if length is 0"
Great idea thanks, will test it later and let you know how it goes, cheers!
Title: Re: Trouble Comparing Empty Strings (String Compare always returning Not Equal)
Post by: Kathar on February 05, 2018, 02:05:05 PM
Hi.
I am not sure why (can't test right now)
But maybe you can use "Get String Length" and then an "int Compare" to see if length is 0"
Great idea thanks, will test it later and let you know how it goes, cheers!

Hmm think it might be something wrong/weird on my end. When I check the string length it's returning as 1 character, though it appears to be empty. If I force set this string again to blank first using Set String 2, then it returns the correct value of 0.

I am retrieving the string from a Room Custom Property though, so I don't know if that may be causing the issue somewhere. (Essentially using this to make a room password system, and checking if a password is set or not). I'll keep playing around and let you know if I get anywhere - thanks for your help so far!

Edit: Okay, so I think I've found the problem! Bit of a weird one, not sure if it's a bug. Basically, on creating a photon room, I've got a UI Input Field where you can set a password. But whenever I retrieve the text from this Input Field and get the string length, it always counts an additional character, whether it's empty or with a password typed in -- it must be adding an additional 'space' or something when I retrieve the text string I'm guessing. If I put the retrieved string through String Trim it returns the correct amount of characters and everything works as expected - happy days!
Title: Re: Trouble Comparing Empty Strings (String Compare returning Not Equal) [SOLVED]
Post by: jeanfabre on February 08, 2018, 04:28:53 AM
Hi,

 maybe you pressed return or tab? I had to deal with the same issue last week.

 Bye,

 Jean
Title: Re: Trouble Comparing Empty Strings (String Compare returning Not Equal) [SOLVED]
Post by: blackant on March 12, 2020, 02:06:27 PM
sorry to put this topic on live again,

i have the exact same problem with a simple input text an di don't see how to solve it ..

i made a short code witch detect if the input is empty or not, but is never empty and never 0 aswell...
Title: Re: Trouble Comparing Empty Strings (String Compare returning Not Equal) [SOLVED]
Post by: jeanfabre on March 13, 2020, 02:05:39 AM
Hi,

 Can you expand the actions above? Make sure you use the dedicated actions instead of GetProperty, while that works too, it's less performant then using a regular action ( the one you disabled)

Bye,

 Jean