Announcement

Collapse
No announcement yet.

Converting C Structure to PB UDT

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

  • Converting C Structure to PB UDT

    Code:
    struct 
    {
      char *offset;
      int rank, element_size;
      void *base;
    
      struct 
      {
        int mult, lbound, ubound;
      }  dimen[G95_MAX_DIMENSIONS];
    } g95_array_descriptor;
    ____________

    Could anyone please provide me PowerBasic equivalent of this C structure ?

    Thanks in advance...

    ------------------
    Come on and take a tour at where i live in

  • #2
    I had to make some alterations to the member names due to conflicts, but this should be ok:

    Code:
    %G95_MAX_DIMENSIONS = 1 ' <-- REQUIRES DEFINITION
     
    Type dimensions
         mult As Long
         nLBound As Long
         nUBound As Long
    End Type
     
    Type g95_array_descriptor
         offset As Asciiz Ptr
         rank As Long
         element_size As Long
         pbase As Dword
         dimen(%G95_MAX_DIMENSIONS) As dimensions
    End Type
    ------------------
    contact me
    kgpsoftware.com - Free and Commercial Software
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Many thanks Kev, i'll try that...

      ------------------
      Come on and take a tour at where i live in

      Comment


      • #4
        Test!

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

        Comment


        • #5
          FYI in 4.x/8.x it is left to the user preference to change member names when they are the same as reserved BASIC keywords, but with one exception, this is not necessary. Buried in the new features/additional changes section of the help:

          "Members of User-Defined TYPEs and UNIONs can now use PowerBASIC reserved words as names. The single exception is END, which must remain reserved in order to terminate the structure declaration. So, for example, MyType.Print may be a valid data reference."

          The only nuance in the process that may be confusing is that the PB IDE still highlights in the initial definition:
          Code:
          TYPE dimensions
               mult AS LONG
               LBOUND AS LONG
               UBOUND AS LONG
          END TYPE     
          
          'but not in usage, where the "dot" precedes the member name
          
          FUNCTION PBMAIN () AS LONG 
              DIM adscp AS  g95_array_descriptor
              adscp.dimen(1).LBOUND = 0  
          ...
          ------------------
          Rick Angell
          Rick Angell

          Comment


          • #6
            Members of User-Defined TYPEs and UNIONs can now use PowerBASIC reserved words as names.
            REALLY?

            I've been asking for that for six years and three major releases!


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

            Comment


            • #7
              REALLY?
              Yes!
              Only waiting for IDE fix in next update, because reserved words inside UDT's are still hilited as keywords...
              (Gets a bit messy to look at...)

              ------------------
              Regards,
              Peter
              Regards,
              Peter

              Comment


              • #8
                Peter,

                That's just in the original definition, not in the actual places
                where the .member is used. So it's not really <U>too</U>
                distracting. Especially if you maintain the TYPE/UNION sttucture
                declares in an include where you do not need to look at them
                often.


                Michael,

                Asking for this and other things for so many years ... and still
                haven't upgraded from your 7.xx ...
                Mine's already buried under a few GB of bytedust It's so
                much easier in 4/8 with all the improvements, including the one
                mentioned here, but lots of other nuances ( IIRC Bob said hundreds
                the other day) that save time, improve coding / checking and
                extend capability as well. It's not that anyone is pushing you to
                upgrade, but seems like if you had been waiting for these kinds of
                things for a long time, then the impetus to upgrade would already
                have struck.


                (Formatted by EZ-Post Using 67 char Lines)


                ------------------
                Rick Angell

                [This message has been edited by Richard Angell (edited February 11, 2006).]
                Rick Angell

                Comment

                Working...
                X