erik.arfeuille@bib.kuleuven.ac
Guest
|
Post by erik.arfeuille@bib.kuleuven.ac on Mar 7, 2002 20:44:18 GMT
New at programming, I am writing a program to check my lottery numbers. What's wrong with the following.
ON ERROR GOTO Mistake CHDIR "C:\LOTTO" END Mistake: SELECT CASE ERR CASE 76 MKDIR "C:\LOTTO" RESUME END SELECT This program always halts on the CHDIR statement end never jumps to the Mistake: label. Why ? A very puzzled newbie. Erik Arfeuille
|
|
|
Post by brisray on Mar 7, 2002 21:41:19 GMT
I've no idea what is happening in your code. I copied it to QBasic and it works fine for me.
I use QBasic 1.1 on Windows 2000
If the error handler is in a subroutine then it won't work, but the message will be "Label not defined"
Is the error handler being entered into at all? Try F8 and stepping through the code or try putting print "now in error handler" before the MKDIR statement.
If you are on a network have you permission on the PC to make directories?
That's all I can think of for now
Ray
|
|
erik.arfeuille@bib.kuleuven.ac
Guest
|
Post by erik.arfeuille@bib.kuleuven.ac on Mar 8, 2002 8:58:03 GMT
I've no idea what is happening in your code. I copied it to QBasic and it works fine for me. I use QBasic 1.1 on Windows 2000 I use version 1.1 o, Windows 98If the error handler is in a subroutine then it won't work, but the message will be "Label not defined" No subroutine, what you saw was the entire 'test'-program.Is the error handler being entered into at all? Try F8 and stepping through the code or try putting print "now in error handler" before the MKDIR statement. As I mentioned, the error handler is not entered at all. Runtime error on the CHDIR statement.If you are on a network have you permission on the PC to make directories? No, just a stand alone PC.That's all I can think of for now I thought my problem sounded pretty weird too. Thanks for answering though.Ray
|
|
|
Post by fly@aol.com on Mar 8, 2002 17:40:27 GMT
tried running the test program, qbasic 1.0 on win95, works fine for me. perhaps you have a typo somewhere.
|
|
erik.arfeuille@bib.kuleuven.ac
Guest
|
Post by erik.arfeuille@bib.kuleuven.ac on Mar 9, 2002 15:22:11 GMT
tried running the test program, qbasic 1.0 on win95, works fine for me. perhaps you have a typo somewhere. Checked, doublechecked and checked again. No typos. I found out one funny thing though. I have a Dutch Windows 98 environment with a Dutch language QBASIC interpreter. Running the test program on my English Windows 98 environment with the Dutch QBASIC interpreter. No good. Using an English QBASIC interpreter on a Dutch Windows 98 OS. No good. But... The test program does work properly on an English QBASIC interpreter in an English Windows 98 OS.... Go figure. Erik
|
|
|
Post by fly@aol.com on Mar 9, 2002 18:48:43 GMT
I found out one funny thing though. I have a Dutch Windows 98 environment with a Dutch language QBASIC interpreter. Running the test program on my English Windows 98 environment with the Dutch QBASIC interpreter. No good. Using an English QBASIC interpreter on a Dutch Windows 98 OS. No good. But... The test program does work properly on an English QBASIC interpreter in an English Windows 98 OS.... Go figure.
I'll bet that the data used in the dutch programs in Windows somehow step on an area of memory that qbasic uses. try other languages and see which ones it works with and which ones it doesn't. after you get a list of successes and failures, perhaps you can call microsoft and talk to the people who did the language implementations. they might be able to find the problem and help you fix it.
|
|
erik.arfeuille@bib.kuleuven.ac
Guest
|
Post by erik.arfeuille@bib.kuleuven.ac on Mar 10, 2002 9:08:53 GMT
I discovered the source of all my troubles.
The answer is in Microsoft Knowledge Base article nr. Q45451 13-DEC-1989.
The code I quoted in this thread, was not the entire code I used in my program and which caused all the mayhem.
The reason why my program never entered the Error Handling routing, was an inappropriate use of the CLEAR command 'after' the ON ERROR GOTO command.
A quote from the article: "The CLEAR statement in a QuickBASIC program turns off error handling routines. Any error that happens after a CLEAR statement is not trapped by an error handling routine that was initiated before the CLEAR statement. To trap errors after a CLEAR statement, you must reinstate the error handling routine with a new ON ERROR GOTO clause."
So, it had nothing to do with the environment I was working in. The reason things worked with the English QBASIC interpreter in the English Windows OS was a fluke. The piece of code I experimented with in that environment did not contain the CLEAR statement.
RULE 1 OF PROGRAMMING: If something goes wrong, in 90% of the cases, you're the one to blame.
I guess this is the way, newbies like me learn.
Thanks everyone.
Erik Arfeuille
|
|