Example, Example 2 -8 – HP 49g Graphing Calculator User Manual
Page 202
Attention! The text in this document has been recognized automatically. To view the original document, you can use the "Original mode".

Example
The following example creates the list of marks used in the previous
example. If a non-numeric value is entered, the program prompts with an
error message. The program performs the following:
® It sets up a loop to collect 20 values.
® It prompts for an input value.
® It tests the input to check if it is a number.
® If the generates an error, the error is trapped, and an error message is
displayed to prompt for a numeric value.
«
@ S e t n u m e r i c m o d e s o t h a t e r r o r t r a p w o r k s
S F { - 3 )
;
@ C r e a t e a n e m p t y l i s t
{}►
marks
;
@ S e t u p a l o o p f o r 2 0 e n t r i e s .
W H I L E S I Z E ( M A R K S ) < 2 0 R E P E A T
@ S t a r t e r r o r - c h e c k i n g r o u t i n e .
I F E R R I N P U T ( " E n t e r a n u m b e r " , " " ) N
@ A t t e m p t t o c o n v e r t t h e e n t r y t o a n u m b e r .
@ T h i s g e n e r a t e s a n e r r o r i f n o n - n u m e r i c
« O B J ^ ( N ) + l - l - y N
® I f n o e r r o r , a p p e n d t h e e n t r y t o t h e l i s t .
« MARKS+N ► MARKS
THEN
©This appears if entry is non-numeric.
MSGBOX("INVALID ENTRY, TRY AGAIN")
END ;
END
Page 10-16
Introduction to programming