Author Topic: BBC BASIC for Windows  (Read 50980 times)

rtrussell

  • Guest
Re: BBC BASIC for Windows - IUP
« Reply #45 on: January 18, 2014, 10:04:14 AM »
After that fix, this is the error I'm getting.
No such FN/PROC

Look and see which line in your program is highlighted when the error occurs - this is the line which is calling a non-existent FN or PROC.   :)

Richard.

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP
« Reply #46 on: January 18, 2014, 10:17:37 AM »
Code: [Select]
      PROCIupSetCallback(but%, "BUTTON_CB", FN_callback(FNButtonClick(), 3))

It seems this nesting of BBC4W functions isn't being recognized. (guess)

Code: [Select]
      INSTALL @lib$+"CALLBACK"
      INSTALL @lib$+"IUP"

      PROCIupOpen
      win% = FNIupDialog
      but% = FNIupButton("Click Me")
      PROCIupAppend(win%, but%)
      cbaddr% = FN_callback(FNButtonClick(), 3)
      PROCIupSetCallback(but%, "BUTTON_CB", cbaddr%)
      PROCIupShow
      PROCIupMainLoop
      PROCIupClose
      END

      DEF FNButtonClick(iup%, mbutton%, mpressed%)
      PRINT "Mouse Button: " + STR$(mbutton%)
      = -2

This doesn't help either.  :-[
« Last Edit: January 18, 2014, 10:20:31 AM by John »

rtrussell

  • Guest
Re: BBC BASIC for Windows - IUP
« Reply #47 on: January 18, 2014, 10:27:28 AM »
Code: [Select]
      PROCIupSetCallback(but%, "BUTTON_CB", FN_callback(FNButtonClick(), 3))

It seems this nesting of BBC4W functions isn't being recognized. (guess)

There's nothing wrong with that code.  If it is causing a No such FN/PROC error really there's only one likely explanation - BBC BASIC doesn't think the procedure PROCIupSetCallback() exists.  In the most recent version of your library you listed it didn't - have you added it since?

The simplest explanation is often the correct one.

Richard.

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP
« Reply #48 on: January 18, 2014, 10:36:57 AM »
Another good catch. I'm signing you up for the All Stars next year.  :)

No errors but no IUP dialog with a button either.

Code: [Select]
      REM BBC4W IUP Library
      REM By John Spikowski - 1/16/2014

      DEF PROCIupOpen
      LOCAL gpa$, ll%
      gpa$ = "GetProcAddress"
      SYS "LoadLibrary", @lib$+"iup.dll" TO ll%
      SYS gpa$, ll%, "IupOpen" TO IupOpen%
      SYS gpa$, ll%, "IupDialog" TO IupDialog%
      SYS gpa$, ll%, "IupLabel" TO IupLabel%
      SYS gpa$, ll%, "IupButton" TO IupButton%
      SYS gpa$, ll%, "IupAppend" TO IupAppend%
      SYS gpa$, ll%, "IupShow" TO IupShow%
      SYS gpa$, ll%, "IupMainLoop" TO IupMainLoop%
      SYS gpa$, ll%, "IupClose" TO IupClose%
      SYS gpa$, ll%, "IupSetAttributes" TO IupSetAttributes%
      SYS gpa$, ll%, "IupSetCallback" TO IupSetCallback%
      SYS IupOpen%, 0, 0
      ENDPROC

      DEF PROCIupClose
      SYS IupClose%
      ENDPROC

      DEF PROCIupShow
      SYS IupShow%
      ENDPROC

      DEF PROCIupMainLoop
      SYS IupMainLoop%
      ENDPROC

      DEF PROCIupAppend(target%, src%)
      SYS IupAppend%, target%, src%
      ENDPROC

      DEF FNIupDialog
      LOCAL dlg%
      SYS IupDialog% TO dlg%
      = dlg%

      DEF FNIupLabel(title$)
      LOCAL lbl%
      SYS IupLabel%, title$ TO lbl%
      = lbl%

      DEF FNIupButton(title$)
      LOCAL btn%
      SYS IupButton%, title$ TO btn%
      = btn%

      DEF PROCIupSetAttributes(iup%, attribstr$)
      SYS IupSetAttributes%, iup%, attribstr$
      ENDPROC

      DEF PROCIupMainLoop
      LOCAL dummy%
      SYS FN_syscalln(IupMainLoop%) TO !FN_systo(dummy%)
      ENDPROC

      DEF PROCIupSetCallback(iup%, cbtype$, cbaddr%)
      SYS IupSetCallback%, iup%, cbtype$, cbaddr%
      ENDPROC

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP
« Reply #49 on: January 18, 2014, 10:54:12 AM »
My error. IupShow() needed something to show.

