On Error Goto Statement In Gw Basic
of integer expression equals an error code already on error goto -1 vba excel in use by GW-BASIC, the ERROR statement simulates the occurrence "on error goto -1" of that error, and the corresponding error message is printed. A user-defined error code gw basic programs for 10th class must use a value greater than any used by the GW- BASIC error codes. There are 76 GW-BASIC error codes at present. It is preferable to use a code number high enough to remain valid when more error codes are added to GW-BASIC. User-defined error codes may be used in an error-trapping routine. If an ERROR statement specifies a code for which no error message has been defined, GW-BASIC responds with the message "Unprintable Error". Execution of an ERROR statement for which there is no error-trapping routine causes an error message to be printed and execution to halt. For a complete list of the error codes and messages already defined in GW-BASIC, refer to Appendix A in the GW-BASIC User's Guide. Examples: The following examples simulate error 15 (the code for "String too long"): 10 S=10 20 T=5 30 ERROR S+T 40 END RUN String too long in 30 Or, in direct mode: ERROR 15 (you type this line) String too long (GW-BASIC types this line) The following example includes a user-defined error code message. . . . 110 ON ERROR GOTO 400 120 INPUT "WHAT IS YOUR BET";B 130 IF B>5000 THEN ERROR 210 . . . 400 IF ERR=210 THEN PRINT "HOUSE LIMIT IS $5000" 410 IF ERL=130 THEN RESUME 120 . . .
where execution is to resume: SyntaxResult RESUME or RESUME 0 Execution resumes at http://www.antonis.de/qbebooks/gwbasman/error.html the statement that caused an error. RESUME NEXT Execution resumes at the statement immediately following the one that caused an error. RESUME line number Execution http://www.antonis.de/qbebooks/gwbasman/resume.html resumes at the specified line number. A RESUME statement that is not in an error trapping routine causes a "RESUME without error" message to be printed. Examples: 10 ON ERROR GOTO 900 . . . 900 IF (ERR=230) AND (ERL=90) THEN PRINT "TRY AGAIN": RESUME 80 . . . If an error occurs after line 10 is executed, the action indicated in line 900 is taken and the program continues at line 80.
the http://pages.intnet.mu/jhbpage/Program/Qbasic/tutorial/Ch8d.htm instruction after the "label1" label until the value of variable "x" is equal to 5. Code Output DIM x AS INTEGER x = 0 label1: x = x + 1 PRINT x IF x on error < 5 THEN GOTO label1 END IF 1 2 3 4 5 You should advoid using the GOTO statement wherever possible. Programmers who used GW-BASIC, the predecessor of qbasic, used to put a lot of GOTO on error goto statements, branching in every directions, in their programs, thus making it difficult to maintain. It was called spaghetti codes. The above program is simpler to write if you use the DO LOOP statement instead. The same as above using the DO - LOOP 'This program displays a sentence 5 times CLS DIM x AS INTEGER x = 0 DO PRINT x x = x + 1 LOOP UNTIL x = 5 However, in some cases, there are no alternatives. The GOTO statement is used in conjunction with the ON ERROR statement which is used to trap errors in your program. [ Previous Index Next ] pages viewed since January 19 2002
be down. Please try the request again. Your cache administrator is webmaster. Generated Sun, 23 Oct 2016 15:31:28 GMT by s_wx1011 (squid/3.5.20)