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.

DarkBASIC Discussion / still have file save problem

Author
Message
The Rev
21
Years of Service
User Offline
Joined: 26th Apr 2004
Location: Mississippi USA
Posted: 5th Sep 2005 23:27 Edited at: 5th Sep 2005 23:30
I thought that the sync fixed the problem but it did not
What is happening is the file sometimes saves other times it does not
Attached is part of the code from a program I am writting the exe the graphic's and a test.txt file all this part of the program does is to delete then create a blank txt file but sometimes it deletes it but does not then recreate it. type in test for the file that is with it
oh one more think once it deletes it it won;t put it back but another file name will work then again the problem comes back on that one
If Anyone like to check the code or see if it deletes the file it is attached I can't figure what wrong. I am running a 500mz 128 meg ram 2 meg ati video card and win 98

Attachments

Login to view attachments
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Sep 2005 01:07
Sorry, but this is a prime example of spaghetti code which results from the use of Goto's. No wonder you can't figure out what's going wrong - I'm having difficulty following it at all!

To the best of my knowledge, the following snippet does what yours does...



OK, the problems you were having with your code (apart from leaping about a lot), were:

if g$="s" or g$="s" then goto s2
if g$<>"s" or g$<>"s" then goto 0

What's the difference between "s" and "s" (in both lines)?

if fh$="0" then goto 0

Oops! Where's fh$ come from lol!

By splitting your code into procedures, you can use Gosub to jump to that section and do the code there. Afterwards, the Return makes the program jump back to the next line after the Gosub. So there's no need for Gotos at all.

And, if something doesn't work, (like the file creation) you know exactly where to go to look for the problem.

In my snippet, you gosub menu1 which then Gosubs menu2 or quits. From menu2 you quit or jump to the create file procedure. After creating the file you drop back down the ladder to menu2, then menu1 and back into the main loop which then gosubs menu1 again ready to create a new file.

One continuous never-ending cycle without a single goto in site - and much easier to follow when things go wrong.

TDK_Man

The Rev
21
Years of Service
User Offline
Joined: 26th Apr 2004
Location: Mississippi USA
Posted: 6th Sep 2005 02:17
Fist off thanks for the reply
What's the difference between "s" and "s" (in both lines)?
it was a capital and small s I was use to doing that way over the upper$(
Oops! Where's fh$ come from lol! That was part of another section I had just cut this part as it was on makeing a dummy file
So the gosubs were the problem?? because I had put in
if file open(1)= 1 then print open
and also the one if it did not open they were put below the
file open write
and it showed the print statment file not open sometime and sometime it did
I'll try the code snipit
The program I am writing is a cartoon gag line maker it does a rnd of different things people places etc from they you try to come up with the gag It works well execpt for the saving and in the DB editor it never mess up only when I make the exe file does it not rewrite the file
I really Like to thank you So much for taking the time to check it
out and I let you know how it went when I redo it the way you recommend

Login to post a reply

Server time is: 2025-05-22 09:00:45
Your offset time is: 2025-05-22 09:00:45