Hi there,
I am currently doing an app (Rpi2, Jessie) where I need to, during update, send a line to be written into a TXT, and after some time, it saves the data and parses a new TXT file. I have already managed to do this, but only when I create an instance of ofFile locally within a function, as follows:
string path = ofToString(“test.txt");
ofFile myTextFile(ofToDataPath(path),ofFile::WriteOnly);
myTextFile.create();
myTextFile << “my text comes here”+”\n”;
myTextFile << “my text comes here”+”\n”;
myTextFile.close();
However, I now need to create a 'global' declaration of my ofFile (myTextFile), and send text to it from time to time, and only even further close it. Thus, I declare in the header:
ofFile myTextFile;
And create it during setup:
string path = ofToString(“test.txt");
myTextFile = ofFile(ofToDataPath(path),ofFile::WriteOnly);
myTextFile.create();
And it works, the file is created. But when I try to send text to it in the update with:
myTextFile << “my text comes here”+”\n”;
And after a while, I call:
myTextFile.close();
It simply won't work. I have tried everything in this setup, but nothing seems to work. I have tested it both in a Mac and at my Rpi2, both unsuccessful.
Anyone one could please give me a light?
Thanks hugely!