Code: [Select]
      INSTALL @lib$+"CALLBACK"
      INSTALL @lib$+"IUP"

      PROCIupOpen
      win% = FNIupDialog
      but% = FNIupButton("Click Me")
      PROCIupAppend(win%, but%)
      cbaddr% = FN_callback(FNButtonClick(), 3)
      PROCIupSetCallback(but%, "BUTTON_CB", cbaddr%)
      PROCIupShow(win%)
      PROCIupMainLoop
      PROCIupClose
      END

      DEF FNButtonClick(iup%, mbutton%, mpressed%)
      PRINT "Mouse Button: " + STR$(mbutton%)
      = -2

The IUP dialog shows with a button (no title) and puts the window in stress mode with a dialog popping. (non-responding - force quit)

Maybe the IupMainLoop() shouldn't have the special blocking SYS call?
« Last Edit: January 18, 2014, 10:55:56 AM by John »

rtrussell

  • Guest
Re: BBC BASIC for Windows - IUP
« Reply #50 on: January 18, 2014, 11:19:53 AM »
Maybe the IupMainLoop() shouldn't have the special blocking SYS call?

Non-blocking.  You can try that, but I would have expected it to result in a deadlock.

More likely, I think, is that one or more of the other SYS calls does also need the special non-blocking version.  Try using it for IupShow:

Code: [Select]
      DEF PROCIupShow
      LOCAL dummy%
      SYS FN_syscalln("IupShow%") TO !FN_systo(dummy%)
      ENDPROC

Richard.

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP
« Reply #51 on: January 18, 2014, 11:26:01 AM »
Using a standard SYS call for IupMainLoop seemed to solve the lockup (non-responding) issue. I'm not seeing events or can I close the IUP dialog or BBC4W.



Can you download IUP for Windows and give this a try on your end? I'm using the VC10 DLL set.

Update

The IUP window closes correctly if I don't click the button first. As soon as I click the button, everything locks up.

« Last Edit: January 18, 2014, 11:40:31 AM by John »

rtrussell

  • Guest
Re: BBC BASIC for Windows - IUP
« Reply #52 on: January 18, 2014, 12:09:32 PM »
Can you download IUP for Windows and give this a try on your end?

Where is the download?  When I tried to find it earlier on today all I could locate was a DLL with a dependency on Cygwin, which I don't have on any of my PCs (and don't want - I use MinGW).

Richard.

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP 3.10
« Reply #53 on: January 18, 2014, 12:16:08 PM »
You're in luck. It seems IUP just released 3.10 within the last 24 hours.

Download Link


rtrussell

  • Guest
Re: BBC BASIC for Windows - IUP 3.10
« Reply #54 on: January 18, 2014, 01:02:17 PM »
Download Link

Do I need all the DLLs in the zip, or just iup.dll?

I'll also need the latest versions of your test program and library.

Richard.

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP
« Reply #55 on: January 18, 2014, 01:21:12 PM »
I just copied all the IUP DLLs (excluding the IupLua*.dll) to my SysWOW64 directory.

I will e-mail you a zip of my BUTTON.BCC and IUP.BCC files.

« Last Edit: January 18, 2014, 01:27:39 PM by John »

rtrussell

  • Guest
Re: BBC BASIC for Windows - IUP
« Reply #56 on: January 18, 2014, 03:44:53 PM »
Right, everything works!  You will need to download CALLBACK_cdecl.BBC from here.  The BASIC files are listed below:

BUTTON.BBC
Code: [Select]
      INSTALL @lib$+"CALLBACK_cdecl"
      INSTALL @lib$+"IUP"

      PROCIupOpen
      win% = FNIupDialog
      but% = FNIupButton("Click Me")
      PROCIupAppend(win%, but%)
      cbaddr% = FN_callback(FNButtonClick(), 6)
      PROCIupSetCallback(but%, "BUTTON_CB", cbaddr%)
      PROCIupShow(win%)
      PROCIupMainLoop
      PROCIupClose
      END

      DEF FNButtonClick(ih%, button%, pressed%, x%, y%, status%)
      PRINT "Mouse Button: "; button% " " pressed%
      = -2

