BASIC Developer & Support Resources > Translators


(1/9) > >>

Dusted off my old translator, because I'm tired of looking for an easy to use macOS GUI.

So I'm re-rolling my own.  Here is example syntax:

--- Code: Text ---' ************************************************' * Demo of AIR's Cocoa Objects Library (libcol) *' ************************************************ $MODULE "" const win_width = 600const win_height = 400const button_width = 90 widgets as enum    txtFld    button    colorButton    combo    checkbox    label    editend enum sub btnClick(sender as id)    dim fname$,a$    fname$ = mainWin.openDialog("bas:c:mm")    if len(fname$) then        mainWin.setText(txtFld,fname$)        a$ = LoadFile$(fname$)        mainWin.setText(edit,a$)    end ifend sub Global mainWin("AIR Cocoa Test Window", win_width, win_height) as FORM Cocoa_Init()    with mainWin        .newEntry(txtFld, "Testing AIR's Cocoa Library with MBC", 16, 20, win_width-122, 26, akWidth)        .newButton(button, "Load", win_width-100, 20, button_width, 26, akRight, btnClick)        .newButton(colorButton, "Color", win_width-100, 50, button_width, 26, akRight)        .newCombo(combo, 16, 50, 210, 26)        .newCheck(checkbox, "Check Box 1", 240, 50, 100, 26)        .newLabel(label, "This is a Label", 360, 50, 100, 26)        .newEdit(edit,"", 16, 96, 480, 280,akWidth | akHeight)         .Add(combo, "Apples:Oranges:Peaches", "Oranges")        .setText(edit, "Hello, World!")    end withCocoa_Run() 
This is leveraging the fact the STRUCTS in C++ can be used like CLASSES; the only real difference is that with STRUCTS, all items are public by default whereas with CLASSES they're private by default.

The FORM struct/object uses a Constructor as seen in the creation of 'mainWin', but it is NOT a CLASS although it is used like one.

One of the interesting things is that only the mainWin object is global.  In other GUI implementations I've looked at, each GUI object that you might reference are declared Global (unless you're passing a pointer/reference to that object to a function).

The 'widgets' enum is just that:  An enum of integers.  So they are not GUI objects, but are used internally to track which object a given action needs to be performed on.

The attached screenshots show this demo in 'action', with the 3rd showing the OpenFileDialog which is attached to the form, and the 5th showing how resizing is handled if you use the 'ak*' series of flags.


We both would be dead and gone waiting for IUP to run native on the Mac. A great project to combine all your talents.

I don't need the aneurysm.  An interface to an interface to an interface to native?  IUP's code-base is wayyyyy too abstracted to unravel. 

What advantages does BaCon and FreeBasic BASIC to C translators have over MBC?


I created a MBC-DEV project in the sandbox.

--- Quote ---MBC is a Basic to C/C++ translator, originally based on the BCX Windows translator by Kevin Diggins. It has successfully compiled using Clang++ and G++ on macOS/Linux 64bit OS's, and G++ on RaspberryPi as 32bit.

--- End quote ---


[0] Message Index

[#] Next page

Go to full version