Results 1 to 4 of 4

Thread: [Q]: Function f() PTR?

  1. #1
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170

    [Q]: Function f() PTR?

    I saw in some code-example from Charles some method to set a pointer at the end of the oxygen-function alike

    Function F() As Long At #P
    
    and I tried to find some further information about this and discovered that tB also seems to allow appending some pointers to functions.
    In tB-help it says:
    ...
    Function declaration:
    Function FunctionName [([arguments])] [AsType [PTR]]
    ...
    Now I'm nosy because there's nothing more explained about "PTR".
    How would that work - and what type of pointer?
    Last edited by ReneMiner; 18-07-2013 at 14:55.
    I think there are missing some Forum-sections as beta-testing and support

  2. #2
    Oxygen now uses the word link to pass a function pointer to a thinBasic pointer. ThinBasic uses at ​to map a function address to a pointer

    This is the standard way of interfacing OxygenBasic procedures and thinBasic procedures.

    uses "oxygen"
    
    
    dim as string src
    dim as long pHypot3d
    dim as long pFinish
    
    
    src="
      function hypot3d(double a,double b, double c) as double  link #pHypot3d
      return sqr( a*a+b*b+c*c)
      end function
    
    
      sub finish() link #pFinish
      terminate 'release all resources
      end sub
    "
    o2_basic src
    if o2_error then
      msgbox 0,o2_error
      stop
    else
      o2_exec
    end if
    
    
    declare function Hypot3d(byval double, byval double, byval double ) as double at pHypot3d
    declare sub Finish() at pFinish
    
    
    msgbox 0,Hypot3d(2,3,4)
    Finish()
    
    Last edited by Charles Pegge; 18-07-2013 at 19:19.

  3. #3
    thinBasic MVPs
    Join Date
    Oct 2012
    Location
    Germany
    Age
    54
    Posts
    1,529
    Rep Power
    170
    OK, thanks for your reply. First at all I prefer using Rawtext-method from tB because of syntax highlighting.
    Edit- O2-question here now
    Last edited by ReneMiner; 18-07-2013 at 20:31.
    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,529
    Rep Power
    170
    ok, this was more about the thinBasic "function f() as whatever Ptr"- so I move the oxygen-specific questions over here
    I think there are missing some Forum-sections as beta-testing and support

Similar Threads

  1. Function pointers?
    By MouseTrap in forum thinBasic General
    Replies: 2
    Last Post: 18-02-2009, 21:35
  2. Function Address
    By peter in forum General
    Replies: 7
    Last Post: 29-10-2008, 22:35
  3. Is there a bit-shift function?
    By ISAWHIM in forum thinBasic General
    Replies: 18
    Last Post: 29-09-2008, 17:05
  4. function returned value
    By sandyrepope in forum thinBasic General
    Replies: 4
    Last Post: 07-12-2007, 22:54

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
  •