Announcement

Collapse
No announcement yet.

Converting PB/DOS to PB/CC

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

  • Converting PB/DOS to PB/CC

    I have been asked to look into converting a PB DOS program to the
    PBCC compiler. Haven't really had time to do much with it so far
    but I was wondering if anyone can 'clue me in' on problems I'm
    going to face when I start?

    Thanks in advance.

    Tom

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

  • #2
    See that this is your first post. Welcome to the board.

    In as far as syntax goes, with some exceptions, it's pretty
    much a straight conversion.

    The only main thing you have to do is "wrap" your main segment
    in FUNCTION PBMAIN() with a terminating END FUNCTION.

    In PB/DOS, you can use variables on-the-fly as needed. In CC,
    you have to DECLARE them as LONG, STRING, INTEGER, etc. before
    you can use them.

    There are a few other bells-n-whistles you have to take into
    consideration but basically, that's pretty much it.

    You might want to browse the source code forum and check out
    some CC examples.

    Oh, almost forgot to add: You better turn your speakers off or
    get used to that "Ka-Chung" critical error notice CC will give
    you when you make a mistake.

    Just out of idle curosity, what kind of program is it that you
    have been asked to convert?
    ------------------


    [This message has been edited by Mel Bishop (edited August 06, 2006).]
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Mel, isn't it be true that if the pbdos program
      had a DEFINT A-Z (for example) and the PBCC PROGRAM
      also had the same DEFxxx A-Z in it without a DIM ALL that variables
      would default to that type as in pbdos. Otherwise, what
      is the use of a DEFINT,DEFLNG etc. Also without
      the DIM ALL other variables can be done 'on the fly' as long as the
      variable ends with the correct symbol ($,#,!, etc) .

      BTW: I do believe that DIM ALL is the way to go since it
      can avoid nasty spelling error problems that may be
      hard to debug sometimes.

      The following 2 programs have the same result except as Mel
      notes below the pbcc program without a waitkey or inkey$ loop
      will close the window when ended.

      TryPB32
      ------
      Code:
        DEFINT A-Z
        A=100
        PRINT A
      PBCC
      ----
      Code:
        DEFINT A-Z
        FUNCTION PBMAIN() AS LONG
          A=100
          PRINT A
        END FUNCTION
      ------------------
      Client Writeup for the CPA


      mailto:[email protected][email protected]</A>



      [This message has been edited by Fred Buffington (edited August 06, 2006).]
      Client Writeup for the CPA

      buffs.proboards2.com

      Links Page

      Comment


      • #4
        Two things come first to mind:

        A. The file for a PBDOS program contains the main program together with any procedures it calls.

        B. In PBCC everything must be a procedure. Where then does the program start? It always starts by executing the function named PBMAIN (or WINMAIN).

        So to convert from PBDOS to PBCC you must wrap your main code inside
        FUNCTION PBMAIN [or WINMAIN]
        ...
        END FUNCTION

        A. PBDOS: Printed output goes to the monitor screen and unless explicitly erased it persists after the program ends.

        B. PBCC: Printed output goes to the console window and that window automatically closes when the program ends.

        So in your conversion you may want to put the PBCC instruction WAITKEY$, which waits for a keypress, before the program ends.

        For more, see the Help file under
        Programming Reference / Upgrading to PBCC

        If you don’t own PBCC already, the Help file is online at www.powerbasic.com/support/help/pbcc/wf_njs.htm


        [This message has been edited by Mark Hunter (edited August 06, 2006).]
        Politically incorrect signatures about immigration patriots are forbidden. Searching “immigration patriots” is forbidden. Thinking about searching ... well, don’t even think about it.

        Comment


        • #5
          Alan Earnshaw once suggestion one should be begin a PB/DOS=> PB/Windows(any) conversion by changing the MS-DOS program to work in the "all executable code must be within a procedure" format.

          That is, the DOS program should look like..
          Code:
          $COMPILE EXE
          
            CALL Main
          
            END
          
          FUNCTION Main 
          ...

          I still think that is a great idea. Make the changes working in the environment in which you are most comfortable.

          Also quickly identifies "variable scope" isssues which must be resolved anyway.

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

          Comment


          • #6
            Third thing that comes to mind ...

            A. PBDOS: You use the keyword SHARE to indicate that the scope of a variable goes beyond a procedure, and you can use it within or outside procedures.

            B. PBCC: You use the keyword GLOBAL instead, you (should) use it outside any procedure, and it applies to all procedures.
            Politically incorrect signatures about immigration patriots are forbidden. Searching “immigration patriots” is forbidden. Thinking about searching ... well, don’t even think about it.

            Comment


            • #7
              Appendix B of the PB/CC help file, called "Upgrading from DOS" might also be worth a look.

              Knuth

              ------------------
              http://www.softAware.de

              Comment

              Working...
              X