All BASIC

BASIC Developer & Support Resources => Translators => Topic started by: AIR on December 11, 2018, 03:59:14 PM

Title: MBC
Post by: AIR on December 11, 2018, 03:59:14 PM
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
  1. ' ************************************************
  2. ' * Demo of AIR's Cocoa Objects Library (libcol) *
  3. ' ************************************************
  4.  
  5. $MODULE "cocoa.inc"
  6.  
  7. const win_width = 600
  8. const win_height = 400
  9. const button_width = 90
  10.  
  11. widgets as enum
  12.     txtFld
  13.     button
  14.     colorButton
  15.     combo
  16.     checkbox
  17.     label
  18.     edit
  19. end enum
  20.  
  21. sub btnClick(sender as id)
  22.     dim fname$,a$
  23.     fname$ = mainWin.openDialog("bas:c:mm")
  24.     if len(fname$) then
  25.         mainWin.setText(txtFld,fname$)
  26.         a$ = LoadFile$(fname$)
  27.         mainWin.setText(edit,a$)
  28.     end if
  29. end sub
  30.  
  31. Global mainWin("AIR Cocoa Test Window", win_width, win_height) as FORM
  32.  
  33. Cocoa_Init()
  34.     with mainWin
  35.         .newEntry(txtFld, "Testing AIR's Cocoa Library with MBC", 16, 20, win_width-122, 26, akWidth)
  36.         .newButton(button, "Load", win_width-100, 20, button_width, 26, akRight, btnClick)
  37.         .newButton(colorButton, "Color", win_width-100, 50, button_width, 26, akRight)
  38.         .newCombo(combo, 16, 50, 210, 26)
  39.         .newCheck(checkbox, "Check Box 1", 240, 50, 100, 26)
  40.         .newLabel(label, "This is a Label", 360, 50, 100, 26)
  41.         .newEdit(edit,"", 16, 96, 480, 280,akWidth | akHeight)
  42.  
  43.         .Add(combo, "Apples:Oranges:Peaches", "Oranges")
  44.         .setText(edit, "Hello, World!")
  45.     end with
  46. Cocoa_Run()
  47.  

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.



AIR.

Title: Re: MBC
Post by: John on December 11, 2018, 04:39:57 PM
We both would be dead and gone waiting for IUP to run native on the Mac. A great project to combine all your talents.
Title: Re: MBC
Post by: AIR on December 11, 2018, 05:17:56 PM
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. 
Title: Re: MBC
Post by: John on December 22, 2018, 01:48:51 AM
What advantages does BaCon and FreeBasic BASIC to C translators have over MBC?
Title: Re: MBC
Post by: John on December 22, 2018, 01:13:37 PM
AIR,

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.

Title: Re: MBC
Post by: John on December 22, 2018, 09:19:19 PM
I tried to compile the regextest.bas example and received the following errors.


MBC Version 4.0-Beta3 (2018/12/09)
MBC4: Based on Linux BCX by Mike Henning (c) 2009
(c) 2009-2018 Armando Rivera with additional code (c) 2009 John Jacques


********************
** 64 BIT VERSION **
********************

