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 & HelpSyntax Questions › strings in loadStrings
Page Index Toggle Pages: 1
strings in loadStrings (Read 618 times)
strings in loadStrings
Feb 13th, 2006, 2:32pm
 
if i have a text file with a line in it like "background 255 100 110" (no quotes)

and i do a:
String lines[] = loadStrings(filename);
String list[] = split(lines[0]);

then
false: list[0] == "background"
true : int(list[1]) == 255
true : int(list[2]) == 100
true : int(list[3]) == 110

i can't seem to read in string values.  i've println'd them out, and they're there but when i do a:
if (list[0] == "background")
it always comes up false.

i've tried trim, casting it to a String, etc.  what am i missing?

-ben
working on:  http://mudabone.com/tangram/20060212/index.html
Re: strings in loadStrings
Reply #1 - Feb 13th, 2006, 2:53pm
 
Cause a string is an object and not a variable like a char use string.equals or equalsIgnoreCase  to compare strings.
Code:

list[0].equals ("background");

Re: strings in loadStrings
Reply #2 - Feb 13th, 2006, 3:21pm
 
See also: http://processing.org/faq/bugs.html#strings
Page Index Toggle Pages: 1