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 Studio Chat / [SOLVED] GetFirstFile not working as described in the documentation?

Author
Message
Ron2019
4
Years of Service
User Offline
Joined: 27th Jul 2019
Location:
Posted: 24th Oct 2019 23:55
I am running AppGameKit Studio V1.0 in Windows 10. I am simply trying to list all of the files in BOTH the project/media folder as well as the "Write Folder", which I have idenitifed as C:/users...AppData. Per the documentation here:

https://www.appgamekit.com/documentation/Reference/File/GetFirstFile.htm

An argument of 2 should read both locations. So, I added files to both locations, but:

This simple code never seems to retrieve from both locations, and appears to be returning different results depending on whether the project is being executed in RUN or DEBUG mode:



There is no other code in the project and I have changed no project level settings once I created the test project to demonstrate this, although I have twiddled various editor settings.

I've tried all four possible
settings and get this:

- The documentation suggests no parameter is the same as "2", yet using that setting only lists the files in one or the other location, depending on how the project is started:
RUN: ONLY Media folder contents in the project folder - NO write folder contents appear to be found
DEBUG: ONLY Media folder in C:\user...local - no Media Folder contents from the Project
are found

- Lists only the files in project media folder, as described by the documentation:
RUN: Media folder in C:\user...local
DEBUG: RETRIEVES NOTHING


- Lists only the files in write folder, as expected:
RUN: RETRIEVES NOTHING
DEBUG: Media folder in C:\user...local[

- Lists only the files in one or the other location, depending on how the project is started, just like using no parm above
RUN: ONLY Media folder contents in the project folder
DEBUG: ONLY Media folder in C:\user...local


I can find nothing about this online. Can somebody suggest what needs to be done to make it read both locations?

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 25th Oct 2019 04:39 Edited at: 25th Oct 2019 04:42
This post has been marked by the post author as the answer.
to be fair, the help doc states:
Quote: "Returns the name of the first file found in the current folder, which is set using SetFolder"


So, try literally setting folders/directories first?

I don't like SetFolder() but using OpenRawFolder() on both GetReadPath() (+"/media") & GetWritePath() seems work fine with GetFirstFile() & GetNextFile().
(doing them separately, of course. IE, no automatic "mode 2" behavior).

i know this isnt what you're looking for but suggesting another way to go about it (and, i've never used debug, so... )

adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 25th Oct 2019 06:19 Edited at: 25th Oct 2019 06:22
Run mode and debug mode have completely different read and write paths, which is confusing.

Run mode:
GetReadPath: project path
GetWritePath: %UserProfile%/AppData/Local/AGKApps/<project name>

Debug mode:
GetReadPath: AppGameKit Studio/media/interpreters/ (for AppGameKit Studio)
GetReadPath: App Game Kit 2/Tier 1/Compiler/interpreters/ (for AppGameKit Classic)
GetWritePath: %UserProfile%/AppData/Local/AGKApps/Windows/<project name>

When debugging, all non-0 length files are copied from your project's media folder to the GetWritePath/media folder.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 25th Oct 2019 07:32
If your still having problems you may find the plugin https://forum.thegamecreators.com/thread/219478

fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Ron2019
4
Years of Service
User Offline
Joined: 27th Jul 2019
Location:
Posted: 25th Oct 2019 15:54
adambiser - Thanks so much for the information! I first ran into this problem trying to find a file written by AppGameKit to the write folder. When I wrote the test code above to see what was happening, I created EMPTY files in each folder for testing. After reading your response I entered data into both files, and both were listed by GetFirstFile(2) in both modes as expected! I'd guess the file AppGameKit wrote out was empty, causing the issue to begin with.

I can find no reference to zero length or empty files in either the GetFirstFile or GetNextFile documentation pages. Could you please provide a link to the documentation where you found this?

Thanks, again!

Ron2019
4
Years of Service
User Offline
Joined: 27th Jul 2019
Location:
Posted: 25th Oct 2019 17:49
After a little more testing, it looks to me like GetFirstFile(2):
* Is listing the files in in both of these folders (in the order listed below) when executed in the IDE using RUN:
* AppData\Local\AGKApps\ReadFolderTest\media
* ReadFolderTest\media (project media folder)

* But when run in DEBUG mode:
* It copies files from the project media folder to \AppData\Local\AGKApps\Windows\ReadFolderTest\media. Note that:
 * This folder differs from the one referenced in RUN mode above.
 * But, it does not copy AppData\Local\AGKApps\ReadFolderTest\media folder contents when executing in RUN mode.
* It then appears to be reading just the files from that folder:
 * IOW, it doesn’t list files in the AppData\Local\AGKApps\ReadFolderTest\media folder.
* But OpenToWrite defaults to AppData\Local\AGKApps\ReadFolderTest\media.
* This makes it necessary to move output files written by OpenToWrite from AppData\Local\AGKApps\ReadFolderTest\media to \AppData\Local\AGKApps\Windows\ReadFolderTest\media in order to list and read them in DEBUG mode.
adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 25th Oct 2019 17:53
@Ron2019:
I discovered the non-zero-length file thing while typing the response above using trial-and-error mixed with confusion.
However, the non-zero-length part only affects the debug mode media copying process, only indirectly affecting GetFirstFile or GetNextFile. I really wish that the folders used in both modes were the same.
Ron2019
4
Years of Service
User Offline
Joined: 27th Jul 2019
Location:
Posted: 25th Oct 2019 18:02
adambiser - That's how I stumbled across it, as well. Tech support is aware and will hopefully document the difference on the GetFirstFile page, if they don't make the reference consistent in both runs. Thanks again for the info!

Login to post a reply

Server time is: 2024-04-25 08:19:33
Your offset time is: 2024-04-25 08:19:33