Page 320 - Learn to Program - Basic-256
P. 320

Chapter 20 – Runtime Error Trapping                                             Page 304


        Exercises:



                                    e u q r l w f e p j x s p w n c
                                    p g u b i r r h f j w w w o c p
                                    b l a s t e r r o r e x t r a p
                                    q e e s v w j l p g a m w l o q
                                    t a n n s r q o i i t m r a n o
                                    r f x i d e o u c a t c h t e y
                                    y h z r l t m r f k o s k v r i
                                    q o i b m r r r r s i e f b r f
                                    x l f x o z o y o e l b b i o a
                                    y k m f z o r r q r t s k e r a
                                    z a h l e i r y r p r s f g y m
                                    i l i l n r e j f e p e a n r l
                                    a q c m t q r k o g t l t l u u
                                    r e u k z b b o u f l s g s t j
                                    m s u h l a r x r m v w a q a l
                                    u b z r l h a l k p a r t l n l


                           catch, endtry, error, lasterror, lasterrorextra, lasterrorline,
                           lasterrormessage, offerror, onerror, trap, try




                           1. Set the “runtime handling of bad type conversion” “Preference”
                           to “warn” or “Error” and write a simple program that asks the user
                           to enter a number. If the user enters something that is not a
                           number, trap the warning/error and ask again.


                                  enter a number> gdf2345
                                  bad entry. try again.
                                  enter a number> fdg545
                                  bad entry. try again.
                                  enter a number> 43fdgdf
                                  bad entry. try again.



                                                       © 2019 James M. Reneau (CC BY-NC-SA 3.0 US)
   315   316   317   318   319   320   321   322   323   324   325