Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: thinBASIC IUP

  1. #1

    thinBASIC IUP

    *** deleted ***
    Last edited by John Spikowski; 18-09-2013 at 01:42.
    ScriptBasic Project Manager
    Project Site
    support@scriptbasic.org

  2. #2
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    Quote Originally Posted by John Spikowski View Post
    I'm trying to get callbacks working with thinBASIC. I'm not sure if this is even possible...

    sounds familiar...

    Just some nosy questions:

    What about that IUP? It's some .dll that I can find in your scriptbasic-examples-thread I guess?

    And- why are the statements as in IupSetAttributes(btn1, "TITLE=Button1, EXPAND=HORIZONTAL") in quotes as it were strings?
    I think that's not a good idea if you think about adding code-spell-correction one day.
    And - are those string-statements maybe case-sensitive?

    Edit-
    What makes me wonder too:
    Function_GetPtr
    help says: "Returns the internal pointer of a script function or sub"
    Returned pointer is thinBasic internal pointer. It has no meaning outside thinBasic.
    Do not confuse it with machine or code pointers.
    Last edited by ReneMiner; 01-03-2013 at 20:05.
    I think there are missing some Forum-sections as beta-testing and support

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    just edited my last post- so please have another look at it
    I think there are missing some Forum-sections as beta-testing and support

  4. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    Just snooped around in the helpfile because I thought it might be that thinBasic is not able to pass pointers to external functions. This is what I found about
    "External function declarations"

    There are still some limitations regarding type of parameters thinBasic is able to pass to external functions.

    If you are in trouble, please visit thinBasic forum and leave a message regarding the problem you are facing and possibly specify an exact example. We will do our best to try to solve the problem as soon as possible.
    but it's just a guess since I have no idea about the internal stuff.
    Maybe you could store the result of Function_GetPtr in another variable and pass this?
    Last edited by ReneMiner; 01-03-2013 at 20:22.
    I think there are missing some Forum-sections as beta-testing and support

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,530
    Rep Power
    171
    "Byval ih as Long" ??? Why?
    I think there are missing some Forum-sections as beta-testing and support

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Hi all,

    as I said many times in this forum, unfortunately there is no way (at the moment) to pass thinBasic script function pointer simply because there is no function and there is no pointer.

    When an external function ask for a function pointer or a code pointer they are referring to pointers to machine code currently running in the current process.
    But thinbasic functions are not translated into machine code, they are just text (simple and damn text) parsed and interpreted on the fly by thinBasic engine.
    thinBasic source code is never translated/converted/compiled into machine code of pcode or intermediate code (or whatever you call it)
    thinBasic source code is just text during all the process of thinBasic source code execution.

    In any case, it is some time (some months) I'm thinking about this trying to find a solution.
    What I have in mind is to create a sort of "machine code alias" for each thinBasic source code function present into a script in such a way every source code function (or sub) has a machine code ghost function into thinBasic engine in such a way to pass pointer of the machine code ghost function to external libraries asking for a callback.

    Sooner or later ...
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,777
    Rep Power
    10
    Well,

    thanks to you too for spending your time in showing how to use IUP library in thinBasic.
    I really appreciate it

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  8. #8

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi John,

    when I am in situation I need a callback in ThinBASIC, I use Oxygen module to handle this for me. Below little example:
    ' ---------------------------------------------------------------------------------------
    ' JIT Part Beginning
    ' ---------------------------------------------------------------------------------------
    Uses "Oxygen"
    
    DWord oxyCallback      ' -- This will contain pointer to JIT function Oxygen_Callback
    DWord oxyTerminate     ' -- This will contain pointer to JIT function Oxygen_Terminate
    
    String callbackCode = "     
    basic 
    
    Sub Oxygen_Callback CDECL ( ByVal param1 As DWord) Link #oxyCallback
                            
       Dim strMsg As String
    
       strMsg = `Passed param = ` & Str(param1)
       
       Print strMsg
    
    End Sub    
    
    Sub Oxygen_Terminate() Link #oxyTerminate
      terminate
    End Sub
    "                                           
      
    ' -- JIT compile  
    O2_BASIC callbackCode
    
    ' -- Check for errors
    If Len(O2_ERROR) Then
      MsgBox 0, O2_ERROR, "JIT compilation failed" 
      Stop
    End If
    
    ' -- Activate
    O2_EXEC
                                  
    ' ---------------------------------------------------------------------------------------
    ' JIT Part End
    ' ---------------------------------------------------------------------------------------
    
    ' -- Declare functions from oxygen
    Declare Sub Oxygen_Callback ( ByVal param1 As DWord)
    Declare Sub Oxygen_Terminate ()   
    
    ' -- Assign them address to make em callable
    Declare Set Address Oxygen_Callback , oxyCallback
    Declare Set Address Oxygen_Terminate, oxyTerminate
    
    ' -- Main code
    Function TBMain()                   
    
      MsgBox 0, "The code pointer to Oxygen_Callback is &h0" + Hex$(oxyCallback)
      MsgBox 0, "The code pointer to Oxygen_Terminate is &h0" + Hex$(oxyTerminate)
      
      Oxygen_Callback(123)
      Oxygen_Terminate()
                          
    End Function
    

    Petr
    Last edited by Petr Schreiber; 27-03-2013 at 17:08.
    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

  10. #10
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,128
    Rep Power
    732
    Hi John,

    you have an interesting observation, as I never noticed the dropping behavior when using OpenGL or OpenCL. But Eros will know more.

    In the meantime, maybe the Library_Exists could help. Why? Help says the syntax is the following:
    Library_Exists[ ( sLibName [, KeepLibLoaded ]) ]
    Which means, that if you pass second parameter equal to true, it will keep the lib... well, loaded Never had a reason to use it so far, so cannot add more info.


    Petr
    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

Page 1 of 3 123 LastLast

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

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