Page 1 of 4 123 ... LastLast
Results 1 to 10 of 31

Thread: Embedded - supported or not?

  1. #1

    Embedded - supported or not?

    Hi,

    I've been using the old BInt32 code as an embedded script engine. I'd like to switch to thinBasic because the language itself is so much better.

    The .INC file contents SEEM to indicate the same kind of support/interface as BInt32 did, but there's no doc anywhere, and my attempts at guessing based on my BInt32 usage have been utter failures.

    Has anyone done this? Any sample code? Eros seemed to indicate the support was there but he hadn't time to document it.

    It seems so tantalizingly close.

    George

  2. #2
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,089
    Blog Entries
    5
    Rep Power
    725

    Post

    Hi George,

    the embedding mechanism is provided by the thinBasic_Init, thinBasic_Run and thinBasic_Release functions at the moment, which basically launch the script on demnad with some configuration options. I think this is the mechanism thinAIR uses to launch scripts, but Eros will know better.

    These functions are present in thinCore.DLL and they are defined in thinBasic/SDK headers.

    There was not a lot of demand for embedding lately, so other areas got priority. I think we could discuss what you would expect from the embeddable language and maybe the further steps could be taken to make thinBASIC more embed-friendly.

    The "problem" is that thinBASIC became quite capable very fast, so many of us started thinking of it more as of standalone language than simple embeddable helper like BINT32 is


    Petr
    Last edited by Petr Schreiber; 14-03-2013 at 10:25.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  3. #3
    you can use the buffer for interpreting as all bint examples shows in example folder so far I can remember. you have only make "bint_run" function for interpreting buffer string. I have tried last years for studying without any problems. I cannot find my example at work. if I find the script I can say more.

    bye, largo

  4. #4
    Hi Petr,

    Yes, the thinBasic functions are extremely similar to what I have currently working with BInt32; that's why it seems such a small step to move over to thinBasic. However, the thinCore.INC files have absolutely no instructions or comments regarding their use. And there are new parameters being passed to the functions but no help as to what they are supposed to be. Can you shed any light on actually what some of the following parameters are, or how used. thinBasic_Run I'm fine with, it looks just like the BInt32 equivalent call, but thinBasic_Init and thinBasic_Release are both new. Like what are hWnd, cInstance, sKey and hScript? I've been trying to guess, but so far all it gets me is a variety of crashes.

    Declare Function  thinBasic_Init                                _
                              Lib "thinCore.dll"                      _
                              Alias "thinBasic_Init"                  _
                              (                                       _
                                ByVal hWnd            As Long       , _
                                ByVal cInstance       As Long       , _
                                ByVal sKey            As String       _
                              ) As Long
      Declare Function  thinBasic_Release                             _
                              Lib "thinCore.dll"                      _
                              Alias "thinBasic_Release"               _
                              (                                       _
                                ByVal hScript         As Long         _
                              ) As Long
      Declare Function  thinBasic_Run                                 _
                              Lib "thinCore.dll"                      _
                              Alias "thinBasic_Run"                   _
                              (                                       _
                                ByVal hScript         As Long       , _
                                byval sBuffer         As string     , _
                                ByVal BufferType      As Long       , _
                      Optional  ByVal Options         As Long       , _
                                ByVal DebugMode       As Long       , _
                                ByVal LogMode         As Long       , _
                                ByVal ObfuscateMode   As Long       , _
                                ByVal CallingProgram  As Long       , _
                                ByVal DependancyMode  As Long         _
                              ) As Long
    

    George

    Quote Originally Posted by Petr Schreiber View Post
    Hi George,

    the embedding mechanism is provided by the thinBasic_Init, thinBasic_Run and thinBasic_Release functions at the moment, which basically launch the script on demnad with some configuration options. I think this is the mechanism thinAIR uses to launch scripts, but Eros will know better.

    These functions are present in thinCore.DLL and they are defined in thinBasic/SDK headers.

    There was not a lot of demand for embedding lately, so other areas got priority. I think we could discuss what you would expect from the embeddable language and maybe the further steps could be taken to make thinBASIC more embed-friendly.

    The "problem" is that thinBASIC became quite capable very fast, so many of us started thinking of it more as of standalone language than simple embeddable helper like BINT32 is


    Petr

  5. #5
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10
    Hi George,

    first of all, thanks to be here in thinBasic community forum.

    I'm sorry but the actual status of thinBasic is not perfect for embedding into 3rd party applications.
    But together maybe we will be able to add all the necessary/wished functionalities.

    Regarding the 3 main functions, I will document in next thinBasic release.
    Here below an example (using PowerBasic as programming language) that should gives you an idea.

    Let me know.
    Eros


    ...
    
        Local hLib_thinCore           As Long   'Handle of thinCore.dll library
        Local hProc_thinBasic_Init    As Long   'Handle to Init function
        Local hProc_thinBasic_Run     As Long   'Handle to Run function
        Local hProc_thinBasic_Release As Long   'Handle to Release function
        Local lRet                    As Long
    
    
        '---Open and load thinCore.dll library
        hLib_thinCore = LoadLibraryA( ByCopy "thinCore.Dll" )
    
    
        '---If all went fine
        If hLib_thinCore Then ...
          '---Try to load Init, Run, Release functions
          hProc_thinBasic_Init     = GetProcAddress(hLib_thinCore, ByCopy "thinBasic_Init"    )
          hProc_thinBasic_Run      = GetProcAddress(hLib_thinCore, ByCopy "thinBasic_Run"     )
          hProc_thinBasic_Release  = GetProcAddress(hLib_thinCore, ByCopy "thinBasic_Release" )
          
          '---If all went fine ...
          If hProc_thinBasic_Init      And _
             hProc_thinBasic_Run       And _
             hProc_thinBasic_Release   Then
          
            '---Initialise all necessary variables
            Call Dword hProc_thinBasic_Init Using thinBasic_Init( _
                                                                  0&          , _ 'Future usage
                                                                  hCurInstance, _ 'Instance passed from OS to the application usually in Main function
                                                                  "thinBasic"   _ 'Always pass "thinBasic" string
                                                                ) To lRet
    
    
            '---If all went fine ...
            If lRet >= 0& Then
    
    
              '---Run the program
              Call Dword hProc_thinBasic_Run Using _
                            thinBasic_RUN( _
                                            0&                             , _     'Will be used in future release               
                                            sEmbedded_Script_Main          , _     'File name or string Buffer
                                            %thinBasic_BufferType_IsScript , _     '0 = previous string is a File Name, 1 = previous string is a string Buffer                
                                            0                              , _     'Options, set it to zero
                                            %FALSE                         , _     'Debug Mode      %TRUE/%FALSE
                                            %FALSE                         , _     'Log Mode        %TRUE/%FALSE   
                                            %FALSE                         , _     'Obfuscate Mode  %TRUE/%FALSE   
                                            1&                             , _     'Calling Program 1=thinBasic, 2=Console               
                                            %FALSE                           _     'Dependancy Mode %TRUE/%FALSE   
                                          ) To lRet
    
    
              '---Unload all modules, release all memory
              Call Dword hProc_thinBasic_Release Using thinBasic_Release( _
                                                                          0&  _     'Will be used in future release
                                                                        ) To lRet
    
    
            End If
    
    
          End If
          '---Free loaded thinCore library
          FreeLibrary(hLib_thinCore)
        End If
    
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  6. #6
    Hi Eros,

    Super! Many, many thanks. This looks SO CLOSE to what I've been using to access BInt32, I knew it should be possible. I've been using BInt32 for a while, (fixed a few minor bugs in there) but thinBasic sure looked appealing.

    I'll give this a try.

    Is there any hope that equivalents to BInt32_ErrorDescription(), BInt32_ErrorGetToken and Bint32_ErrorGetLine) also exist?

    George

  7. #7
    Hi again,

    Ignore my last question, the normal error popup is more than adequate.

    Quote Originally Posted by gddeluca View Post

    Is there any hope that equivalents to BInt32_ErrorDescription(), BInt32_ErrorGetToken and Bint32_ErrorGetLine) also exist?

    George

  8. #8
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10
    Dear George,

    you can use thinBasic_ErrorFree after thinBasic_RUN to check if execution generated a run-time error.

    In next thinBasic version (I'm just working on it) if you set "Log Mode" to %TRUE in thinBasic_RUN, in case of run-time error thinBasic will create a file into %TEMP%\ directory called with the same name of the script but with estension ".log"
    This file will have a structure like an INI file and will contain something like that:

    [Script]
    Main=<name of the main script>
    Include=<in case of error occurred into an included script, name of the included script>
    [RunTimeError]
    DateTime=17/03/2013 10:40:38
    Code=<error code>
    Description=<error description>
    Line=<line number where error occurred>
    LineCode=<full line of the script where error occurred>
    Token=<first token in the line where error occurred>
    Additional=<optional additional info arrived from run-time error>
    
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  9. #9
    Hi Eros,

    Sounds good. What you provided in your previous note was great, I've managed to swap my App from Bint32 to thinBasic with almost no code changes other than the function renames. Your help is much appreciated.

    George

  10. #10
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    54
    Posts
    8,636
    Blog Entries
    2
    Rep Power
    10
    Great.

    If you like, giving more details on how you use thinBasic as embedded language can give me more info on how to improve thinBasic Core engine.
    In my mind, the idea to embed a programming language into a main application is to perform operations on the main application.
    More or less like having VBA in Office applications (pass me the comparison: VBA is much powerful than thinBasic).

    Is this the case?

    Thanks
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Page 1 of 4 123 ... LastLast

Similar Threads

  1. OpenCL: Supported hardware
    By Petr Schreiber in forum OpenCL
    Replies: 6
    Last Post: 13-02-2010, 10:36
  2. Type pointer var not supported by WITH?
    By Michael Hartlef in forum thinBasic General
    Replies: 9
    Last Post: 24-09-2008, 15:42
  3. glcreateshader not supported !
    By sandyrepope in forum TBGL Bonus Pack
    Replies: 3
    Last Post: 31-10-2007, 13:51
  4. New supported post tag: [youtube]
    By ErosOlmi in forum General
    Replies: 1
    Last Post: 03-02-2007, 10:23

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •