BBC BASIC for Windows
Programming >> BBC BASIC language >> LBB Conversion
http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1430585506

LBB Conversion
Post by RNBW on May 2nd, 2015, 4:51pm

Richard

You provided a very useful bit of code in LBB Conforums (below:)

Code:
    number.of.rows = 8

    for row = 1 to number.of.rows
      for col = 0 to 4
        textbox #w.tb, 10+col*55, row*20, 55, 20
        maphandle #w.tb, "#w.tb";row;col
      next col
    next row
    open "Textbox grid" for window as #w
    #w.tb42 "Some text"
    wait
 


I used LBB to convert it to BBC Basic and it provided the code below:

Code:
      REM Automatically translated from Liberty BASIC to BBC BASIC
      REM by 'LB Booster' version 3.00, Sat. 02 May 2015, 17:21:20
      REM!Crunch spaces,rems
      REM!Embed @lib$+"LBLIB.BBCC", @lib$+"LBprompt.tpl"
      HIMEM=PAGE+&1F400000:INSTALL @lib$+"LBLIB.BBCC":PROC_LBinit
      Version$ = "4.04 (LBB 3.00)":Err$ = "":erl%=0:lc%=0:io&=&F

      number`of`rows = 8

      FOR row = 1 TO number`of`rows : WHILE 1 > (number`of`rows) EXIT FOR : ENDWHILE
        FOR col = 0 TO 4
          PROC_textbox(`w, `w`tb, "#w.tb", 10 + col * 55, row * 20, 55, 20)
          PROC_maphandle$(`w`tb, "#w.tb" + STR$(row) + STR$(col))
        NEXT col
      NEXT row
      PROC_open("Textbox grid", "window", "#w", `w)
      PROC_gui(`w`tb42, "Some text")
      PROC_wait
      PROC_end
 


This works a treat except that if I run the code and then close the output and try to run it again, it comes up with the error message <<Couldn't register class>>. Closing down BBC Basic and reload and it works again, and so on. It doesn't work if you just close down the code. Still the error message. Any idea why this happens?

Also, I notice the use of the character ( ` ) is used in the conversion. What is the significance of this.




Re: LBB Conversion
Post by rtr2 on May 2nd, 2015, 5:56pm

on May 2nd, 2015, 4:51pm, RNBW wrote:
Any idea why this happens?

Yes, it's because the LBB IDE runs your program in a different process whereas the BB4W IDE runs your program in the same process. So, when run from LBB, Windows conveniently does a whole load of cleanup operations when the program - and therefore process - terminates (including automatically unregistering the class). This doesn't happen in BB4W because the process isn't terminated (unless you close BB4W down and open it again).

In principle you could probably eliminate the error by unregistering the class yourself (the class name is "LB2BBC" which is an interesting hangover from its early origins!) but you could still have problems if your program terminates 'abnormally'.

There are a number of features of the LBLIB library which makes it unsuitable for running from the BB4W IDE, of which this is one. That's why I never recommend attempting to port a program from LBB to BB4W without rewriting it sufficiently to allow LBLIB to be dispensed with (e.g. by using BB4W libraries instead).

Quote:
Also, I notice the use of the character ( ` ) is used in the conversion. What is the significance of this.

No particular 'significance' other than it's a character which is legal in a variable name, but which is little used. Therefore it's a handy replacement for characters which are valid in Liberty BASIC but not BBC BASIC (for example a dot).

Richard.

Re: LBB Conversion
Post by RNBW on May 2nd, 2015, 7:01pm

Thanks for the explanation. In due course, I want to reproduce the program I am writing in LBB in BB4W and wanted to see if the LBB conversion helped and I found the problem when I ran it. I think I shall probably need your help when I finally get round to it.

Ray