Microsoft KB Archive/68123

= 7.10 &quot;Subscript Out of Range,&quot; WindowDo with No Open Windows =

Article ID: 68123

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft BASIC Professional Development System 7.0
 * Microsoft BASIC Professional Development System 7.1

-



This article was previously published under Q68123



SUMMARY
If a WindowDo statement is executed before any windows are opened, a &quot;Subscript out of range&quot; error will occur. This article explains why the error happens and gives two ways of correcting the error.



MORE INFORMATION
The problem is caused by WindowInit incorrectly initializing the variable GloStorage.currMenu to -1 instead of 0 (zero). WindowDo checks to see if currMenu is 0 (zero) to determine if there are no open windows, and WindowDo generates the error when it tries to access window number -1.

To work around this problem, do one of the following:

  Open a window and then immediately close it. This will set currMenu back to 0 (zero). For example: WindowInit WindowOpen 1,6,5,12,25,0,7,0,7,15,FALSE,FALSE,FALSE,FALSE,0,&quot;&quot; WindowClose 1 WindowDo 0,0  To correct the problem permanently, modify WINDOW.BAS:

 Load the WINDOW.BAS module into QBX.EXE. Push F2 to view the subprograms and then move to WindowInit. Locate the line that reads &quot;GloStorage.currMenu = -1&quot;, and change it to &quot;GloStorage.currMenu = 0&quot;. Save the new copy of WINDOW.BAS. Then follow the instructions at the beginning of GENERAL.BAS to create a new LINK library (.LIB) and Quick library (.QLB).</ol> </li></ol>

Code Sample
When the following program is run in the QBX.EXE environment, it will generate a &quot;Subscript out of range in Quick library module: WINDOW&quot; error. ' QBX must be started with &quot;QBX /L UITBEFR&quot; to load the UI ToolBox ' Quick library

'$INCLUDE: 'general.bi' '$INCLUDE: 'mouse.bi' '$INCLUDE: 'menu.bi' '$INCLUDE: 'window.bi' COMMON SHARED /uitools/ GloMenu          AS MenuMiscType COMMON SHARED /uitools/ GloTitle       AS MenuTitleType COMMON SHARED /uitools/ GloItem        AS MenuItemType COMMON SHARED /uitools/ GloWindow      AS windowType COMMON SHARED /uitools/ GloButton      AS buttonType COMMON SHARED /uitools/ GloEdit        AS EditFieldType COMMON SHARED /uitools/ GloStorage       AS WindowStorageType COMMON SHARED /uitools/ GloWindowStack AS INTEGER COMMON SHARED /uitools/ GloBuffer$ DIM GloTitle(MAXMENU)          AS MenuTitleType DIM GloItem(MAXMENU, MAXITEM)  AS MenuItemType DIM GloWindow(MAXWINDOW)       AS windowType DIM GloButton(MAXBUTTON)       AS buttonType DIM GloEdit(MAXEDITFIELD)      AS EditFieldType DIM GloWindowStack(MAXWINDOW)  AS INTEGER DIM GloBuffer$(MAXWINDOW + 1, 2) WindowInit WindowDo 0,0 END

Additional query words: BasicCom

Keywords: KB68123

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.