forums

TNT Basic Forums > Programming Q&A
Error: Could not create file
< Last Thread     Next Thread >
Author
Thread        Post A Reply

03-10-2004 23:56

Posted by:
kemalyun

Location:
Frankfurt/Germany

Find more posts by kemalyun

This code:

set directory game
datei = create file("register.dat","TEXT","Text")
for curs=1 to string length(s)-1 step 2
file write datei,mid str(s,curs,2)
next curs
close file datei

gives me an "runtime exception caught: could not create file" in the "datei= create file" line. strange thing is, it creates the file and writes the string-data into it. When I quit Tnt and check the directory, the file is there and the contents are right.

So why that error and why does it still create the file?

03-11-2004 05:22

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

My guess is that it created the file the first time you ran it, and now the file creation doesn't work; if the file is already there, TNT can't make one. Try deleting the file and then running the code.

03-11-2004 09:55

Posted by:
kemalyun

Location:
Frankfurt/Germany

Find more posts by kemalyun

No,

no, that's not it. There is no file of that name there before, and after I run the app, the file is there and even the contents are right, meaning the code must has been executed to the end, but it still gives me that error.

Is there a way to "trap" an error in TNT? Like

on error procedurename()

or something?

03-11-2004 19:01

Posted by:
puffin

Click Here to Email puffin   Find more posts by puffin

i don't think that was what eekaydee was saying. it could work fine the first time and create a file, but any other time you try to create a file, one with that name already exists in that location, so it can't create the file.

so did it work without error the first time you ran it?

03-12-2004 13:11

Posted by:
kemalyun

Location:
Frankfurt/Germany

Find more posts by kemalyun

yes

I found it! Because of a bug in the "recognize the registration-code" routine, the "create reg-code file" routine was executed twice, so it first created the file and then, 2nd time, the error occured. Damn ... that was tricky. Anyway thanks for the help!

03-12-2004 13:27

Posted by:
eekaydee

Location:
CA, USA

Click Here to Email eekaydee   Find more posts by eekaydee

Ahh, that is pretty tricky!

All times are GMT        Post A Reply

Forum Jump:
< Last Thread     Next Thread >

< Contact Us - TNT Basic >

Powered by: vBulletin Lite Version 1.0.1 Lite
Copyright © Jelsoft Enterprises Limited 2000.