Donate Now Goal amount for this month: 100 USD, Received: 0 USD (0%)
Donate to support this site and ThinBASIC project development

Results 1 to 2 of 2

Thread: COM Callback

  1. #1

    COM Callback

    I have opened a USB interface with COM and the send works fine.
    I need a CallBack for the input.

    Here is a short script, the first part works, just need callback.

    ' AH COM GUI script created on 09-10-2011 07:30:05 by: JDS  (ThinAIR)
       
        Uses "Console"
        Uses "UI"
        Uses "COM"  ' -- Create object   
        
        Dim Chndl As Long  
        Dim i As Single 
        Dim Params(7) As Variant   
        Dim RetVal As Variant  
      Chndl = Console_Alloc
         Function TBMain()
         
      DWord AHO = COM_CREATEOBJECT ("X10.ActiveHome", Params(7))
         ' -- Call method (parameters should be supplied in form of Variant array)
        
          Params(1) = "sendplc"
          Params(2) = "O09 on"
          COM_CALLMETHOD(AHO, "SendAction", 2, Params(),RetVal)  
                
             
          Params(2) = "o09 off"
          COM_CALLMETHOD(AHO, "SendAction", 2,  Params(), RetVal)       
      
      While Time$
     
      If GetAsyncKeyState(%VK_ESCAPE) Then Exit While  
      Wend    
      
       COM_RELEASE(AHO)   
      
      End Function          
    '---------------------------------------           
       CallBack Function AHO_RecvAction (ByVal bszRecv As Variant _
                                , ByVal vParm1 As Variant _
                                , ByVal vParm2 As Variant _
                                , ByVal vParm3 As Variant _
                                , ByVal vParm4 As Variant _
                                , ByVal vParm5 As Variant _
                                , ByVal vReserved As Variant) As Long  'Handles ActiveHomeObj.RecvAction
         Console_WriteLine bszRecv
         Console_WriteLine vParm1
         Console_WriteLine vParm2
         Console_WriteLine vParm3
         Console_WriteLine vParm4
         Console_WriteLine vParm5
         Console_WriteLine vReserved
         Console_WriteLine
      
      End Function
    
    Hope someone can help! Thanks

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    47
    Posts
    7,605
    Blog Entries
    2
    Rep Power
    10
    steinie,

    I'm sorry but thinBasic has no possibility to create function callbacks other than the one used for Windows handling in UI module.
    The problem is that script functions do not exists as compiled code at runtime but they are only source code to which I cannot derive a code pointer to be passed to a calling function.

    In the past I had an idea on how to solve this puzzle but still had no time to try to implement it.
    The idea was to have some many dummy functions in compiled code (Core module) to be linked to script functions at runtime. So each script function can have its counterpart in compiled code. In this way thinBasic, when asked, can pass the function pointer of the compiled function to which a script function was connected. Done that, the problem was how to parse and pass into the calling stack the needed function parameters.

    Sorry but this is the current situation.
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | psch.thinbasic.com
    Win7Pro 64bit - 8GB Ram - Intel i7 M620 2.67GHz - NVIDIA Quadro FX1800M 1GB

Similar Threads

  1. Callback Error
    By gungadout in forum thinBasic General
    Replies: 5
    Last Post: 23-09-2010, 01:17
  2. Animation within a Callback
    By marcuslee in forum thinBasic General
    Replies: 2
    Last Post: 03-09-2010, 16:57

Bookmarks

Posting Permissions

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