[Lines In:20] [Lines Out:185] [Statements:12] [Time:0.01 sec's]
BCX translated regextest.bas to regextest.cc
Shelling Out To: g++  -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings regextest.cc -ldl  -o regextest
regextest.cc: In function ‘int main(int, char**)’:
regextest.cc:170:12: error: ‘REGEX’ does not name a type; did you mean ‘REG_ERR’?
   static   REGEX  hits;
            ^~~~~
            REG_ERR
regextest.cc:171:11: error: ‘hits’ was not declared in this scope
   memset(&hits,0,sizeof(hits));
           ^~~~
regextest.cc:171:11: note: suggested alternative: ‘puts’
   memset(&hits,0,sizeof(hits));
           ^~~~
           puts
regextest.cc:177:6: error: ‘bcxregex’ was not declared in this scope
   if(bcxregex(Src,"( )", &hits))
      ^~~~~~~~
jrs@jrs-laptop:~/MBC$


Title: Re: MBC
Post by: AIR on December 22, 2018, 09:29:34 PM
Give me a few minutes....
Title: Re: MBC
Post by: AIR on December 22, 2018, 09:38:30 PM
Sorry, the problem is here:

Code: C
  1.  if(bcxregex(Src,"( )", &hits))

I changed that function to 'regmatch'.

You also need to put in something to search for, as is it will search for a space.
Title: Re: MBC
Post by: John on December 22, 2018, 09:44:19 PM
Could you please post your working version? I'm still getting errors.

Title: Re: MBC
Post by: AIR on December 22, 2018, 09:57:01 PM
Code: Text
  1. $EXECON
  2. $NOMAIN
  3.  
  4. FUNCTION main(argc as integer, argv as PCHAR*) as integer
  5.     dim hits as REGEX
  6.     LOCAL Src$,j
  7.  
  8.     Src$ = "Hello, World! This is Armando"
  9.     IF regmatch(Src$,"(H.+,).+(man)",&hits) THEN
  10.         FOR j = 1 TO hits.count
  11.             IF LEN(hits.results[j]) THEN
  12.                 PRINT hits.results[j]$,SPC$;
  13.             END IF
  14.         NEXT
  15.         PRINT
  16.     END IF
  17. END FUNCTION
  18.  
Title: Re: MBC
Post by: John on December 22, 2018, 10:04:47 PM
Thanks!


MBC Version 4.0-Beta3 (2018/12/09)
MBC4: Based on Linux BCX by Mike Henning (c) 2009
(c) 2009-2018 Armando Rivera with additional code (c) 2009 John Jacques


********************
** 64 BIT VERSION **
********************

[Lines In:17] [Lines Out:246] [Statements:16] [Time:0.01 sec's]
BCX translated regextest.bas to regextest.cc
Shelling Out To: g++  -Wformat -D_FORTIFY_SOURCE=2 -Wno-write-strings regextest.cc -ldl  -o regextest
jrs@jrs-laptop:~/MBC$ ./regextest
Hello, man
jrs@jrs-laptop:~/MBC$

Title: Re: MBC
Post by: John on December 22, 2018, 11:00:44 PM
Is there more MBC examples I can try under Ubuntu 18.10?

Converting some of the BaCon examples is an idea.

It would be interesting to compare the resulting C code for efficiency, readability and the ability to extend it at that level.
Title: Re: MBC
Post by: AIR on December 23, 2018, 09:42:08 PM
Updated MBC and Examples uploaded to my repository.  You will need to recompile MBC for all of the items in Examples/Console to compile.
Title: Re: MBC
Post by: John on December 24, 2018, 12:05:24 AM
It would be great if you could push your MBC changes to sandbox copy. I really can't take on much more than I already have going. Feel free to remove the MBC repo in the sandbox if it's too much trouble to maintain.

Title: Re: MBC
Post by: AIR on December 24, 2018, 12:42:41 AM
It would be great if you could push your MBC changes to sandbox copy. I really can't take on much more than I already have going. Feel free to remove the MBC repo in the sandbox if it's too much trouble to maintain.

If Gitlab CE had a PROPER mirroring option, this wouldn't be an issue.  Aside from all of the extras it comes with that I don't need, the lack of a simple mirroring option was a deal killer for me when I looked at it previously.

That's why I settled on GOGS and it's fork, GITEA.  GOGS is on my VPS, GITEA is on my local server at home.

They both support scheduled checking and updating of repositories, with no interaction required.

At one point, I had a mirror set up that would pull from BitBucket down to GOGS which was then pulled down to GITEA.  So any changes I pushed up to BitBucket would automatically sync to my GOGS and GITEA instances.  So I always had fully functional backup repositories no matter what.

Anyway, I simply don't have the time or the patience to maintain a repository in the SANDBOX for MBC, because keeping everything synced would be a PITA, and I would need to keep two active code bases going on multiple machines and VM's here.

AIR.
Title: Re: MBC
Post by: John on December 24, 2018, 12:47:56 AM
Gone.

I think MBC could be a BaCon contender.
Title: Re: MBC
Post by: John on December 24, 2018, 12:58:26 AM
Quote
If Gitlab CE had a PROPER mirroring option.

Quote
Repository mirroring allows for mirroring of repositories to and from external sources. It can be used to mirror branches, tags, and commits between repositories.

A repository mirror at GitLab will be updated automatically. You can also manually trigger an update at most once every 5 minutes.
Title: Re: MBC
Post by: jack on December 24, 2018, 07:18:22 AM
@AIR
I am on macOS and would like to get my hands on MBC, would you post a link?
Title: Re: MBC
Post by: AIR on December 24, 2018, 09:59:52 AM
Quote
If Gitlab CE had a PROPER mirroring option.

Quote
Repository mirroring allows for mirroring of repositories to and from external sources. It can be used to mirror branches, tags, and commits between repositories.

A repository mirror at GitLab will be updated automatically. You can also manually trigger an update at most once every 5 minutes.

Your instance doesn't seem to support it.  I don't know if full mirror and sync requires the Enterprise version on not...
Title: Re: MBC
Post by: AIR on December 24, 2018, 10:06:59 AM
@AIR
I am on macOS and would like to get my hands on MBC, would you post a link?

Hi, Jack.

https://git.binarymagic.net/AIR/mbc.git

AIR.
Title: Re: MBC
Post by: John on December 24, 2018, 11:43:45 AM
Quote
Your instance doesn't seem to support it.  I don't know if full mirror and sync requires the Enterprise version on not...

Gitlab CE.(sandbox) is running in Enterprise mode. Open source projects (non-commercial) are licensed under this model.
Title: Re: MBC
Post by: jack on December 24, 2018, 12:41:40 PM
@AIR
thank you  :)
Title: Re: MBC
Post by: jack on December 24, 2018, 12:50:11 PM
MBC compiled with no problems, thank yo AIR :)
Title: Re: MBC
Post by: jack on December 24, 2018, 01:01:45 PM
where can I find col.h?
google is no help, it gives a bunch of nonsense results like "Lt Col H Jones Vc Obe | War Imperial War Museums"
Title: Re: MBC
Post by: John on December 24, 2018, 01:22:06 PM
AIR,

