B4J Library jBasicLib embedded Basic interpreter library

agraham

Expert
Licensed User
Nearly six years ago I posted the original B4A version of this library that was in fact a port to Java from the original Basic4ppc .Net C# version that I wrote even earlier. Shortly after that I gave up Android development out of disgust with Google and returned to playing with Basic4ppc and C# under Windows.

I now find myself back having to use Android for mobile work and have already posted an updated, polished and reasonably documented version for B4A. I now post here a version that will work with B4J.

Download the zip and before extracting it unblock it by right clicking on it in File Explorer, selecting Properties and checking Unblock at the lower right of the General tab otherwise the CHM help files will need to be individually unblocked.

The zip file contains the library jar and xml files and a relatively trivial demo program that does however show how to load, run and monitor a program. At the top level of the zip you will find a Readme.txt file, you know what to do with it (No! Not that! :)).
 

Attachments

wl

Well-Known Member
Licensed User
Seems great !

One question though: is there some possibility to blend the code more in its host application ? It would be nice if the Basic script could use call a method defined in the host B4J application by its name instead of by calling it through CallHostSub ?

Thanks!
 

wl

Well-Known Member
Licensed User
I'm planning to use the library as a simple scripting mechanism in a jServer handler. Is the library threadsafe ?

Thanks
 

agraham

Expert
Licensed User
I assume that you mean threadsafe in the sense that you want to run multiple instances in parallel on separate threads. Yes it should be, the only static item in the library is the version number.

private static final double version = 2.00;
 

agraham

Expert
Licensed User
Note that if you want to call back to the main GUI thread of your app each instance must be initialized on that thread, although it can run programs on any other thread. This is because this B4J version of the library uses the thread on which it was initialized to determined the thread to call in CallGuiSub/SysGui. However a side effect of this will be that all the other events, like Break and Ended, will be called on the main thread as well.

If you initialize the instances on the thread they are to run on then all the events will run on that thread but CallGuiSub/SysGui will also run on that thread and so cannot touch any UI elements.
 

wl

Well-Known Member
Licensed User
Thanks. I'll use it for server side scripting (website), so I guess that won't pose a problem. Thanks !
 

wl

Well-Known Member
Licensed User
Hi,

Looking to passing a key-value pair from the script to B4J with AddSysCalls, but it seems these kind of methods only support a single string as a parameter.

Any possibility to pass 2 string values as parameters ?

I know I can use CallSubHost for multiple parameters.

Thanks!
 
Last edited:

agraham

Expert
Licensed User
I don't know why you think that. The methods added by AddSysCalls are called using CallHostSub under the hood so you can pass methods with as many string parameters as you need.
 
  • Like
Reactions: wl

wl

Well-Known Member
Licensed User
It seems I was wrong: I thought I read it somewhere in the help files and had an error while trying multiple parameters, but I tried it again and it seems to work.

Great ! Thanks!
 
Top