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
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
Leave a comment: