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.

Newcomers AppGameKit Corner / Opening and closing files

Author
Message
tasmanian guy
14
Years of Service
User Offline
Joined: 29th Jun 2010
Location: Australia
Posted: 3rd Nov 2017 01:52
Hi,

Can someone provide a simple example of opening a file, for example file1.txt
Closing the file.
And then opening a different file, for example file2.txt

I was hoping it was as simple as:

OpenToRead ( 1, "myfile1.txt" )
CloseFile ( 1 )
OpenToRead(2,"myfile2.txt")
CloseFile(2)

Is the above code correct?

Thank you.
DBPro is the new Amos (I hope)
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 3rd Nov 2017 04:22
Yes it is. You can also use

f = OpenToRead("myfile1.txt")
Close(f)


Things to keep in mind;

1. IOS/Android/Linux filenames are case sensitive so if you say OpenToRead(1, "MyFile.txt") and the name of the file is "myfile.txt" then the open will fail on those devices but not on windows

2. Output files are not created in the "media" directory on windows they are created in /Users/{your id}/AppData/Local/AGKApps/{Your app name} (I have no idea where they are created on ISO/Android etc)

Login to post a reply

Server time is: 2024-11-22 20:12:07
Your offset time is: 2024-11-22 20:12:07