Announcement

Collapse
No announcement yet.

Please help: Translation syntax from C++ to PBWin

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

  • Please help: Translation syntax from C++ to PBWin

    I defined some structures in C++ for vector fonts.
    Just to help You understand the coherences I'm adding the
    whole bunch of definitions.
    Only two of them including pointers seem to be difficult
    to translate to PB because one contains a reference of the other.

    Code:
    // structures for MCF font records
    struct MCFHeader {
    	BYTE bVersion;
    	char szFont[33];
    	short nChars;
    };
    
    struct MCFCharRecord {
    	BYTE ch;
    	short bFillable;
    	fPoint2D fpMin;
    	fPoint2D fpMax;
    };
    
    'Start of difficulties:
    '======================
    
    typedef struct tagMyCharRecord* PMyCharRecord;
    typedef struct tagMyEntityRecord* PMyEntityRecord;
    
    typedef struct tagMyCharRecord {
    	BYTE ch;
    	BOOL tfDefined;
    	short bFillable;
    	fPoint2D fpMin, fpMax;
    	short nEntities;
    	PMyEntityRecord pLast;
    	PMyEntityRecord pNext;
    } MyCharRecord;
    
    typedef struct tagMyEntityRecord {
    	BYTE bKind;
    	short nPoints;
    	fPoint2D* Points;
    	PMyEntityRecord pNext;
    } MyEntityRecord;
    
    'End of difficulties
    '===================
    
    // defines
    #define ENDOFCHAR 99  // end-of-character marker for MCF
    #define MAXREAL (FLOAT)(1.0e+38)
    How do You think have I to translate it?

    Norbert

    ------------------
    Socialism only for people owning everything.
    Norbert Doerre
    Norbert Doerre

  • #2
    I reorganized the types. They are not circular, but use forward referencing, which is not supported in PB. Also note that the type alignment is BYTE in PB but can be set to another value in C. You may have to look at the docs for the correct alignment.

    Hope this helps:

    Code:
    ' structures for MCF font records
     
    Type MCFHeader
         bVersion As Byte
         szFont As Asciiz * 33
         nChars As Integer
    End Type
     
    Type MCFCharRecord
         ch As Byte
         bFillable As Integer
         fpMin As fPoint2D
         fpMax As fPoint2D
    End Type
     
    Type MyEntityRecord
         bKind As Byte
         nPoints As Integer
         Points As fPoint2D Ptr
         pNext As MyEntityRecord Ptr
    End Type
     
    Type MyCharRecord
         ch As Byte
         tfDefined As Long ' BOOL is a LONG in Win32
         bFillable As Integer
         fpMin As fPoint2D
         fpMax As fPoint2D
         nEntities As Integer
         pLast As MyEntityRecord Ptr
         pNext As MyEntityRecord Ptr
    End Type
     
    ' defines
    Macro ENDOFCHAR = 99 ' end-of-character marker for MCF
    Macro MAXREAL = (1.0e+38)
    ------------------
    contact me
    kgpsoftware.com - Free and Commercial Software
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      That's just what I tried out first.
      It lasted some time however until I was aware that forward
      referencing is not allowed in PB. ;-)

      But Your code won't run nevertheless because PMyCharRecord and
      PMyEntityRecord are lacking.
      These definitions are used later in the code to define for instance

      'PMyEntityRecord recEnt'

      or

      'PMyCharRecord recChar'.

      That's just what I don't know how to handle in PB.
      The difficulty is that forward referencing from/to the
      typedef struct. PMyCharRecord and PMyEntityRecord are both
      defined as forward reference and at the same time members of
      typedef struct tagMyCharRecord{...} and tagMyEntityRecord{...}.

      Norbert

      ------------------
      Socialism only for people owning everything.
      Norbert Doerre



      [This message has been edited by norbert doerre (edited March 04, 2006).]
      Norbert Doerre

      Comment


      • #4
        They are just pointers. Use MACRO PMyCharRecord = MyCharRecord Ptr, for example and all should be well. This should be done after the TYPE declarations.

        ------------------
        contact me
        kgpsoftware.com - Free and Commercial Software

        [This message has been edited by Kev Peel (edited March 04, 2006).]
        kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

        Comment


        • #5
          Originally posted by Kev Peel:
          They are just pointers. Use MACRO PMyCharRecord = MyCharRecord Ptr, for example and all should be well. This should be done after the TYPE declarations.


          Yes, 'macro' does it. I don't find much about macro definitions in
          the PB manual. But I have now an idea how to handle it. :-)

          Thanks
          Norbert

          ------------------
          Socialism only for people owning everything.
          Norbert Doerre
          Norbert Doerre

          Comment


          • #6
            nevermind


            THESE 5 CHARACTERS SEQUENTIALLY:
            LOWER CASE "I"
            AMPERSAND
            LOWER CASE "L"
            LOWER CASE "T"
            SEMICOLON

            are the way HTML represents
            Code:
            i<
            just figured it out.

            That what you get for copying code from a web page I guess


            [This message has been edited by Mike Trader (edited March 04, 2006).]

            Comment

            Working...
            X