IUP.BBC
Code: [Select]
      REM BBC4W IUP Library
      REM By John Spikowski - 1/16/2014

      DEF PROCIupOpen
      LOCAL gpa$, ll%
      gpa$ = "GetProcAddress"
      SYS "LoadLibrary", "iup.dll" TO ll%
      SYS gpa$, ll%, "IupOpen" TO IupOpen%
      SYS gpa$, ll%, "IupDialog" TO IupDialog%
      SYS gpa$, ll%, "IupLabel" TO IupLabel%
      SYS gpa$, ll%, "IupButton" TO IupButton%
      SYS gpa$, ll%, "IupAppend" TO IupAppend%
      SYS gpa$, ll%, "IupShow" TO IupShow%
      SYS gpa$, ll%, "IupMainLoop" TO IupMainLoop%
      SYS gpa$, ll%, "IupClose" TO IupClose%
      SYS gpa$, ll%, "IupSetAttributes" TO IupSetAttributes%
      SYS gpa$, ll%, "IupSetCallback" TO IupSetCallback%
      SYS IupOpen%, 0, 0
      ENDPROC

      DEF PROCIupClose
      SYS IupClose%
      ENDPROC

      DEF PROCIupShow(iup%)
      LOCAL dummy%
      SYS FN_syscalln(IupShow%), iup% TO !FN_systo(dummy%)
      ENDPROC

      DEF PROCIupMainLoop
      LOCAL dummy%
      SYS FN_syscalln(IupMainLoop%) TO !FN_systo(dummy%)
      ENDPROC

      DEF PROCIupAppend(target%, src%)
      SYS IupAppend%, target%, src%
      ENDPROC

      DEF FNIupDialog
      LOCAL dlg%
      SYS IupDialog% TO dlg%
      = dlg%

      DEF FNIupLabel(title$)
      LOCAL lbl%
      SYS IupLabel%, title$ TO lbl%
      = lbl%

      DEF FNIupButton(title$)
      LOCAL btn%
      SYS IupButton%, title$, "" TO btn%
      = btn%

      DEF PROCIupSetAttributes(iup%, attribstr$)
      SYS IupSetAttributes%, iup%, attribstr$
      ENDPROC

      DEF PROCIupSetCallback(iup%, cbtype$, cbaddr%)
      LOCAL dummy%
      cbtype$ += CHR$(0)
      SYS FN_syscalln(IupSetCallback%), iup%, cbtype$, cbaddr% TO !FN_systo(dummy%)
      ENDPROC

Richard.

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP
« Reply #57 on: January 18, 2014, 04:22:52 PM »
Thanks Richard!

IUP looks like a good fit for BBC BASIC for Windows. I slightly modified your BUTTON.BBC to print the mouse button number (1=left, 2=middle, 3=right) and the mouse button state. (pressed / released)

Wine 1.6.1



FYI: It seems IupShow() and IupMainLoop() are the only functions that need the special SYS call. IupSetCallback with a normal SYS works fine.
« Last Edit: January 18, 2014, 11:55:55 PM by John »

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP
« Reply #58 on: January 18, 2014, 10:21:49 PM »
Nice to see XP theme support working with BBC4W and IUP on Windows XP. (VirtualBox) I haven't been able to get XP theme support to work on Wine yet.

Windows XP




Windows 7 64 bit



« Last Edit: January 18, 2014, 11:55:06 PM by John »

Offline John

  • Forum Support
  • Posts: 3601
Re: BBC BASIC for Windows - IUP vs. Native BBC GUI
« Reply #59 on: January 19, 2014, 05:15:11 PM »
Richard and I were having a discussion about the benefits of IUP to BBC4W users. Here is a BBC4W native version of the BUTTON.BBC example.

The native version is theming the button and takes less code to produce. It only detected the left mouse button and the click event as a whole but 95% of the time that is all you need.



Update

I spent some time this evening going over the BBC BASIC for Windows documentation on Windows programming. I try to avoid any language that depends on translating and passing Windows messages as a means of communicating with the GUI. The Windows message system is the ugliest thing I've ever seen and mastering that mess has never been a goal of mine.

I think direct positioning is a legacy technique and containerized self resizing controls are the way things are now done. The message loop handler has to be a bit smarter than a REPEAT/UNTIL waiting for something to generate FALSE state. For the quick one screen utility/game the native BBC4W GUI interface would more than likely work out fine. I wouldn't try to write anything for my clients using that direction. (non-maintainable)

I think BBC BASIC for Windows is a great interactive interpreter and you should be proud of your efforts maturing it to this point. The built-in assembler sets it above the rest with that feature alone. Graphics are another area you excel in with the BASIC.

One of the features of IUP I really like is the interactive GUI layout tool as an API call. Changes made via the dialog layout tool / property sheet are immediately reflected in the running application. Here is an example of our BUTTON.BBC demo using the IupLayoutDialog() function.













Notice how the background of the dialog was changed via the property sheet and the dialog layout showing the expanded window size. I could add / remove controls from the layout tool and generate a C, LED or Lua source code with the changes.

« Last Edit: January 20, 2014, 03:38:05 PM by John »