Announcement

Collapse
No announcement yet.

More C to PB Declarations Conversion...

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

  • More C to PB Declarations Conversion...

    Code:
    struct  GMWnv;
    typedef GMWnv *HGMNV;
    
    
    // GM5S32.DLL business logic functions
    long _stdcall GMW_Execute( const char *szFunc, HGMNV hgmnv );
    
    
    // create, release & copy name value containers
    HGMNV __stdcall GMW_NV_Create();
    I'm not sure if there is enough information here, but it's all I have. I'm converting a C declaration header file to be used with PB and I came across the code above. What is the struct GMWnv? I know a struct is usually a TYPE in PB, but this struct doesn't have any variables declared within it. I'm not sure how the typedef is being used either. The other thing that's weird (I think) is that the GMWnv struct/typedef isn't being used anywhere in the header file. HGMNV is being used, but that doesn't seem to be declared anywhere.

    I'm sure the problem is my ignorance of C, so if anyone can help then I'm all ears.

    Thanks a lot,
    Scott

    ------------------
    Scott Wolfington
    http://www.boogietools.com




    [This message has been edited by Scott Wolfington (edited March 05, 2003).]
    Scott Wolfington
    [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

  • #2
    hgmnv is a pointer. Try:
    Code:
    DECLARE FUNCTION GMW_NV_Create LIB "GM5S32.dll" ALIAS "GMW_NV_Create" () AS DWORD
    DECLARE FUNCTION GMW_Execute LIB "GM5S32.dll" ALIAS "GMW_Execute" (szFunc AS ASCIIZ, BYVAL hgmnv AS DWORD) AS LONG
    GMW_Execute uses the pointer returned by GMW_NV_Create.




    ------------------

    Comment


    • #3
      Doh! Right, of course. Thanks Jose. What is GMWnv used for?

      Also, one more question...

      LONG _STDCALL GMW_DS_Query( char *szSQL, char *szFilter ="", char *szFDlm ="\r", char *szRDlm ="\n" );

      It looks like szFDlm has a default value of a \r. Is that what that means? Is this possible in PB?

      Scott


      ------------------
      Scott Wolfington
      http://www.boogietools.com




      [This message has been edited by Scott Wolfington (edited March 05, 2003).]
      Scott Wolfington
      [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

      Comment


      • #4
        It looks like they are optional parameters with default values, but you can't do the same in PB (yet?), you have to pass the values.

        Why they use an empty structure to declare a pointer? No idea. C is Chinese to me.




        ------------------

        Comment


        • #5
          Again, thanks Jose. I appreciate it. Ok, my last question wasn't my last. Here's another:

          Should an INT in C be a LONG in PB when converting these declares?

          also

          Should a LONG in C be a DWORD in PB when converting?

          or, do they come over as they are?

          Thanks,
          Scott


          ------------------
          Scott Wolfington
          http://www.boogietools.com




          [This message has been edited by Scott Wolfington (edited March 05, 2003).]
          Scott Wolfington
          [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

          Comment


          • #6
            A C INT is a LONG in 32-bit Windows and an INTEGER in 16-bit Windows. A LONG is a LONG. An UINT (U stands for unsigned) is a DWORD in 32-bit Windows and a WORD in 16-bit Windows. An ULONG is a DWORD.


            ------------------

            Comment


            • #7
              again, thanks jose. i've been using some tips that lance offered in the below forum link, but this fills in some missing pieces for me.
              http://www.powerbasic.com/support/pb...ead.php?t=2696

              ------------------
              scott wolfington
              http://www.boogietools.com


              [this message has been edited by scott wolfington (edited march 05, 2003).]
              Scott Wolfington
              [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

              Comment


              • #8
                In the help file there is a section called "Comparative Data Types" that contains a useful table.


                ------------------

                Comment


                • #9
                  Great. Thanks. I was looking for that in the Appendix but couldn't find it. Now I know.

                  Scott

                  ------------------
                  Scott Wolfington
                  http://www.boogietools.com


                  [This message has been edited by Scott Wolfington (edited March 05, 2003).]
                  Scott Wolfington
                  [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

                  Comment


                  • #10
                    Ok, last question, really (for the night anyway).

                    I've seen some declarations where the pointer asterisk is in different places. For example and using the same function name just as a sample:

                    LONG _STDCALL GMW_DB_Open( char *szTableName );
                    LONG _STDCALL GMW_DB_Open( char* szTableName );

                    Notice the * placement. What's the difference between these?

                    Scott


                    ------------------
                    Scott Wolfington
                    http://www.boogietools.com


                    [This message has been edited by Scott Wolfington (edited March 05, 2003).]
                    Scott Wolfington
                    [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

                    Comment


                    • #11
                      Nothing, as far as I know. It is a pointer to an as ASCIIZ string, so you can translate it to PB as szTableName AS ASCIIZ.


                      ------------------

                      Comment


                      • #12
                        Scott,

                        Jose is right. The * either place is fine. Just a matter
                        of coding style. I like the second one best where the pointer
                        designation is just after the type specifier.

                        Cheers,
                        Cecil

                        ------------------


                        [This message has been edited by Cecil L. Williams (edited February 27, 2003).]

                        Comment


                        • #13
                          The "Comparative Data Types" topic in the PB/Win 6.1x and PB/Win 7.0 help files is highly recommended reading, and can answer a lot of those "what's this translate to in PowerBASIC" questions...


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

                          Comment


                          • #14
                            Thanks Jose, Cecil, and Lance.

                            Lance, you're a little late to the party. Jose mentioned that same help file topic above.

                            Again, thanks guys.

                            Cheers,
                            Scott


                            ------------------
                            Scott Wolfington
                            http://www.boogietools.com


                            [This message has been edited by Scott Wolfington (edited March 05, 2003).]
                            Scott Wolfington
                            [url="http://www.boogietools.com"]http://www.boogietools.com[/url]

                            Comment

                            Working...
                            X