Can you create a MBC 'stub' group/project in the sandbox pointing to your repo?
Title: Re: MBC
Post by: AIR on December 24, 2018, 03:04:35 PM
where can I find col.h?
google is no help, it gives a bunch of nonsense results like "Lt Col H Jones Vc Obe | War Imperial War Museums"

LOL, too funny!!

libcol (Cocoa Objects Library) is a library that I created but haven't released to the general public.

I've attached an installer package that you can use (built on Sierra, so no guarantees that it will work on anything older.  I generally go back two OS versions only).

You'll need to do a git pull to get the updated cocoa.inc file, I had to make a minor tweak in it.

AIR.

Title: Re: MBC
Post by: John on December 24, 2018, 03:19:28 PM
The BASIC confederation is forming. We now have AIR Support (https://sandbox.allbasic.info:8181/AIR/mbc).

Thank You!
Title: Re: MBC
Post by: AIR on December 24, 2018, 03:25:59 PM
AIR,

Can you create a MBC 'stub' group/project in the sandbox pointing to your repo?

Created, but I don't think it will sync with any changes I make in my repo.

(https://docs.gitlab.com/ee/workflow/img/repository_mirroring_pull_settings_upper.png)

You need to be able to PULL, your instance defaults to PUSH (meaning your instance can update another repo, but not vice-versa.)

You need to be on the STARTER BRONZE package in order to use this feature, it is NOT available in CORE FREE. 

https://docs.gitlab.com/ee/workflow/repository_mirroring.html#pulling-from-a-remote-repository-starter
Title: Re: MBC
Post by: John on December 24, 2018, 03:34:47 PM
That sucks!

At this point I can't see paying $4 / user / month (paid in advance annually) for the additional features. It's a sandbox not a release repo.
Title: Re: MBC
Post by: AIR on December 24, 2018, 03:39:25 PM
That sucks!

At this point I can't see paying $4 / user / month (paid in advance annually) for the additional features. It's a sandbox not a release repo.

That's another reason why I didn't go with GitLab.  I understand they want to generate revenue, but unless you have a company backing you, it's not worth it.
Title: Re: MBC
Post by: John on December 24, 2018, 06:27:21 PM
I wonder if there is a free Gitlab plug-in to support interfacing with foriegn repos? Hard to believe this hasn't been address already by the community.
Title: Re: MBC
Post by: John on December 24, 2018, 06:39:13 PM
How to properly mirror a git repository (http://blog.plataformatec.com.br/2013/05/how-to-properly-mirror-a-git-repository/)
Title: Re: MBC
Post by: AIR on December 24, 2018, 06:50:40 PM
If you're willing to get your hands dirty, you could probably set up an hourly cron job that will periodically do a git pull/fetch for a given (or several of the) repo's.

Hell, you could write a script in SB to do it, and just schedule it with cron.  The alternative would be a Bash/Python/Ruby script, or some compiled binary.

All you would need to do in the script is CD into the repo root, and issue the appropriate git command.

This is all theoretical, I'm not sure if GitLab does something funky with the repo's.

A good way to test is to use a repo you control on, say, GitHub and mirror it in GitLab.  Then set up what I've suggested above.  Then make a change in the GitHub repo, and see if the change is reflected in GitLab (after the update period you set up in the cron job, of course).

Unlike modifying the GitLab code, this shouldn't violate their TOS since a git repo is a git repo in the end....they just make it simple for the terminal-challenged.

AIR.
Title: Re: MBC
Post by: AIR on December 24, 2018, 06:54:19 PM
How to properly mirror a git repository (http://blog.plataformatec.com.br/2013/05/how-to-properly-mirror-a-git-repository/)

This only references mirroring, it doesn't address keeping that mirror in sync automatically....

For me, git pull and git fetch/git branch (for getting local access to the upstream branches) are all I need to get what I want.
Title: Re: MBC
Post by: AIR on December 24, 2018, 06:59:46 PM
This is probably what you want to look at:  https://help.github.com/articles/syncing-a-fork/
Title: Re: MBC
Post by: John on December 24, 2018, 07:17:10 PM
Am I correct to assume the version of MBC in the sandbox it tuned for Linux where the original is a Mac branch?
Title: Re: MBC
Post by: AIR on December 24, 2018, 08:25:58 PM
Look at the commit message for the mbc4.cc file.

Best to use the provided Makefile, then copy the final binary to a location on your path.
Title: Re: MBC
Post by: John on December 24, 2018, 09:55:09 PM
You said you where looking for feedback so here it is.

Can you do an IUP example in MBC that covers the basics?
Title: Re: MBC
Post by: AIR on December 24, 2018, 10:02:21 PM
When IUP works natively on macOS....remember, my Dev systems are macOS...
Title: Re: MBC
Post by: John on December 24, 2018, 10:32:28 PM
I think you're missing an opertunity to attract the Linux crowd.

Joe (BigFish) from the BaCon group is what you need to make MBC shine on Linux. He would be a good sandbox member to have as well.
Title: Re: MBC
Post by: AIR on December 24, 2018, 10:53:47 PM
I think you're missing an opertunity to attract the Linux crowd.

Linux has many viable options already, macOS only has PureBasic/RealBasic, and to a lesser degree BlitzBasic.  Of the three, only RealBasic accomplishes what I want from a GUI perspective, but at a cost of a ~12MB runtime per app (plus it ain't free).  So that's my focus.

To be completely honest, MBC pisses me off constantly.  I keep having to fix legacy crap from it's Windows BCX C roots.  That's why I've been adding stuff to JADE recently, because a C++/ObjC++ direction using the Cocoa Framework is where I'm heading....

<RANT>

        BTW, F*** SWIFT.  I have to use so much ObjC code to do stuff, it's not worth the effort.

</RANT>

AIR.
Title: Re: MBC
Post by: John on December 25, 2018, 12:01:21 AM
Makes for exciting times here on the forum. I like the variety and different approaches languages/developers take to solve the same task.
Title: Re: MBC
Post by: John on December 25, 2018, 07:33:15 PM
I personally would like to see JADE be the project of interest. It could help with extending C BASIC. I'm planning on pushing the Script BASIC extension modules I wrote which most were done using C BASIC.

I wonder where James Fuller is with his version of BCX?