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
    Philippines
    Age
    48
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    133
    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.
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    48
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    133
    just edited my last post- so please have another look at it
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  4. #4
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    48
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    133
    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.
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  5. #5
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Philippines
    Age
    48
    Posts
    1,218
    Blog Entries
    1
    Rep Power
    133
    "Byval ih as Long" ??? Why?
    [TABLE="class: tblf1 tblf-fullwidth tblf-alternate"]
    [TR]
    [TD][COLOR=#b22222][B][SIZE=1]The limit is[/SIZE][/B][/COLOR][/TD]
    [TD="class: isRelinked"] [COLOR=#0000cd][B][SIZE=1]Imagination[/SIZE][/B][/COLOR][/TD]
    [/TR]
    [/TABLE]

  6. #6
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,195
    Blog Entries
    2
    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/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  7. #7
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    50
    Posts
    8,195
    Blog Entries
    2
    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/ | psch.thinbasic.com
    Win10Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

  8. #8
    Ban removed.
    Forum: http://www.jose.it-berater.org/smfforum/index.php<br />Website: http://www.jose.it-berater.org/index.html<br />SED Editor, TypeLib Browser, headers and examples.

  9. #9
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,798
    Blog Entries
    3
    Rep Power
    693
    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 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

  10. #10
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    6,798
    Blog Entries
    3
    Rep Power
    693
    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 7 64bit - Intel Core 2 Duo T6600 @ 2.2GHz - 4 GB RAM - NVIDIA GeForce G210M 512MB
    Windows 8 64bit - Intel Core i5-3350P @ 3.1GHz - 8 GB RAM - NVIDIA GeForce GT640 3GB

Page 1 of 3 123 LastLast

Posting Permissions

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