[SOLVED] Read from/write to text files on mac

I’ve written a simple experiment with Windows, and am now trying to create a mac version using the same code.

In the windows version, stimuli to present are read in from the text file \tfiles\text.txt, and results are written to the text file \data\testResults.txt (Note: these are not in the assets folder, but could be moved there if necessary).

The program compiles fine on the mac, but bugs out because it can’t find these text files. I’ve tried copying them across to the same directory as the .app file, but to no avail. The error message says “Error: [file_open,tfiles\test.txt]”.

I’ve seen similar errors seem to occur with macros, but can’t see how to implement the same fix here. Any help appreciated.

I don’t know the solution, but I can help you decode the error.

This means there was an error calling file_open() with “tfiles\test.txt” as the argument. This could mean that the tfiles folder doesn’t exist in the working directory, or that it doesn’t contain a file named test.txt, or that test.txt is already open in another program.

Thanks player_03 - I’ve fixed the problem now, so here’s the solution for anybody else who was struggling with this.

The files are hidden in the .app package (right click and choose ‘show contents’).
I created appropriate directories in the ‘Resources’ folder.

Also note that I was using \ in my filepath (e.g. tfiles\test.txt), which windows was fine with, but mac was not. Using / works on both platforms (e.g. tfiles/test.txt)