Qbasicnews.com
April 03, 2020, 09:14:03 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Back to Qbasicnews.com | QB Online Help | FAQ | Chat | All Basic Code | QB Knowledge Base
 
   Home   Help Search Login Register  
Pages: 1 [2]
  Print  
Author Topic: If I could bother you guys once again...  (Read 9024 times)
relsoft
*/-\*
*****
Posts: 3927



WWW
« Reply #15 on: February 15, 2003, 02:56:24 AM »

This word is somehow very disturbing....

"masturba "

LOL
Logged

y smiley is 24 bit.


Genso's Junkyard:
http://rel.betterwebber.com/
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #16 on: February 15, 2003, 07:50:57 AM »

Programmer, musician, poet... Nathan, you are really a renassaince man! :rotfl:
Could you put music to your poem?
Logged

Antoni
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #17 on: February 15, 2003, 11:10:10 AM »

Hahahahaha - Nope, that poem is conceived to be sang without music and standing dressed like Shakespeare in the top of a big can full of beer.
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
joey7643
Member
*
Posts: 59


« Reply #18 on: February 15, 2003, 12:12:04 PM »

I have figured out my problem with my second question. However, I have been trying a while to get an error-message system working in my program for sometime. How would I setup something that when an error occurs (say error #54) I would like a message to display "Bad file mode."

I have looked through many examples, but I can't seem to get it working.

Thanks again, also for your help with my first problem/question. I have it working now.
Logged
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #19 on: February 15, 2003, 12:37:02 PM »

It's  going to detect things like that before your error handler gets to it anyway.
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Piptol
Ancient QBer
****
Posts: 422



WWW
« Reply #20 on: February 15, 2003, 12:39:05 PM »

Quote from: "Hexadecimal Disaster"
And if I'd written that in English, the poem would not rhyme.  :roll:


Maybe not, but this does: Wink

Hex posted vulgarities,
In a language few understand,
But wildcard had learnt spanish,
And *somebody* got banned!
Logged

In a world without walls and doors, who needs Windows and Gates?
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #21 on: February 15, 2003, 01:34:32 PM »

Quote from: "joey7643"
I have figured out my problem with my second question. However, I have been trying a while to get an error-message system working in my program for sometime. How would I setup something that when an error occurs (say error #54) I would like a message to display "Bad file mode."

I have looked through many examples, but I can't seem to get it working.

Thanks again, also for your help with my first problem/question. I have it working now.


Well, just add an ON ERROR to your code (this is something that I dislike, but well).

At the top:

Code:
ON ERROR GOTO errorhandler


And somewhere:

Code:
errorhandler:
PRINT "Error number : "; ERR
PRINT "Press a key": SLEEP: k$=INKEY$
RESUME NEXT


I dislike this 'cause it makes your EXE a lot bigger and slower. But if you are not in a speed-intensive application (i.e. a game) then it is ok Wink
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
joey7643
Member
*
Posts: 59


« Reply #22 on: February 16, 2003, 10:56:26 AM »

Thanks, that is what I needed na_th_an.

Thank you all for your help  Cheesy  Smiley
Logged
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #23 on: February 16, 2003, 05:08:50 PM »

ON ERROR only makes the app slower where it's activated. If you put an ON ERROR GOTO 0 past the part where you need the errors to be trapped, your overall code will not suffer from lack of speed.
Logged

Antoni
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #24 on: February 16, 2003, 05:11:55 PM »

Nice to know, Antoni... err

How do you know ALL THAT STUFF?? Cheesy (should I RTFM??)
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Antoni Gual
Na_th_an
*****
Posts: 1434



WWW
« Reply #25 on: February 16, 2003, 05:31:56 PM »

I ask Glenn, the only one who has TFM  Cheesy

(Now seriously: I think I read  it at Ethan Winer's book.)
Logged

Antoni
na_th_an
*/-\*
*****
Posts: 8244



WWW
« Reply #26 on: February 16, 2003, 07:16:24 PM »

I downloaded that book a whole lot ago... Maybe I should RTFEWB... (new acronym)
Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Neo
Na_th_an
*****
Posts: 2150



« Reply #27 on: February 17, 2003, 07:17:20 AM »

Perhaps... (RTFM? NO!!! Even I knew that LoL)
Logged
Hexadecimal Disaster
Been there, done that
*****
Posts: 1123



« Reply #28 on: February 18, 2003, 01:09:40 AM »

Kinda late, but... I had some life to live.



Quote from: "from Mr. Ethan Winer's book"
The conventional way to handle errors is to use ON ERROR, and design an error handling subroutine. There are a number of problems with using ON ERROR, and most professional programmers try to avoid using it whenever possible. But ON ERROR does work, and it is often the simplest and most direct solution in many programs. The short listing below shows the minimum steps necessary to implement an error handler using ON ERROR.

Code:
ON ERROR GOTO HandleErr
FILES "*.XYZ"
END
HandleErr:
SELECT CASE ERR
CASE 53: PRINT "File not found"
CASE 68: PRINT "Device unavailable"
CASE 71: PRINT "Disk not ready"
CASE 76: PRINT "Path not found"
CASE ELSE: PRINT "Error number"; ERR
END SELECT
RESUME NEXT

The statement ON ERROR GOTO HandleErr tells BASIC that if an error occurs, the program should jump to the HandleErr label. Without ON ERROR, the program would display an error message and then end. Since it is unlikely that you have any files with an .XYZ extension, BASIC will go to the error handler when this program is run. Within the error handling routine, the program uses the ERR function to determine the number of the error that occurred. Had line numbers been used in the program, the line number in which the error occurred would also be available with the ERL function. In this brief program fragment, the most likely error numbers are filtered through a SELECT CASE block, and any others will be reported by number. Regardless of which error occurred, a RESUME NEXT statement is used to resume execution at the next program statement. RESUME can also be used with an explicit line label or number to resume there; if no argument is given BASIC resumes execution at the line that caused the error. In many cases a plain RESUME will cause the program to enter an endless loop, because the error will keep happening repeatedly. In this case, the file will not exist no matter how many times BASIC tries to find it. Therefore, a plain RESUME is not appropriate following a "File not found" or similar error. Had the error been "Disk not ready", you could prompt the user to check the drive and then press a key to try again. In that case, then, RESUME would make sense.

Although BASIC's ON ERROR can be useful, it does have a number of inherent limitations. Perhaps the worst problem with ON ERROR is that it often increases the program's size. When you use RESUME NEXT, you must also use the /x compile switch. Unfortunately, /x adds internal address labels to show where each statement begins, so the RESUME statement can find the line that caused the error. These labels are included within the compiled code and therefore increases its size.

Another problem with ON ERROR is that it can hide what is really happening in a program. I recommend strongly that you REM out all ON ERROR statements while working in the QuickBASIC editing environment. Otherwise, an Illegal function call or other error may cause QuickBASIC to go to your error handler, and that handler might ignore it if the error is not one you were expecting and testing for. If that happens and your program uses RESUME NEXT, you might never even know that an error occurred!

Yet another problem with ON ERROR is that it's frankly a clumsy way to program. Most languages let you test for the success or failure of the most recent operation, and act on or ignore the results at your discretion. Pascal, for example, uses the IOResult function to indicate if an error occurred during the last input or output operation.

Finally, BASIC generates errors for many otherwise proper circumstances, such as the FILES statement above. You might think that if no files were found that matched the .XYZ extension given, then BASIC would simply not display anything. Indeed, an important part of toolbox products such as Crescent Software's QuickPak Professional (shameless plug, eh? - Hex) are the routines that replace BASIC's file handling statements. By providing replacement routines that let you test for errors without an explicit ON ERROR statement, an add-on library can help to improve the organization of your programs.


And now the interesting part:

Quote
As I mentioned earlier, some errors can be avoided by using CALL Interrupt to access DOS directly. (One important DOS service lets you see if a file exists before attempting to open it.) But critical errors such as those caused by an open drive door require assembly language. In Chapter 12 you will learn how to bypass BASIC and access DOS directly using CALL Interrupt.



*breathes deep*


Now, back off topic:

Quote from: "Pipster"
Maybe not, but this does:  

Hex posted vulgarities,
In a language few understand,
But wildcard had learnt spanish,
And *somebody* got banned!


No sir, that doesn't rhyme. Ask Plasma357 for some music lessons. (he composed a nice rhyme about me at the old QB45 forum) And smile. Keep smiling.
Logged

img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Glenn
I hold this place together
*****
Posts: 786



WWW
« Reply #29 on: February 18, 2003, 02:38:00 AM »

errors such as an open drive door wouldn't cause a problem for the INTERRUPT/INTERRUPTX routines if not for a bug in QB.QLB/QB.LIB.  The Redmond Mafia actually (at one time) released new routines (complete with ASM source code) at their website with the bug fixed.  But true to their nature, in fixing the bug they made the routines worse.  The "fixed" routines wouldn't let you use the BP register.  (So I'm still using the old ones.  I need that register.)



Quote:
As I mentioned earlier, some errors can be avoided by using CALL Interrupt to access DOS directly. (One important DOS service lets you see if a file exists before attempting to open it.) But critical errors such as those caused by an open drive door require assembly language. In Chapter 12 you will learn how to bypass BASIC and access DOS directly using CALL Interrupt.
Logged

ravelling Curmudgeon
(geocities sites require copying and pasting URLs.)
I liked spam better when it was something that came in a can.
Windows should be defenestrated.
Pages: 1 [2]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!