Offset for Jump To... Option Appears Incorrect after $INCLUDE (33142)






This article was previously published under Q33142

SUMMARY

In the QuickBASIC Interpreter, the Jump To... option goes to a physical line offset from the beginning of the file, excluding the extra lines in the compiler's $INCLUDE files (if any).

However, when an error occurs in a compiled program, the number of the line in error counts the lines in $INCLUDE files. This applies to error line numbers shown in the Program Listing File, or in the run-time error message "***** Error <n> at <line>" (which requires the "Process Runtime Events" compiler option to get a line number).

Thus, if the main source file contains REM $INCLUDE or '$INCLUDE statements, the Jump To... option in the interpreter will not show you the proper line in the main program where the error occurred. This is because the compiler counts the lines in the $INCLUDE files when figuring the offset, while the interpreter environment does not.

To calculate the correct offset, subtract the number of lines in the $INCLUDE files from the given error offset. Then select Jump To... from the Search menu and use the smaller offset.

MORE INFORMATION

When a compile-time error occurs in a compiled program's $INCLUDE file itself, the interpreter improperly puts a box around a line in the main program. The number of lines that this box lies below the REM $INCLUDE statement is the number of the line in error in the $INCLUDE file.

Below is an example where the interpreter draws a box around the wrong line (in the main source file) if any error occurs in a compiled programs's $INCLUDE file. When you compile the following, the interpreter marks line 3 in the main program with a box and gives a "Syntax Error" message:
REM This is the MAIN program.
REM $INCLUDE "JUNK"
PRINT "LINE 3"   ' The interpreter flags this line with "Syntax Error"
PRINT "LINE 4"

REM This is a separate $INCLUDE file called JUNK, saved in Text format.
INPUT PRINT  ' This line is a deliberate Syntax Error.
				
Note: REM $INCLUDE statements are ignored when the program is run in the interpreter.

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: KB33142