Skip to main content
GameDev.net gamedev.net
🔒 Locked

[web] Read/Write .txt

Started by Centanoul Sep 2, 2005 at 6:33 PM 3 replies 950+ views
Original Post
Centanoul
Centanoul
I am about finished writing a little game in &#106avascript. Is there anyway that I can write the scores to a txt file and read scores back with &#106avascript? I would only need commands like these: Doc = OpenDocument(name.txt) ReadDocument(Doc, CharToRead) WriteDocument(Doc, "String") CloseDocument(Doc) If not...what other language could read and write such variables to a txt file? And what are the commands? (Without getting into server side scripting. I am renting a domain, not a server.) Thank you ~Cent
Deranged
Deranged
Well you have to have a server, thats where the files are, and the server serves them up..., Anyways, the other ones I know of are server side, and they are PHP ASP and ColdFusion.
Centanoul
Centanoul
Site-Building Tools
Supports CGI Scripts: Perl, Python, PHP3, PHP4, PHP5

Would that let me do it with PHP? Or are CGI scripts different from what I need? And if it will do so, can you point me to the commands to open/close/read/write? I can't seem to find them lieing in any tutorial.
(would rather not pay 70$/month for a server)

~Cent
Talonz
Talonz
I don't know &#106avascript very well but I imagine that it would pose a security risk if you could do that hehe.<br><br>http://www.w3schools.com/php/php_functions2.asp<br><br>Try that page if you want to use PHP to write files, but I don't know how you would incorporate it into your &#106avascript game. Maybe have a submit score button or something that takes them to the next page, but then you'd have to make it really secure.
Sander
Sander
The easiest way to solve this would be to use a small PHP or CGI script to write the scores to a file on the server and use an XMLHttpReuest object to call that script from inside your &#106avascript game.<br><br>Take a look at <a href="http://www.w3schools.com/dom/dom_http.asp">http://www.w3schools.com/dom/dom_http.asp</a>

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.