I have created a text file which I am using to determine whether a background image, or canvas colour is shown:-
Code:void getPrefs_setbackground() {
// Set the background
String[] prefs;
prefs = loadStrings("background.txt");
// If the file exists do this
if (prefs != null) {
String[] pieces = split(prefs[0], ',');
if (pieces[0] == "colour" && pieces.length == 2) {
fill(int(pieces[1]));
rect(0,0,width,height);
println ("egypt");
} else {
background_pic = loadImage(pieces[0]);
image(background_pic, 0, 0);
}
// If the file doesn't exist set the background to a solid colour
} else {
// Set the background to be a solid colour
fill(canvasColor);
rect(0,0,width,height);
}
}
However, this portion doesn't work and I am not sure why:-
Code:if (pieces[0] == "colour" && pieces.length == 2) {
The pieces[0] array does contain the string colour, so why does the IF statement not work?
background.txt looks like:-
colour,123
Please help.