Page 1 of 1
New errors: next without for and file already open
Posted: Mon Sep 20, 2010 11:58 am
I have used Qbasic for 15 years and written a ton of programs for scheduling, math, etc. Currently working on a combinatorics problem that was working really well up until yesterday. Suddenly, when attempting to run one of my programs, got a "next without for" error, but the "next" and "for" are clearly there; and got an error in another program of similar structure saying that a "file already open", when trying to open an output file. I've rebooted computer, used task manager to close everything, deleted the so-called already open file, changed file name, moved my programs to another computer with qbasic on it- all to no avail, same errors. I can still run some older programs, eg one which takes a permutation in cycle form and converts into line form, that I wrote just a few days ago. Anyone have any ideas. Please help, as I was looking at the relationship of permutation class structure and number of latin squares of a certain size and hoping to gain insight into same with my programs. Any help greatly appreciated!!
Posted: Mon Sep 20, 2010 3:36 pm
Next without FOR? Look for a missing END IF
File already OPEN? Look for a file number that may already have been opened for another file. Don't forget to CLOSE a file before using the same #.
CLOSE closes all files. Just type that in the Immediate window and hit enter.
Posted: Mon Sep 20, 2010 4:00 pm
Thanks, I already found the next w/out for problem and it's exactly as you said, but in my haste to run the program I guess I thought it had run before after I created some new else, end ifs. I'll try your suggestion for the other one. I may not need to resolve it, since I have the results I need.
Now to make sense of it!
Posted: Mon Sep 20, 2010 4:43 pm
Tried what you suggested re the file already open. I never use same # for my I/O files and always close them when no longer needed. I did bring up the output screen and saw output that could not have been there from running the program to the point where I got the error as if the program is still trying to write from an earlier time. I've never used the immediate window, but I typed close in it and hit enter, but no luck. I even typed it in the program prior to the offending statement both with and without the number and ran it. I'm thinking of opening a new file and cut and paste all but the offending statement and then entering it in the new program.
Posted: Mon Sep 20, 2010 4:59 pm
I found the error! Dumb me! I had left the open statement inside a do loop so it was coming back to it and the close statement was outside all the loops, so it was right the file was already open. Funny how computers do what you tell them to do, not what you want them to do. Maybe someone else will benefit from this snafu. Thanks so much again.
Posted: Mon Sep 20, 2010 7:34 pm
YEP, they are not so smart. You can actually have a computer kill itself LOL.
They ALWAYS do what your code tells them to do! Then when you find the error, it laughs at YOU!
Posted: Sat Oct 02, 2010 2:25 am
thanks for the info you given..
just continue doing good..
thanks a lot and God Bless..
how to treat depression
Posted: Sat Oct 02, 2010 9:29 am
Well thankyou Stone, I appreciate the thank you!
If you EVER have a problem, just ask and welcome to the forum. I see you just joined. You can put your location and stuff in your profile if you want.
People come here from all over the world.
Posted: Tue Oct 05, 2010 2:08 am
You really do.,thanks for this info.
Share this to others to make some worthy information.
Posted: Wed Oct 06, 2010 6:46 pm
Famous last words of a programmer named Fumblefingers:
"My program ran great yesterday, but today it doesn't.
All I changed was only a comment."