Announcement

Collapse
No announcement yet.

CALL DWORD

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

  • CALL DWORD

    I am trying to call a function which needs no arguments but returns a long integer.

    dim process as dword
    'assign process to function address
    dim result as long

    call dword process to result 'I can't get this line to compile using PBDLL5.0

    Any help appreciated.

    Regards

    Dave

  • #2
    This works in PBDLL 6.0:
    Code:
    #COMPILE EXE
     
    DECLARE FUNCTION ProcessProc() AS LONG
     
    FUNCTION PBMAIN
     
        DIM Process AS DWORD
        DIM Result AS LONG
         
        Process = CODEPTR(ProcessProc)
     
        CALL DWORD Process USING ProcessProc() TO Result
     
        MSGBOX FORMAT$(Result)
        
    END FUNCTION
     
    FUNCTION ProcessProc() AS LONG
     
        FUNCTION = 1
        
    END FUNCTION

    Comment


    • #3
      When using the TO keyword, you must also use the USING keyword. This requires a DECLARE statement to tell the compiler how to pass parameters (if any) to the target sub/function. Please review the CALL DWORD page in the help file. Peter's code shows this in action.

      -------------
      Lance
      PowerBASIC Support
      ( mailto:[email protected][email protected]</A> )
      Lance
      mailto:[email protected]

      Comment


      • #4
        Thanks

        I did read the documentation (both pdf and hlp) and the following copied from the documentation seems to indicate that you don't have to use USING to use TO.

        CALL DWORD pointer [BDECL|CDECL|SDECL] [TO variable]
        CALL DWORD pointer [USING abc([ Argument_list])] [TO variable]

        Cheers

        Dave

        Comment


        • #5
          That was a bug in the PB/DLL 5.0 documentation that was corrected in the PB/DLL 6.0 documentation. You may want to update to the latest version of the compiler.

          --Dave


          -------------
          PowerBASIC Support
          mailto:[email protected][email protected]</A>

          Home of the BASIC Gurus
          www.basicguru.com

          Comment

          Working...
          X