Just want to write text to disk.
by Shane · in Torque Game Builder · 10/01/2009 (7:19 pm) · 4 replies
So i want to write some data to disk..ran across some helpful things such as:
function writeFile()
{
%file = new FileObject();
if(%file.openForWrite("~/data/test.txt"))
{
%file.writeLine("Hello World!");
echo("File Written");
}
else
{
error("File is not open for writing");
}
%file.close();
%file.delete();
}
yet this doesn't work at all...I can even search my harddrive and test.txt is no where to be found. How hard is this really? I ran across some threads that explained this is an issue , I am running 1.7.4 on windows Xp. I just want to write out a file, at this point i don't even care where it ends up...
So I try the above, all looks good, but alas nothing gets written in reality. This is maddening.
Shane
function writeFile()
{
%file = new FileObject();
if(%file.openForWrite("~/data/test.txt"))
{
%file.writeLine("Hello World!");
echo("File Written");
}
else
{
error("File is not open for writing");
}
%file.close();
%file.delete();
}
yet this doesn't work at all...I can even search my harddrive and test.txt is no where to be found. How hard is this really? I ran across some threads that explained this is an issue , I am running 1.7.4 on windows Xp. I just want to write out a file, at this point i don't even care where it ends up...
So I try the above, all looks good, but alas nothing gets written in reality. This is maddening.
Shane
#2
Thanks again!
Shane
10/02/2009 (1:50 pm)
I'll be that did it, the odd thing is it never showed up in the windows search, perhaps that folder is hidden form search? In either case that did it...and when you say change the config, that is the file that gets changed when you make a build and specify the company name and game name right?Thanks again!
Shane
#3
I'm glad it worked. And yep, the config file is set when you "build" and specify the names. Although, you can just change it now... it's in your game's common directory as commonConfig.xml.
Later!
10/02/2009 (1:59 pm)
Even if I tell Windows to find hidden files, it _never_ finds stuff in the Applicaton Data directories! (Oh well.)I'm glad it worked. And yep, the config file is set when you "build" and specify the names. Although, you can just change it now... it's in your game's common directory as commonConfig.xml.
Later!
#4
thx again for ur help.
01/04/2010 (2:17 am)
ths, really can not imagine if everything like this, and without any guidance or hints, must be mad..thx again for ur help.
Associate William Lee Sims
Machine Code Games
%appdata%/MachineCodeGames/Goetia/game/data/test.txt
You can go to "Start > Run" and type in "%appdata%" to find that directory. If you haven't changed the config, yours will probably be in %appdata%/Independent/UntitledGame/game/data.
The reason for this is that post-XP, you cannot write to the install directory. GG modified the engine to have it write to the Application Data directory (which is the proper way, anyway).
Hope that helps!