KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Article: Q45168
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | SR# S890511-147 docerr B_BasicCom | mspl13_basic
Last Modified: 29-JAN-1991

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.

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.

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.