We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm messing around loadString(), but i run into a problem what i don't really understand why happened.
Only code 4 runs even if in the file.txt at the l line there is FUNC1 , FUNC2 or FUNC3.
String[] file;
int l = 0;
void setup() {
file = loadStrings("file.txt");
}
void draw() {
if(l < file.length) {
if(file[l] == "FUNC1"") {
//code 1
}else if(file[l] == "FUNC2") {
//code 2
}else if(file[l] == "FUNC3") {
//code 3
}else {
//code 4
}
}
}
Answers
you have to use equals instead of == with Strings
no double
""
pleaseint l = 0; is a very bad variable names since it looks likes 1 (one).
in fact all variable names with length one are bad, except maybe x,y, i
variable names start with a small letter like i or index
constants BIG_LETTERS
classes big Capital, like
class Ball
arrays and ArrayList small but plural like
balls
Thanks for the fast and useful help. :)
;-)