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 / How to interpret AGK-generated files with an external editor

Author
Message
Eqqman
9
Years of Service
User Offline
Joined: 15th Jul 2015
Location:
Posted: 4th Mar 2017 06:25
Hello-

I'm in desperate need of being able to dump out debugging information so I can process it outside of AGK. I had thought I could do this by simply writing out information to a file and then opening up that file with my text editor of choice, but as with many other things in AppGameKit, it doesn't work as expected. The command OpenToWrite(id, "myfile.txt", 0) doesn't actually create a file named "myfile.txt". Instead I get "bytecode.byc" and none of my apps in Linux Mint want to open this file. If I change the extension from BYC to TXT the text editor just crashes. This initially led me to think the file I/O was broken, but the OpenToRead() function does work on "files" I made with OpenToWrite(). But this doesn't help me as I want access to my data outside of AGK. Are there any suggestions?
Goo Goo G\'Joob!
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 4th Mar 2017 06:51 Edited at: 4th Mar 2017 06:55
Hi Eqqman. I think you've slightly misunderstood what's going on here. bytecode.byc is nothing whatsoever to do with your OpenToWrite command. This file contains the compiled AppGameKit bytecode used by the interpreter. Compiling any AppGameKit program, regardless of whether it creates any files or not, will always cause a bytecode file to be created. If you've not changed the directory explicitly, files created with OpenToWrite usually end up in <DRIVE>:\Users\<UserName>\AppData\Local\AGKApps\<AppName>\media. Have a look and see if myfile.txt exists in there.

EDIT: Sorry, just saw you're on Linux so that path won't be correct for you (that's the Windows path). I would expect it to be put in a similar user data folder on Linux though. Maybe someone else here has the exact path to hand?
Eqqman
9
Years of Service
User Offline
Joined: 15th Jul 2015
Location:
Posted: 4th Mar 2017 07:53
Thanks for the clarification!
I've done a search using the built-in tool for Mint under both the `Home` folder and for the computer in general, and had no luck.
Goo Goo G\'Joob!
Eqqman
9
Years of Service
User Offline
Joined: 15th Jul 2015
Location:
Posted: 4th Mar 2017 08:06 Edited at: 4th Mar 2017 08:07
Found it with this terminal command:

The path was:
./home/[username]/.config/AGKApps/WritingToFile/media/myfile.txt
...so it's in a hidden system folder, and I didn't find any settings in AppGameKit that would let me change this folder. The sad news here is that "myfile.txt" would not open since the Mint text editor says it can't detect the encoding. Seeing where these files go, I was able to track down the one I created myself and it did at least open, although the data didn't make sense.

Edit: note that "WritingToFile" is a project name, as each project gets its own folder.
Goo Goo G\'Joob!
Lucas Tiridath
AGK Developer
16
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 4th Mar 2017 08:54
Well done tracking down the file.

Quote: " I didn't find any settings in AppGameKit that would let me change this folder"

Did you try any of the AppGameKit commands like SetRawWritePath or SetFolder?

Quote: "The sad news here is that "myfile.txt" would not open since the Mint text editor says it can't detect the encoding."

Whether you can open the file in a text editor will depend on what you have written into the file. If you want to create files containing human readable text, you need to use the WriteLine command. All the other WriteX commands write the data in a binary format rather than a text character encoding.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Mar 2017 09:15
Quote: "SetRawWritePath "

I don't think this is available on Linux. Any command containing "raw" is made for a specific platform, in this case Windows.

A generic text editor should allow you to open the file. In Windows I use Notepad++ which defaults to UTF-8 but can be changed.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Blendman
10
Years of Service
User Offline
Joined: 17th Feb 2014
Location: Arkeos
Posted: 4th Mar 2017 09:26
Hi

To find you path folder, you can use : GetWritePath()

To change your write folder, have you tried to use SetFolder() ?
AGK2 tier1 - http://www.dracaena-studio.com
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 4th Mar 2017 15:07
Quote: "would not open since the Mint text editor says it can't detect the encoding."


Sounds like you used WriteString instead of WriteLine

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 4th Mar 2017 23:44
If you want to view and edit the file, you'll need to use a hex editor. The WriteInteger command has nothing to do with ascii encoding, so a text editor is pretty useless. WriteLine (and ReadLine) both work fully with ascii encoding so if you exclusively use those commands a text editor will be fine (use chr() to turn an integer/float into a string and Val({)/ValFloat to read it back into a number). I'm not sure how WriteString is encoded but I'm pretty sure it's unreadable with a text editor.
Good hex editors for Linux

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Mar 2017 06:30
Quote: "If you want to view and edit the file, you'll need to use a hex editor."

The agk file is stored in plain text, set up like an ini file. He can view it with notepad.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
easter bunny
11
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 5th Mar 2017 07:00
Quote: "The agk file is stored in plain text, set up like an ini file. He can view it with notepad."

Waittttt, isn't he talking about files created with OpenToWrite() and WriteInteger(), WriteString() and WriteLine()?

My Games - Latest WIP - My Website: Immortal.Digital - FB - Twitter
130,000 installs with AppGameKit and counting
Eqqman
9
Years of Service
User Offline
Joined: 15th Jul 2015
Location:
Posted: 5th Mar 2017 07:18 Edited at: 5th Mar 2017 07:19
Quote: "Waittttt, isn't he talking about files created with OpenToWrite() and WriteInteger(), WriteString() and WriteLine()?"

Yes. I'll make sure I use the text commands exclusively and see what happens. Thanks all!
Goo Goo G\'Joob!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Mar 2017 16:41
Oh, I thought he was referring to the project AppGameKit file.

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Login to post a reply

Server time is: 2024-09-29 23:26:28
Your offset time is: 2024-09-29 23:26:28