Microsoft KB Archive/45168

From BetaArchive Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Article ID: 45168

Article Last Modified on 11/21/2006



APPLIES TO

  • Microsoft QuickBasic 4.0
  • Microsoft QuickBASIC 4.0b
  • Microsoft QuickBasic 4.5 for MS-DOS
  • Microsoft BASIC Compiler 6.0
  • Microsoft BASIC Compiler 6.0b
  • Microsoft BASIC Professional Development System 7.0
  • Microsoft BASIC Professional Development System 7.1



This article was previously published under Q45168

SUMMARY

This article describes how to find the line in the source code that gives an "ERROR nn AT ADDRESS segment:offset" message from an .EXE program at run time.

When you compile with the BC /a/Zi or /a/Zd option, the LINK /LI (Linenumber) option creates a .MAP file that includes (at the bottom) the relative address of every line in the source program. (A documentation correction for the /LI option is shown farther below.)

However, instead of using LINK /LI, it is easier to use the .LST listing file generated by the BC.EXE compiler to find the source line at the address given in the run-time error message.

This information applies to Microsoft QuickBasic versions 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler versions 6.00 and 6.00b for MS-DOS, and to Microsoft Basic Professional Development System (PDS) versions 7.00 and 7.10 for MS-DOS.

MORE INFORMATION

Use .LST File Instead of .MAP File to Find Error Address

A .MAP file generated with the LINK /LI option is not the most convenient way to find the line in the source code that gives an "ERROR nn AT ADDRESS segment:offset" error message from an .EXE program at run time. Instead of using the .MAP file, you only need the .LST file for each module, which conveniently displays the code offsets next to the lines in your source file. The offset given in the error message is the approximate area of your code where the error occurs. (However, some errors aren't reported until the code has run past the actual problem area).

To create an .LST file, you need to compile from the BC.EXE command line. When BC.EXE prompts you for a source listing ("Source listing [NUL.LST]:"), give it a name. Alternatively, you can specify the .LST file as the third argument. You can end the BC.EXE command line with a semicolon to suppress prompting, as follows:

   BC TEST.BAS,,TEST.LST/A;
                

The BC /A option includes an assembler translation of the program in the .LST file, which can help when debugging.

Documentation Error for LINK /LI

The LINK /LI (Linenumbers) option is incorrectly documented as follows in the manuals listed further below:

This option has effect only if you are linking object files compiled with the /M option. [** Incorrect **]

There is no /M compiler option, only a LINK /M option. This sentence should be changed to read as follows:

This option has effect only if you are linking object files compiled with the /a/Zi or /a/Zd options.


This correction applies to the following manuals:

  1. Page 367 of the "Microsoft QuickBasic: Programming in Basic" manual for version 4.50
  2. Page 225 of the "Microsoft QuickBasic Version 4.00: Learning and Using Microsoft QuickBasic" manual for versions 4.00 and 4.00b
  3. Page 225 of the "Microsoft Basic Compiler: Learning and Using Microsoft QuickBasic" manual for versions 6.00 and 6.00b for MS-DOS and MS OS/2

The Basic PDS manuals correctly document the /LI option.


Additional query words: QuickBas BasicCom

Keywords: KB45168