Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / OpenToWrite() problem.

Author
Message
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 30th Dec 2011 07:25
Why isn't this working?. It doesn't matter if I set the append flag to 0 or 1 and doesn't make a difference what kind of data I'm writing to a file; WriteFloat()/WriteInteger()/WriteLine()/WriteString(); the file extension deosn't make any difference either, no changes appear in the file.

I wrote the following piece of code to confirm my suspicions.

The file "test.txt" is in the media folder. The program examples in the "AGK\Projects\Basic\Examples\Files" don't seem to be working either.

Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 30th Dec 2011 08:06 Edited at: 30th Dec 2011 08:12
What's even more weird, if I run the program below I get the data on the screen but any file in the media folder doesn't get changed, the file isn't created in the media folder if it doesn't already exist either.

I'm coding my own level editor, so I really need the file to be in the folder so that I can copy and paste it into any game projects.

Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 30th Dec 2011 08:19
Quote: "the file isn't created in the media folder if it doesn't already exist either."

No it won't be.

It'll be created (on pc at least) in the "My Documents > AppGameKit > FULL_PATH_TO_AGK_PROJECT\" folder

As AppGameKit runs in a sandbox, you do not have write permissions to anywhere but a set folder. Anything using the write/read commands need to be located here.

My signature is NOT a moderator plaything! Stop changing it!
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 30th Dec 2011 08:33
I am using a PC and I'm attempting to use the files relative to the project folder.
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 30th Dec 2011 09:01
Open to write will not write to the project folder, but to the my documents folder.

My signature is NOT a moderator plaything! Stop changing it!
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 30th Dec 2011 09:21 Edited at: 30th Dec 2011 09:25
Thanks for that, I get what you mean, I can get on with the project now. You've been extremely helpful.

I thought I was going to have to revert back to DBPro or Blitz3D to do my tool making for a moment there. LOL
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Dec 2011 13:07
Another handy tip - on Android (And possibly others) the file is empty if the program doesn't close it (ie the program crashes). I use it for debugging, and have a system whereby the file gets closed and reopened regularly so that I have something to look at if the program bombs out.

On PC, it works ok, the data seems to be written immediately.

badkneecap
13
Years of Service
User Offline
Joined: 21st Jun 2010
Location:
Posted: 30th Dec 2011 18:56
Steve, I have another thread where I was having similar problems. First, if you search on your C drive for "text.txt", you will see that it is being created as Mobiius stated.

I was having trouble with my app overwriting files using the append=0 parameter in the WriteToFile function. I just found the problem. I have to run the compiled .exe as the "administrator" on my computer. I'm running Vista and I have run across this problem before. It a pain. I have to compile, file the .exe in file explorer, right click, and select to "run as adminsitrator".

This solved it for me. What OS are you running?
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 30th Dec 2011 19:25 Edited at: 30th Dec 2011 19:26
I'm running Windows XP.
Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 30th Dec 2011 19:28 Edited at: 30th Dec 2011 19:30
If it saves files to MyDocuments, how does it store game progress and score data on a device?.

[edit]I have an iPod touch but don't have a Mac to compile stuff on, so I haven't had chance to experiment properly yet.[/edit]
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 30th Dec 2011 20:08
Quote: "If it saves files to MyDocuments, how does it store game progress and score data on a device?"


Every platform has a "safe storage" folder. On Android it is a subfolder of your AppGameKit executable.

Steve Ancell
18
Years of Service
User Offline
Joined: 16th Feb 2006
Location: Brighton, East Sussex, UK
Posted: 31st Dec 2011 20:54
Thanx for your help, I understand now.

Login to post a reply

Server time is: 2024-04-20 10:35:08
Your offset time is: 2024-04-20 10:35:08