B4A Library BasicLib interpreter and BasicIDE development IDE revisited

Discussion in 'Additional libraries, classes and official updates' started by agraham, Jan 12, 2019.

  1. agraham

    agraham Expert Licensed User

    Nearly six years ago I posted the original B4A versions of this library and project that were in fact a port to Java from the original Basic4ppc .Net C# versions 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 owing to the now almost total unavailability of small (seven and eight inch) Windows tablets with reasonable amounts of memory and decent performance. In fact even small (seven inch) Android tablets with a decent amount of memory and storage seem to have gone missing from the market :(

    I like to be able to actually knock up small ad hoc programs on a mobile device but have found nothing in the Play Store appropriate for my use (apart from perhaps DroidScript but that’s a different discussion). So I got the Basic4Android trunk down from the attic and blew the dust off it.

    So in case anyone is interested in playing with it here we have an updated, polished and reasonably documented version of my mobile development environment that is easily customized with your own additions. 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.

    At the top level of the zip you will find a Readme.txt file so I suggest you do just that!

    NOTE: This project will not work when run in Release(Obfuscated) mode without renaming all the extension Subs in the Script module to contain underscores. It will also not run with the rapid debugger for reasons described in the help.

    NOTE: If on Android 8.1 or later you are getting unwanted underlining in the editor try adding the following two lines to Main.Activity_Create after the other edtSource property assignments.
    Code:
    edtSource.InputType = 0x00080000 ' TYPE_TEXT_FLAG_NO_SUGGESTIONS
    edtSource.SingleLine = False
    I have posted a complementary B4J BalToBasicIDE project which can use the .bal layout file from a B4A project to provide a control layout for a BasicIDE project.
     

    Attached Files:

    Last edited: Jan 18, 2019
  2. JohnCody

    JohnCody Well-Known Member Licensed User

    Am I correct in my initial understanding that this allows us to embed a basic-like scripting language in our apps that would allow end-users to customize our apps (if our apps expose methods and objects of the app)?
     
  3. agraham

    agraham Expert Licensed User

    Yes! :)
     
    hibrid0 likes this.
  4. JohnCody

    JohnCody Well-Known Member Licensed User

    Cool! I remember a company called Sax that did something similar with VB.
     
  5. Don Oso

    Don Oso Member Licensed User

    this is awesome thanks, your libs can be used with B4J?
     
  6. agraham

    agraham Expert Licensed User

    I don't honestly know! BasicLib probably not as it uses the B4A event mechanism to call back to the host. CollectionsExtra might but it does have a dependency on a B4A library. Both should be capable of working with B4J - I'll have to look at it.
     
    amaxco likes this.
  7. Don Oso

    Don Oso Member Licensed User

    Thanks for you answer ! the possibilities with b4j can be endless
     
    amaxco likes this.
  8. agraham

    agraham Expert Licensed User

    I've just tried and can see that BasicLib needs some minor changes to run in B4J - interestingly against my expectation the event mechanism does seem to work. I guess Erel kept it compatible in B4J with B4A.

    I've got the library running by knocking some out colour related stuff that I will need to rewrite. Although colors are probably of little interest in B4J I may as well try to keep what will be jBasicLib fully aligned with BasicLib. I'll try and post a B4J version in a few days.
     
    mindful, amaxco, Don Oso and 2 others like this.
  9. Erel

    Erel Administrator Staff Member Licensed User

    True.

    About the colors, the correct approach is to leave them as integers and use XUI library with B4XView.
     
    amaxco likes this.
  10. agraham

    agraham Expert Licensed User

    Actually they were, and are, but I was using android.graphics.Color for parsing and combining the A, R, G and B colour components so I need to replace that with some bitwise logic.
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    You can add a reference to XUI library and call the static XUI.Color_RGB or XUI.Color_ARGB methods.
     
  12. Adie

    Adie Member Licensed User

    There is life again. :)

    From here https://www.b4x.com/android/forum/threads/b4a-interpreter.84167/#post-533656

    I finally developed a complete ready mix management system with B4A and BasicLib 1.98 in 2017. All processing programming was done in BasicLib 'format' and run with the interpreter. Speed and robustness was 100%. Basically a VERY high end PLC interfacing with the plant. :D Lots and lots changed and the system was tested on a Raspberry Pi with Android Things. As we went from C++ development to Pascal (Lazarus) the urgent need for Android was pushed to the back of the list. December 2018 we decided to re-evaluate B4A and the Pi for entry level plants. We are porting applicable parts of the Quote and Order systems to Android and B4A. It will only run on 7" systems to accommodate all the on screen data and simplify programming.

    We only used the BasicLib interpeter in our app. Now with the 'upgrade' we will be more 'at ease' with the long term sustainability of the Lib.

    Thanks.

    Adie
     
    Don Oso and agraham like this.
  13. agraham

    agraham Expert Licensed User

    Interesting use case. The source is pure Java, compilable with SLC and available for purchase at the right price if you really want long term assurance. ;)
     
    DonManfred likes this.
  14. agraham

    agraham Expert Licensed User

    jBasicLib version of this library for B4J now posted here
     
    Erel likes this.
  15. Don Oso

    Don Oso Member Licensed User

    Wow ! , thanks for your effort !!
     
  16. johndb

    johndb Active Member Licensed User

    I am testing the interpreter (B4A Version) but I am getting the following error when running the sample script "IdeTest". It would appear that the subs in the script activity are not recognized. I am testing the sample code as-is.

    Error.png
     
    Last edited: Jan 14, 2019
  17. agraham

    agraham Expert Licensed User

    I downloaded the project from the first post above to check and it works fine for me. In the Script module at line 689 should be this
    Code:
    Sub SetActivityTitle(title As String)
        
    Activity.title = title
    End Sub
    and at line 3533 this
    Code:
    ' Activity functions
        Blib.AddSysCalls(Array As String("ActivityFinish", _
                                        
    "CloseMenu", _
                                        
    "GetFirstTime", _
                                        
    "CloseAfterThis", _
                                        
    "LogCat", _
                                        
    "OpenMenu", _
                                        
    "SetActivityBackground", _
                                        
    "SetActivityTitle", _
                                        
    "SetActivityTitleColor"))
    If they are there and it is not working then you have me baffled. Try starting from scratch again.
     
  18. johndb

    johndb Active Member Licensed User

    Yes, both exist. I am using B4A Version 8.80 (latest) and testing it on a Pixel XL with Android version 9. It would appear that all syscalls aren't connected to the script activity. They are all underlined (red) indicating that the subs aren't found. I'll reinstall the libraries and will give it another go. Thanks.
     
  19. johndb

    johndb Active Member Licensed User

    I downloaded it again and unfortunately I had the same error. I also tried using a Galaxy 5, Android Version 6.01 with the same error.
    Has anyone else played with this other than @agraham? It seems to work for him ... he is the author ;)
    Thank you,
    John
     
  20. agraham

    agraham Expert Licensed User

    Thats' not why they are underlined. The editor isn't that clever, there is no code in the main module that does that. The editor is an unadorned EditText which is why I suggest in the help that you use a dedicated code editor like Quoda to edit the code. I've haven't had time to investigate but it looks like EditText may have grown a spellchecker in Android 8.1.0 which is on by default. My Xiamoi Mi Max 3 with 8.1.0 displays them, my Huawei Y7 with 8.0.0 does not. BasicIDE works on both.

    Are you trying to run in Release(obfuscated) mode? If so this will cause the problem you are seeing. The Sub names are mangled and can no longer be identified by their original name. This kills Callsub as well.
     
    Last edited: Mar 17, 2019 at 6:07 PM
    johndb likes this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice