playMaker

Author Topic: Trouble Comparing Empty Strings (String Compare returning Not Equal) [SOLVED]  (Read 3067 times)

Kathar

  • Playmaker Newbie
  • *
  • Posts: 48
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!
« Last Edit: February 05, 2018, 05:16:12 PM by Kathar »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7615
    • jinxtergames
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"

Kathar

  • Playmaker Newbie
  • *
  • Posts: 48
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!

Kathar

  • Playmaker Newbie
  • *
  • Posts: 48
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!
« Last Edit: February 05, 2018, 02:28:39 PM by Kathar »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Hi,

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

 Bye,

 Jean

blackant

  • Hero Member
  • *****
  • Posts: 521
  • http://blackantmaster.com
    • blackantmaster.com
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...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
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