I am having trouble using the saveStrings() function. I am using it in APDE. But I have tried the same code on processing 3.2.1.
String sentence = "This is a sentence";
String[] save;
String[] load;
void setup(){
size(displayWidth, displayHeight);
background(0);
fill(0,0,255);
textAlign(CENTER);
textSize(64);
save = split(sentence, " ");
text(save[0], width/2, height*0.2);
text(save[1], width/2, height*0.4);
saveStrings("strings.txt", save);
load = loadStrings("strings.txt");
text(load[2], width/2, height*0.6);
text(load[3], width/2, height*0.8);
}
This should output the words "This is a sentence" down the middle of the window. However it returns an error saying that the index called is longer than the string length, for text(load[2], width/2, height*0.6);
. Meaning the the variable "load" didn't load in anything from "strings.txt". I know this is an issue with saveStrings() because when I open strings.txt and put in 1, 2, 3, 4 on different lines, the code ouputs "This is 3 4" down the middle. Also when I check strings.txt it doesn't have the String[] saved.
I've tried putting strings.txt in different locations but it still doesn't work.