BBC BASIC for Windows
Programming >> Libraries >> WINLIB5
http://bb4w.conforums.com/index.cgi?board=libraries&action=display&num=1335626270

WINLIB5
Post by arbykeen13 on Apr 28th, 2012, 3:17pm

Bad subscript in module C:\Program Files\BBC BASIC for Windows\lib\WINLIB5
I also load WINLIB2. I am using FN_button and
SYS "SetWindowText", @hwnd%, "SOLITARE"
This is a game that I wrote and I use the mouse function for screen position and 7 buttons. It works for many "clicks" then stops with the above message. Is there a limit or can I reset the numbers of "clicks"
Ron


Re: WINLIB5
Post by admin on Apr 28th, 2012, 4:46pm

on Apr 28th, 2012, 3:17pm, arbykeen13 wrote:
Bad subscript in module C:\Program Files\BBC BASIC for Windows\lib\WINLIB5

The most likely cause of a 'Bad subscript' error from WINLIB5 is calling FN_setproc too many times (it supports a maximum of 255 buttons). My guess is that rather than creating your dialogue box template just once, during your program's initialisation phase, you are creating it multiple times and therefore eventually exceeding this limit - you will also be using up memory unnecessarily.

Take particular note of this comment in the Help documentation: "Make sure you only call FN_newdialog once (for each dialogue box); if you need to re-open a dialogue box that has already been opened, simply call PROC_showdialog. Preferably place all your calls to FN_newdialog in an initialisation routine that is only executed once":

http://www.bbcbasic.co.uk/bbcwin/manual/bbcwing.html#newdialog

Richard.