Announcement

Collapse
No announcement yet.

PB/CC to PB/Win

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

  • PB/CC to PB/Win

    I've been using PB/CC for several months now, have written a couple of (simple) utilities for use at work and really like the product. However, I'm also looking at converting several of my programs to Windows and am wondering if the code itself - I realize I go from procedural to event/object in the conversion - will be pretty much 'cut and paste' or if I'll have to do more than minimal rewriting.

    From comparing the two environments I see the delta in terms of functions and functionality ... and my guess is that the code will transfer pretty much 'as is' during the conversion - again, realizing I'm going to an event-based environment - but would like to hear from y'all to be sure.

    Thanks in advance.

    Tom

  • #2
    All your user interface code will have to be re-written from scratch .. there are no "equivalent" functions in PB/Windows for LOCATE, PRINT, LINE INPUT, INSTAT, etc.

    All your non-UI code, however, is identical.

    Hopefully you have not just bundled all your UI and non-UI code together.

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

    Comment


    • #3
      Thanks, Michael. No, I've kept everything separate ... and don't mind rewriting the UI stuff - which I expected to have to do - but didn't want to have to rewrite all the algorithms, etc.

      Have a good day!

      Tom

      Comment


      • #4
        Tom,

        Most, if not all non-UI code can be reused when porting from PBCC to PBWin.

        The thing to do, is start moving non-UI code into a separate include file, of which can be used later in your PBWin app. Document the routines well (ie. comment explaining how to use the routine).

        Remove all references to the UI in routines which are mostly non-UI code, but have a few UI references.

        ie.

        Say a routine does a calculation and then prints the value to the screen.
        Move the calculation code into a separate routine and have the original routine call it for the calculation and then print the results. Now the calculation routine can be moved to the include file for non-UI routines.

        By rewriting the existing PBCC app, so only UI code is in the main BAS file and nearly all of the non-UI code is in a separate library (include), you will be able to test all your non-UI code routines to make sure they work as intended. Now you are ready to port the app to PBWin. Now you create the UI (now GUI) from scratch and then use the non-UI library code as needed.

        ie.

        Convert:
        Code:
        SUB CalcSomething(BYVAL A&, BYVAL B&)
             LOCAL C&, I&
             C&=0
             FOR I&=1 TO A&
                  C&=C&+(B&^3)
             NEXT I&
             PRINT STR$(C&)
        END SUB
        to:

        Code:
        ' put this kind of routine on non-UI library code
        FUNCTION CalcLoop3(BYVAL A&, BYVAL B&) AS LONG
             LOCAL C&, I&
             C&=0
             FOR I&=1 TO A&
                  C&=C&+(B&^3)
             NEXT I&
             FUNCTION=C&
        END FUNCTION
        '
        SUB CalcSomething(BYVAL A&, BYVAL B&)
             PRINT STR$(CalcLoop3(A&,B&))
        END SUB
        Last edited by Chris Boss; 23 Jan 2008, 11:49 AM.
        Chris Boss
        Computer Workshop
        Developer of "EZGUI"
        http://cwsof.com
        http://twitter.com/EZGUIProGuy

        Comment

        Working...
        X