File io problems
by DIAG · in Torque Game Engine · 03/15/2004 (2:35 am) · 5 replies
Hello,
I am trying to read in a file using the scripting language. When i use openForWrite("blah.txt"), the file is created alright. however, if i exchange this to openForRead("blah.txt"), it does not open. Can anyone help me?
I am trying to read in a file using the scripting language. When i use openForWrite("blah.txt"), the file is created alright. however, if i exchange this to openForRead("blah.txt"), it does not open. Can anyone help me?
#2
thanks for you quick reply. that does not work for me either. I wonder has it anything to do with how im calling the file name? how do u call a file in the same directory as the .exe i presumed you just called the name
03/15/2004 (3:45 am)
Hey,thanks for you quick reply. that does not work for me either. I wonder has it anything to do with how im calling the file name? how do u call a file in the same directory as the .exe i presumed you just called the name
#3
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5054 Hope that helps
03/15/2004 (3:54 am)
OpenFileForRead is broke, but there is a fix listed here..www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5054 Hope that helps
#4
I fixed this with somewhat of a hack: I stripped the strange chars from my strings like this:
I used this to save some player stats, thus the use of %client.name. As I said, this works for me with TGE 1.2
Stefan.
03/15/2004 (4:22 am)
The openForRead actually works, since the method is rerouted to another method in the FileObject class. Since this is the public area, I can't go into details here. I had a similar problem once, it turned out, that the engine introduced some strange chars into the filename string when I tried to construct it like this:%filename = %path @ %name @ "." @ %someid @ ".txt";
I fixed this with somewhat of a hack: I stripped the strange chars from my strings like this:
%path = "starter.fps/saves/"; %someid = %client.someid; %name = getTaggedString(%client.name); %len = strlen(%name); %name = getSubStr(%name, 2, %len - 3); %filename = %path @ %name @ "." @ %someid @ ".txt";
I used this to save some player stats, thus the use of %client.name. As I said, this works for me with TGE 1.2
Stefan.
#5
thanks for your help guys. turns out it wasnt implemented in my code! thanks for the link sam!
03/15/2004 (8:43 am)
Hey,thanks for your help guys. turns out it wasnt implemented in my code! thanks for the link sam!
Torque 3D Owner Stefan Rampp
new fileObject( "loadFile" ); %ok = loadFile.openForRead( %filename ); if(%ok == 0) { echo("Problem creating file for loading: " @ %filename); return; } else { loadFile.readLine(); //read your data } loadFile.close(); loadFile.delete(); //delete the fileObjectThis works for me. What code do you use?