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 DBPro Corner / FILE OPEN () doesn't work for files opened to write

Author
Message
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Dec 2011 01:36
Check out the code.
Is this just me, or is there a misrepresentation of the use of the FILE OPEN() command in the help files?
Seems like whether the file is opened to read or to write should be irrelevant and the FILE OPEN() command should result in true in both cases.



Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Dec 2011 02:09 Edited at: 5th Dec 2011 02:40
OK, maybe this is just me, because now I'm getting a
file is not open runtime error when I'm trying to write a memblock to file.
I swear it was OK before.



What the heck


EDIT:

OK so... ya noob error... I guess the file can't actually exist when you OPEN TO WRITE... annoying, but I've figured it out.
Ugh... wish I could delete post.

MrValentine
AGK Backer
13
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 5th Dec 2011 02:50
This could still be expanded upon... I atill see or feel some sort of error in your code... guess I will only find out in future...

Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 5th Dec 2011 16:11
Yeah the error was that I created the file via a make file command and then executed the open to write command.
The open to write command will fail (without a runtime error) if the file it calls (in this case ugh.txt) has already been created.

Correct code:



The lesson here:
Use if file exist(filename$) then delete file filename$
before open to write file_number,filename$

And make sure that filename$ is very unique (or in a new directory or something) so you don't delete the wrong file!

Login to post a reply

Server time is: 2024-05-20 06:39:13
Your offset time is: 2024-05-20 06:39:13