Post Reply 
HP Prime speed vs TI-Nspire CX
11-09-2016, 01:00 PM (This post was last modified: 11-09-2016 01:13 PM by toml_12953.)
Post: #23
RE: HP Prime speed vs TI-Nspire CX
(11-09-2016 08:44 AM)ttw Wrote:  Without GOTOs, error handling is hard.

In ANSI (ISO) BASIC, error handling is done this way:

WHEN EXCEPTION IN
<code block>
USE
<error handling code>
END WHEN

Contrived simple example: square root error

Code:
DO
   LET ERRFLAG = 0
   INPUT PROMPT "ENTER A NUMBER": N
   WHEN EXCEPTION IN
      LET X = SQR(N)
   USE
      PRINT "ERROR IN SQUARE ROOT"
      LET ERRFLAG = -1
   END WHEN
LOOP UNTIL ERRFLAG = 0
PRINT "THE SQUARE ROOT OF";N;";"IS";X
END

No need for GOTO even in error handling.

Tom L

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP Prime speed vs TI-Nspire CX - jte - 11-08-2016, 06:43 PM
RE: HP Prime speed vs TI-Nspire CX - DGM - 11-08-2016, 09:10 PM
RE: HP Prime speed vs TI-Nspire CX - ttw - 11-09-2016, 08:44 AM
RE: HP Prime speed vs TI-Nspire CX - toml_12953 - 11-09-2016 01:00 PM



User(s) browsing this thread: 2 Guest(s)