Announcement

Collapse
No announcement yet.

C to PB help

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

  • C to PB help

    Can "C" guru here please take a look at the following code translation and
    see if there is an error. Thank you

    '***** C CODE **************************************
    'void Upload( void *loadDat, unsigned int ULSize )
    'void *DownLoad( unsigned int request_size)

    'char request[] = “\5\0\2\0\0\16\0\0”;
    'Upload( request, 8 );

    'char *response = DownLoad( 4096 );
    'void *DownLoad( unsigned int request_size)

    '***************************************************

    '******* PB translation ? ***************************
    'DECLARE SUB UpLoad LIB "pigusb_test.DLL" ALIAS "UpLoad" (BYVAL loadDat AS DWORD,BYVAL ULSize AS DWORD)
    'DECLARE FUNCTION DownLoad LIB "pigusb_test.DLL" ALIAS "DownLoad"(BYVAL request_size AS DWORD) AS DWORD

    LOCAL request AS STRING
    request = CHR$(5,0,2,0,0,16,0,0)
    upload ( STRPTR(request), 8)

    LOCAL response AS ASCIIZ PTR
    response = DownLoad(4096)
    CONTROL SET TEXT hDlg, %IDC_TEXTBOX1, STR$(response ) 'see if I get the ptr


    ------------------
    Doug McDonald
    KD5NWK
    www.redforksoftware.com

  • #2
    Use the following:

    CONTROL SET TEXT hDlg, %IDC_TEXTBOX1, @response

    ------------------
    Website: http://com.it-berater.org
    SED Editor, TypeLib Browser, COM Wrappers.
    Forum: http://www.forum.it-berater.org
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      Thank you Jose,

      Does the C to Pb porting Look ok? Data types match up, call correct ect...?

      Thanks again
      Doug

      ------------------
      Doug McDonald
      KD5NWK
      www.redforksoftware.com

      Comment


      • #4
        The parameters look correct. However, you will have to add CDECL to
        the PB declarations.


        ------------------
        Website: http://com.it-berater.org
        SED Editor, TypeLib Browser, COM Wrappers.
        Forum: http://www.forum.it-berater.org
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #5
          > However, you will have to add CDECL to the PB declarations.

          Surely that would depend on the calling convention setting specified in the C "project file"?

          ------------------
          kgpsoftware.com - Downloads
          kgpsoftware.com - Development and Consulting
          kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

          Comment


          • #6
            Thanks again,

            I thought I had it worked out........I think its the D>> I'm calling's problem.
            The people that wrote it are not too good.

            Doug

            ------------------
            Doug McDonald
            KD5NWK
            www.redforksoftware.com

            Comment


            • #7
              >The people that wrote it are not too good.

              Um, then I gotta ask... why are you using this code?

              Surely there is some quality "download" code available here at the right price (free).

              (Textbook example of why I detest "verb-for-verb" translations from other programming languages).


              Michael Mattias
              Tal Systems (retired)
              Port Washington WI USA
              [email protected]
              http://www.talsystems.com

              Comment

              Working...
              X