Okay, so I got the following problem:
I'm trying to open a text file in my project folder. So far so good, I got the following function:
function file_load(STRING* fileName)
{
// firstly, create a file handle
var myFileHandle;
// now, do the annoying string hickup to open the file in the correct folder:
STRING* fileToGet = " ";
str_cpy(fileToGet,"%EXE_DIR%\\");
str_cat(fileToGet,fileName);
// return(fileToGet);
// open the file
myFileHandle = file_open_read(fileToGet);
error(fileToGet);
error(str_for_num(NULL,myFileHandle));
}
Now, what I'd expect to happen now is that the error boxes popping up show me the path I wanna access, which should be my project folder (I got no subfolders) and the handle I get when accessing the file. The file does physically exist in the folder.
What I get in the box however is not this:
%EXE_DIR%\\myFile.txt
but this:
%EXE_DIR%\myFile.txt
As you can see, one "\" is missing; accordingly, I get a zero as file handle value as the folder the script tries to open doesnt exist.
I tried and put an
with a varying number of "\"s, and I always got only one "\" back - if I put an uneven number of them in the string, I get a syntax error at compiling.
Now, am I missing something about strings here? Is there a logical reason why the "\"s seem to vanish?