• Aucun résultat trouvé

COMPILE TIME ERRORS

Dans le document Interactive BASIC Compiler (Page 30-33)

RUN* [filename I

COMPILE TIME ERRORS

After typing RUN, ZBASIC compiles the program. If errors are encountered, ZBASIC will stop compiling and display the error on the screen along with the offending line (when compiling from disk using RUN "Filename" or RUN", ZBasic will stop compiling, load the Source Code, and LIST the line where the error occurred.) The Statement within the line and the line number will be displayed. The following program would cause ZBASIC to print an error during compile:

00010 CLS

00020 PRINT "HELLO THERE MR. COMPUTER USER!"

00030 PRINT "I AM A COMPUTER"

00040 Z=Z+1: X=X+Z: PWINTX RUN

Syntax Error in Stmt 03 at Line 00040 00040 Z=Z+1: X=X=Z: PW~ X

NOTE: The error will be marked in some way depending on the computer system being used. The error marker indicates the general error location on the line where compilation stopped. To edit line 40 above type; EDIT 40 (or just comma). Fix the spelling of PRINT.

ZBasic will often display the missing character H expected.

00010 INPUT"Enter a number" A$

RUN

";" expected error in Stmt 01 at line 00010 00010 INPUT"Enter a number"_A$

00010 DIM A(10,10}

00020 A(X}=100 RUN

"," expected error in Stmt 01 at line 00020 00020 A(X_}

Error Messages

28

ERRORS

COMPILE TIME ERROR MESSAGES

A compile time error is one that ZBasic encounters after you type RUN (while it is compiling your program). More often than not, the error is a syntax error. Edit the line to fix the error and type RUN again until all the errors have been deleted.

COMPILE TIME

DEFINITIONS and POSSIBLE REMEDIES Only constants may be used in DIM statements:

DIM A ( X) or Z ( A+4 ) are not allowed. If you have a need to erase and reuse dynamic string arrays see; INDEX$, CLEAR INDEX$, MEM.

Array variable being used was not Dimmed. Make sure variable is Dimmed correctly. Most interpreters allow ten elements of an array before a DIM is required. A compiler requires a DIM for every array.

DEF LEN or DIM string length is less than one or greater than 255.

Also ij CLEAR =zero or CLEAR is too large. Check and adjust range.

Anything ZBasic does not understand. Check for spelling, formatting errors and syntax. The offending part of the line is often highlighted.

String function is too complex to compile. Break up complex strings.

An FN or LONG FN was defined twice.

String assignment problem: A$=123: Change to A$=STR$(123) Out of Memory Error In... Program is getting too large. Check large DIM statements and defined

string lengths, or compile using RUN*. For very large programs you may wish to CHAIN programs together.

Line # Error In... GOTO, GOSUB, ON GOTO, ON GOSUB, THEN or some other branching command can't find line number or a label.

Mismatch error In... The assignment to a variable is the wrong type.

Structure Error In .•. FOR wHhout NEXT, DO without UNTIL, WHILE wHhout WEND, LONG IF without END IF or LONG FN wHhout an END FN.

Structure Error In 65535* Missing NEXT, WEND, END IF, END FN or UNTIL. If unable to find error quickly, LLiST the program. Structures are indented two spaces. Backtrack from the end of the program until the extra indentation is located.

"?" Expected error In •.. ZBasic expected some form of punctuation that was not provided.

29

Error Messages

Check cursor position in displayed line for error.

*NOTE: Each ZBasic loop command must have one, and only one matching partner. Each FOR needs a NEXT, each WHILE needs a WEND, each LONG FN needs an END FN, each LONG IF needs an END IF and each DO needs an UNTIL.

ERRORS

RUN TIME ERRORS

A Run Time (execution) error is an error that occurs when the compiled program is running (Object Code). The only Run Time error messages produced are:

DISK ERRORS (Unless trapped by the user). See Disk Errors in the FILES section of this manual.

OUT OF MEMORY ERROR when loading a compiled program saved to disk that is too large to execute in memory.

ARRAY BOUNDS ERROR will be shown if the user configures ZBasic to check for this.

This will slow down a program execution but is extremely handy during the debug phase of programming. You may turn this off after the program is completely tested. If access to an array element out of bounds is made, the program is stopped and the line number with the error is printed.

STRING LENGTH ERROR. Some versions of ZBasic have a configure option that tells ZBasic to check for string assignments greater than the length allowed. This does slow execution speed and add memory overhead, so you may want to remove this error checking after the program is debugged. See your appendix for specifics. If an attempt is made to assign a string a value longer than its length, the program is stopped and the line number with the error is printed.

RECOVERING FROM FATAL RUNTIME ERRORS

Since ZBasic is a compiler and converts your code into machine language, there is always a risk that you may unintentionally enter an endless loop or hang up the system (the computer will not respond to anything) .

In these instances you may not be able to get a response from the computer or be able to

<BREAK> out of the program. The system may have to be reset or turned off, and back on again to regain control. To avoid losing valuable time, it is very important that you SAVE PROGRAMS and MAKE BACKUPS FREQUENTLY. See your computer appendix for possible alternatives.

USING SINGLE STEP DEBUGGING TO FIND THE SOURCE OF "CRASHES"

Should you encounter a situation where your program goes so far and then the system hangs-up or you get a system error of some kind that you just can' locate, there is a simple way to find the problem.

First put a TRaNS and TRON in the program somewhere before the crash occurs. The TRON is added so that you can see a listing of the line numbers as the program executes.

Press the space bar a statement at a time, keeping track of the line numbers as they go by.

When the system crashes, make a note of the line number where the crash occurred and fix the problem in your program.

Error Messages

30

~

Dans le document Interactive BASIC Compiler (Page 30-33)