green text is being edited and should not be considered
relevant to the tutorial. for a while, it will make up
the bulk of this section.
black text has been edited to be more accurate with
regards to puppybasic.
........................................................................
errors
1 of 10
an intro to puppybasic
chapter 14: errors
........................................................................
........................................................................
errors
2 of 10
you could do well to always trap and handle errors, i almost never
bother. if you write your program well, you might manage to avoid it.
this applies less to large programs. of course, sometimes error trapping
is quite useful.
whether you use error handling or not, your program, upon encountering
an error, can tell the user the name of the error. if you do not trap
your errors, the program will end as well. if you do use error handling,
you have the option of telling the user a more friendly interpretation
of the problem:
"I'm sorry, no file by that name exists in this folder."
........................................................................
........................................................................
errors
3 of 10
or even fixing it so the program can continue:
"That file does not exist. Create? (Y/N)"
you can even trap errors to detect which screen modes don't work. as
mentioned in the graphics section, there are several screen modes in
puppybasic, and they start with SCREEN 0, or text-only mode and range
from 0 to 13. so, you can tell your program to go to all the possible
screen modes: (none of this is true, this tutorial is being edited.)
........................................................................
........................................................................
errors
4 of 10
okscreen$ = SPACE$(14)
ON ERROR GOTO oops
FOR q = 0 TO 13
SCREEN q
NEXT q: nomorec = 1
and then when it tries to SCREEN [not an available mode] it will cause
an error 5, and GOTO the "oops" routine:
........................................................................
........................................................................
errors
5 of 10
oops:
IF nomorec = 0 THEN
IF ERR = 5 THEN MID$(okscreen$, q + 1) = "x"
END IF
RESUME NEXT
which adds an "x" under the part of the variable okscreen$ for that
mode.
........................................................................
........................................................................
errors
6 of 10
the command RESUME NEXT tells the program "don't worry about that last
error..." and the program then runs the next line, which is the "NEXT q"
of the FOR... NEXT loop.
when you're done trying all the modes, you can go back to SCREEN 0,
which is the default, and should always work:
SCREEN 0: WIDTH 80 'WIDTH 80 should always work, otherwise, remove it.
then print a guide for the numbers 0 to 13:
........................................................................
........................................................................
errors
7 of 10
PRINT " 1111"
PRINT "01234567890123"
and under that:
PRINT: PRINT okscreen$
END 'don't forget to put an END statement between
'your program and routines.
now your program will put a little "x" under the modes that don't work
on your computer!
........................................................................
........................................................................
errors
8 of 10
if we went over this section too fast: here is a review:
ON ERROR... GOTO linelabel
tells the program what routine to goto when an error occurs. there is no
"ON ERROR... GOSUB."
IF ERR=n THEN
will do something in response to the specific error... (you can also use
"SELECT CASE ERR" for handling this part.)
........................................................................
........................................................................
errors
9 of 10
RESUME NEXT
goes back to the part of the program where the error occured, but it
goes to the first line AFTER the problem.
note: error code 5 is "illegal function call" - the error you get when
you try to change to an unavailable mode, although there are other
possible causes.
........................................................................
........................................................................
errors
10 of 10
there are at least a couple other commands for error handling, but
unless you want them enough to look them up, you probably won't ever
need them.
-= end of chapter 14 =-
........................................................................
an intro to puppybasic (chapter 14)
this content is public domain.
........................................................................
click here to go back to the contents page
Before You Post, Please Note...
-> Please Note: By Posting, you agree to submit the contents of your post to the Public Domain <- SEE: howto post to this blog
Friday, February 2, 2007
puppybasic intro ch. 14 - errors
Subscribe to:
Post Comments (Atom)
26 comments:
xanax online xanax online to buy - qualitest 2mg xanax
xanax online xanax bars 5mg - buy xanax 3mg online
buy tramadol cod tramadol addictive properties - tramadol 50 mg for migraine
tramadol online no prescription tramadol zoloft drug interaction - tramadol hcl erowid
generic xanax buy generic xanax no prescription - xanax dosage recommended
buy tramadol online tramadol make u high - buy tramadol online yahoo
buy tramadol online tramadol buy online no prescription - tramadol hcl high erowid
xanax online xanax zanaflex - xanax 4mg pill
buy tramadol online buy tramadol 100 - tramadol hcl 50mg street value
buy tramadol online tramadol overdose dosage - tramadol addiction risk
buy tramadol online tramadol used withdrawal - tramadol for dogs pet meds
buy tramadol online tramadol 50 mg snort - buy tramadol cheap online no prescription
xanax online xanax 2mg gg249 - xanax dosage nih
buy cialis cialis 5 mg daily side effects - cialis grapefruit effect
xanax online xanax for anxiety after drinking - xanax 8 weeks pregnant
xanax online xanax effects sleep - xanax alcohol overdose symptoms
tramadol buy tramadol hcl capsules 50mg - forum buy cheap tramadol
buy tramadol overnight tramadol legal to buy online - tramadol 50 mg 180 tabs
http://landvoicelearning.com/#51438 tramadol 50 mg for toothache - effects of tramadol overdose
http://buytramadolonlinecool.com/#51726 tramadol no prescription overnight - order tramadol online saturday delivery
buy tramadol online tramadol addiction recovery - tramadol overdose with alcohol
learn how to buy tramdadol tramadol 100mg seizure - tramadol 100 mg /ml
buy ativan online cheap ativan online no prescription - duration of ativan withdrawal
buy tramadol with mastercard tramadol hcl er 200 mg side effects - tramadol 50mg for sale
cheapest ativan xanax vs ativan social anxiety - ativan dosage compared to xanax
buy ativan online ativan side effects humans - ativan taper alcohol
Post a Comment