Results 1 to 10 of 10

Thread: Oxygen can call thinBasic functions

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Oxygen can call thinBasic functions



    thinBasic calls Oxygen function -<-----> Oxygen calls thinBasic function

    With the latest Oxygen, it is now possible to read the PB version of thincore.inc ( included in the example zip below).

    Using two of the more recent thincore functions enables Oxygen to obtain a function token from thinBasic then use it to invoke the thinBasic function.


    Latest Oxygen: http://community.thinbasic.com/index.php?topic=2517

    [code=thinbasic]

    uses "oxygen"

    '-------------------------------
    'thinBasic calls Oxygen function
    'Oxygen calls thinBasic function
    '===============================

    dim v as long
    dim p1,p2,p3,p4 as long
    dim src as string

    src = "
    '
    #o2h
    '
    '
    include `thincore.inc`
    '
    '---------------------------------------
    function callback_token() as long at #p2
    '=======================================
    function=thinBasic_FunctionParseAndGetPtr 0
    end function

    '--------------------------------------------------
    function callback_to(byval a as long) as long at #p3
    '==================================================
    dim as double d
    dim as string s
    dim as double p(10)
    p(1)=42
    thinBasic_FunctionCall_ByPtr a, 1,&p, d,s
    print `thinBasic returns: ` str d
    function=1
    end function

    '------------------
    sub finish() at #p1
    '==================
    terminate
    end sub
    '
    "




    '===============================================================


    'msgbox 0, o2_prep src
    o2_basic src
    if len(o2_error) then
    msgbox 0, o2_error : stop
    end if
    o2_exec

    declare sub finish() at p1
    declare function callback_token() as long at p2
    declare function callback_to(byval a as long) as long at p3

    '===============================================================


    '----------------------------------------------
    function targetfun(byval a as double) as double
    '==============================================
    msgbox 0, "ThinBasic receives: "+str$(a)
    function=a*2
    end function

    '----
    'TEST
    '====

    v=callback_token targetfun
    'v=callback_token "targetfun"
    callback_to v

    finish
    [/code]
    Attached Files Attached Files

Similar Threads

  1. Using Oxygen subs and functions in thinBasic
    By Charles Pegge in forum O2h Compiler
    Replies: 0
    Last Post: 18-03-2009, 13:25

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
  •