KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q61403: LPRINT Followed by BLOAD or BSAVE Gives "File Already Open"

Article: Q61403
Product(s): See article
Version(s): 7.00   | 7.00
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | SR# S900417-59 buglist7.00 fixlist7.10 | mspl13_basic
Last Modified: 13-AUG-1990

Performing an LPRINT statement prior to a BLOAD or BSAVE statement
causes a "file already open" error to occur on the BLOAD or BSAVE
statement if the program is run from the QBX.EXE environment or if it
is compiled with the BC /Fs (Far Strings) option.

Microsoft has confirmed this to be a problem in Microsoft BASIC
Professional Development System (PDS) version 7.00 for MS-DOS and MS
OS/2. It does not occur in earlier BASIC versions. This problem was
corrected in Microsoft BASIC PDS version 7.10.

The program below demonstrates this problem. To generate the "file
already open" error, run this program from the QBX.EXE environment or
compile it with the Far Strings option.

The following is a list of workarounds for this problem:

1. Open the printer as a device and send output to the printer using
   the PRINT #<file number> statement instead of the LPRINT statement.

2. Issue a CLOSE statement after the LPRINT statement.

3. For an executable program, compile the program with the Near
   Strings option.

Code Example
------------

   CLS
   PRINT "hello"
   DEF SEG = &HB800          'points to the segment at the screen buffer
   BSAVE "picture", 0, 4000  'save the screen in the file named picture
   DEF SEG                   'restore default segment
   LPRINT "bob"
   DEF SEG = &HB800
   BLOAD "picture", 0        '**file already open error occurs here
   DEF SEG

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.