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 / [SOLVED] fileIsOpen problems

Author
Message
Brian Lancaster
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 26th Jun 2020 19:52 Edited at: 26th Jun 2020 19:53
I'm trying to make a scripting language with notepad like I did with my DarkBASIC game. I want these TXT scripts to open other TXT scripts with a "callscript" command in notepad. In DarkBASIC, I did this with the "file open" to check to see if a file index is currently open.

In AppGameKit, I'm trying to use the "fileIsOpen" command, but I get the error message: "File 1 does not exist". I thought the command was to check whether the file is open in the program or not. Is there some other command that I'm missing? I want a command to check whether the current file index is open in the program so I can keep track of nested scripts.

Thanks.

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

Go to answer

Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 26th Jun 2020 21:20
this works as intended for me:
Brian Lancaster
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 26th Jun 2020 21:54 Edited at: 26th Jun 2020 22:04
I want to test it when it's not open, though. And it says, "File not found".

EDIT: I'm not sure what the point of the command is. It's supposed to test whether a file is open or not, and if it's not open, it crashes the program. Pretty sure it's AppGameKit bug. I will probably have to work around it with variables.
SFSW
21
Years of Service
User Offline
Joined: 9th Oct 2002
Location:
Posted: 26th Jun 2020 22:11
This post has been marked by the post author as the answer.
This is one of the commands where you need to change the error mode before executing to prevent a stop error. For whatever reason(s), if the index doesn't already exist, it will stop your app to report it. So instead of just the command by itself, just preface with the error mode change, the restore the error mode after the check:



So 'FileState' will be 0 if it truly isn't open without stopping your app/game, or 1 if it does exist and is open.
Brian Lancaster
10
Years of Service
User Offline
Joined: 20th Dec 2013
Location: Oakland, CA
Posted: 26th Jun 2020 22:20
@SFSW Yes! It worked. Thanks so much.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 26th Jun 2020 23:31
I think that command will tell you if a particular file handle is open.
If the same file is opened using another handle it won't report that

Login to post a reply

Server time is: 2024-03-28 14:42:15
Your offset time is: 2024-03-28 14:42:15