We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Alternet string comparison not working
Page Index Toggle Pages: 1
Alternet string comparison not working (Read 677 times)
Alternet string comparison not working
Jan 19th, 2010, 9:37am
 
I'm having a bit of a problem comparing Strings sent from client to server using the alternet library (forum doesn't allow me to link it, but look it up in google, if needed). Maybe it's just ignorance, but I truly can't figure it out for myself.

What I'm trying to do is have the server read a String sent from one of its clients, and compare it to any other data in the server, so that it can iterate through several possible actions. Well, things got tricky for some reason, and I can't have it returning true in the following statement:

Code:
void serverReceiveEvent(Server receivingServer, RemoteAddress client, String data) {
 if(data == "testing") {
   // do something
 }
}


I've printed the data in the server, after it's received, and made sure it is receiving exactly a string with the "testing" value. Still, it refuses to validate that statement, and I truly can't understand why.

Any ideas?

Thanks, Ed.
Re: Alternet string comparison not working
Reply #1 - Jan 19th, 2010, 9:47am
 
See the String reference page.

Please, delete the other thread, thanks.
Re: Alternet string comparison not working
Reply #2 - Jan 19th, 2010, 9:51am
 
I got it (quicker than I thought). As simple as using the good old java equals(). Thanks anyway and sorry for the hassle.  Smiley
Page Index Toggle Pages: 1