Main Menu

Recent posts

#1
Tips & Tricks / Re: Calling Lua from BCX with ...
Last post by MrBcx - Today at 03:32:42 PM
Quote from: Quin on Today at 03:19:23 PMCool stuff, MrBcx! this is a super cool looking project.


Indeed -- Tony did a killer job on it.

I tinkered with it a few years ago.  It's a very impressive interpreter and, as I've briefly demonstrated,
really easy to embed into BCX.  I embedded my own basic interpreter into an engineering app that I wrote
35 years ago.  My interpreter was not as sophisticated as Tony Wang's but it still added a usefulness that
I would have dearly missed had I not built it into my app.

For some things, an easy to learn / easy to use scripting language is indispensable.
#2
User Contributions / Re: Bcx EDitor (BED)
Last post by Quin - Today at 03:23:09 PM
MrBcx,
Would it be possible to have Control+F being pressed from the main BED window when the dialog is showing but doesn't have the foreground focus set it to the foreground? If I type a search query, press enter, find it, and then want to type another, control+f doesn't work to bring me back to the dialog, I have to use my screen reader's object navigation to navigate the window hierarchy and manually focus it that way.
Thanks!
#3
Tips & Tricks / Re: Calling Lua from BCX with ...
Last post by Quin - Today at 03:19:23 PM
Cool stuff, MrBcx! this is a super cool looking project.
#4
Tips & Tricks / Re: Calling Lua from BCX with ...
Last post by MrBcx - Today at 02:13:11 PM
Quote from: jos on Today at 01:52:22 PMHi,
Interesting! Would it be possible to do something similar with a Basic interpreter? (Written entirely in C. Very fast and competent.)

https://github.com/paladin-t/my_basic?tab=readme-ov-file

Yes. 

Download my_basic.h and my_basic.c

This BCX sample (below) builds using BED (all compilers except Lcc-Win32)

There will be compiler warnings.


#include "my_basic.c"

DIM bas AS struct mb_interpreter_t PTR
mb_init()
mb_open(&bas)
mb_load_string(bas, "print 22 / 7;", TRUE)
mb_run(bas, TRUE)
mb_close(&bas)
mb_dispose()

PAUSE

Here is a more elaborate BCX example derived from the my_basic wiki Lambda section:


#include "my_basic.c"

DIM script AS STRING

script  = " class my_list"                           + CRLF$
script += "    var l = list()"                       + CRLF$
script += "    var tail = " + WRAP$("__TAIL__")      + CRLF$
script += "    def push_back(i)"                     + CRLF$
script += "        push(l, i)"                       + CRLF$
script += "    enddef"                               + CRLF$
script += "    def pop_back()"                       + CRLF$
script += "        return pop(l)"                    + CRLF$
script += "    enddef"                               + CRLF$
script += "    def get_iterator()"                   + CRLF$
script += "        it = iterator(l)"                 + CRLF$
script += "        return lambda ()"                 + CRLF$
script += "        ("                                + CRLF$
script += "            if not move_next(it) then"    + CRLF$
script += "                return tail"              + CRLF$
script += "            endif"                        + CRLF$
script += "            return get(it)"               + CRLF$
script += "        )"                                + CRLF$
script += "    enddef"                               + CRLF$
script += "endclass"                              + CRLF$
script += "lst = new(my_list)"                    + CRLF$
script += "lst.push_back(1)"                      + CRLF$
script += "lst.push_back(2)"                      + CRLF$
script += "lst.push_back(3)"                      + CRLF$
script += "lst.push_back(4)"                      + CRLF$
script += "iter = lst.get_iterator()"             + CRLF$
script += "do"                                    + CRLF$
script += "    item = iter()"                        + CRLF$
script += "    if item <> lst.tail then"             + CRLF$
script += "        print item;"                      + CRLF$
script += "    endif"                                + CRLF$
script += "until item = lst.tail"                 + CRLF$


DIM bas AS struct mb_interpreter_t PTR
mb_init()
mb_open(&bas)
mb_load_string(bas, script, TRUE)
mb_run(bas, TRUE)
mb_close(&bas)
mb_dispose()

PAUSE


#5
Tips & Tricks / Re: Calling Lua from BCX with ...
Last post by jos - Today at 01:52:22 PM
Hi,
Interesting! Would it be possible to do something similar with a Basic interpreter? (Written entirely in C. Very fast and competent.)

https://github.com/paladin-t/my_basic?tab=readme-ov-file
#6
Tips & Tricks / Re: Calling Lua from BCX with ...
Last post by jbk - Today at 11:59:01 AM
@Quin
interesting, I built a library and am trying to put together some kind of minimal header but it's slow going
#7
Tips & Tricks / Calling Lua from BCX with no D...
Last post by Quin - Today at 10:25:37 AM
Today I discovered Minilua, and was curious if I could get it to work in a BCX application. And I did! This code successfully executes the lua code:
print 'Hello, world!'
And it compiles to a standalone executable, around 280 KB with MSVC using the UCRT. Pretty impressive!
$Header
#define LUA_IMPL
#include "minilua.h"
$Header

Dim L As lua_State Ptr
L = luaL_newstate()
If L = NULL Then End
luaL_openlibs(L)
luaL_loadstring(L, "print 'Hello, world!'")
lua_call(L, 0, 0)
lua_close(L)
#8
Bug Reports / Re: Using $Warnings_On with MS...
Last post by Quin - Today at 07:41:40 AM
Robert,
Touche. I admittedly skipped over that comment when I glanced at it. This seems fine as it is :)
Perhaps something could be added to the description as well noting it, but it's stated in the comment so that's not super necessary
#9
Bug Reports / Re: Using $Warnings_On with MS...
Last post by Robert - April 26, 2025, 09:08:31 PM
Quote from: Quin on April 26, 2025, 04:13:14 PM
Quote from: MrBcx on April 26, 2025, 02:17:39 PMEverything that you sandwich between $HEADER directives must be legal c/c++ or c/c++ pre-processors commands.  You cannot use BCX's BASIC directives, like $PRAGMA.
Gotcha, thanks!
Robert, could we consider noting this in the help?

Hi Quin:

What is "this" that you want noted? And where would you like it noted?

The last sentence in the Purpose: portion of the $HEADER directive section is

QuoteA $HEADER directive is placed before and after the C code.

That sentence is immediately followed by the Syntax: description, which is
$HEADER

 /* C statements go here */

$HEADER
#10
Bug Reports / Re: Using $Warnings_On with MS...
Last post by Quin - April 26, 2025, 04:13:14 PM
Quote from: MrBcx on April 26, 2025, 02:17:39 PMEverything that you sandwich between $HEADER directives must be legal c/c++ or c/c++ pre-processors commands.  You cannot use BCX's BASIC directives, like $PRAGMA.
Gotcha, thanks!
Robert, could we consider noting this in the help?