Announcement

Collapse
No announcement yet.

Tiny problem converting C++ to PB

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Tiny problem converting C++ to PB

    Hey all,

    I'm in the middle of converting some C++ code to PowerBASIC code, but there's a problem...
    Unfortunately I can't get the lines with the '<---' comments converted.
    Code:
    typedef	void * __stdcall (*pfnMemoryAllocator)(DWORD);
    typedef	void __stdcall (*pfnPGICallBack)(DWORD, DWORD, LPCTSTR);
    
    
          ...
    
    
    typedef struct tagPGIParamsBlock
    {
        pfnMemoryAllocator pMemAllocator; // function pointer to supplied memory allocation
        pfnPGICallBack pCallBack;         // function pointer to callback function
        LPVOID pInBuff;
        LPVOID pOutBuff;
        DWORD dwInSize;
        DWORD dwOutSize;
        DWORD dwInterface;
        DWORD dwIndex;
    }
    PGIParamsBlock, *PPGIParamsBlock;
    
    
          ...
    
    
    pfnMemoryAllocator MA = pPGIPB->pMemAllocator; // <--- Don't know how to do this!
    pfnPGICallBack CB = pPGIPB->pCallBack;
    
    
          ...
    
    
    if ( CB != NULL ) {
        CB(pPGIPB->dwInterface, evID_PostLogInfo, Message1);  // <--- This neither!
    }
    It's probably pretty easy to convert this to PB code, but I just don't see it...
    Help is greatly appreciated!

    ------------------
    Kind regards,
    Mark Geurds

    mailto:m.geurds[REMOVE]@[TH1S]chello.nlm.geurds[REMOVE]@[TH1S]chello.nl</A>

  • #2
    Hi Mark,

    By the looks of it, MA and CB are global variables that hold function pointers (CodePtr) and should be Global MA As DWORD and Global CB As DWORD, but it is not clear from the code you posted when they are assigned values.

    You call these values using CALL DWORD with these declarations:

    Code:
      Declare Sub CallMA(ByVal DWORD)
      Declare Sub CallCB(ByVal DWORD, ByVal DWORD, ByRef ASCIIZ)
    Hope this helps some!


    ------------------
    contact me
    kgpsoftware.com - Free and Commercial Software
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Hi Kev,

      Thanks for the tip... I'm a bit under the wheather now, so I'll try it as soon as I feel better again.

      ------------------
      Kind regards,
      Mark Geurds

      mailto:m.geurds[REMOVE]@[TH1S]chello.nlm.geurds[REMOVE]@[TH1S]chello.nl</A>

      Comment

      Working...
      X