Go to:  Site entry | Site contents | Site index | Personal Computer | PBCC | Text bottom

PowerBASIC  to  PB/CC  Conversion  Notes

I've endeavoured to start conversion of my old PowerBASIC (16-bit) code to the new PB/CC — PowerBASIC / Console Compiler — (32-bit) code early in 2010.  This was precipitated by necessity to restore my habitual functionality after move to 64-bit Windows-7 that won't support 16-bit applications (Windows-XP emulation proved to be quite a drag, hardly worth of investing any time into it — IMHO, of course).  "New" is just a relational term here — a CD with earlier version of 32-bit PB/CC was collecting dust next to my desktop, I believe, for about 8 or 9 years — an ever busy guy needs a real hard push to shake off a tranquility of relative balance that is so difficult to achieve, and so easy to lose.  It goes without saying that upon tearing dusted cellofane cover from CD case, and running installation it turned out this version of PB/CC won't run under 64-bit Windows-7; got to buy an upgrade consoling myself that I help stay in business the company that develops so good a compiler.

That was an easy part; conversion was by far harder, as one would expect, but to undestand what to convert and how was still eve harder, and unfortunately PB/CC help (that otherwise I find to be of exceptional quality) offered next to nothing to guide one though this painful ordeal.  A pity, of couse, these days when programming is dominated by the new, ever chnging fads, it's by far better chance that anybody who would be interested in good-old BASIC would be some old-timer, who ndealt with it before for whatever reasons. 

"Consistent" is a key word here — almost any style is as good as any other — once the consistency is provided.  It is important to note that the same coding style can be used with a wide variety of programming languages making it easier to switch between them.  If you'll look at other programming examples on this site, you'll see the illustration of the above statement — the same coding style throughout, which is only slightly adjusted to accommodate for the specifics of the corresponding language.

However, each command is not a mere exercise in a code styling — it provides on most part a useful function which is debugged to the best of my ability and is normally tested by several years of intensive usage.  This is not to say that it is in any way guaranteed to be error-free — you will be using any code you pick from this site entirely at your own risk and will be completely responsible yourself for any problems which might arise from this usage.  So when trying code, please exercise the common sense precautions and test code most thoroughly yourself before applying it to anything important.


PowerBASIC to PB/CC Conv Refer Sum  (DOCUM\PBASPBCC.REF)   01/20/2010-10/21/2010
--------------------------------------------------------------------------------

 - Prolong sepatators to 80 characters

 - Change "." into "_" in all compound names that are not structures

   Site.Dir$ --> Site_Dir$

 - Drop - nor longer supported

   OPTION BASE 1  ' Default array indexation starts from "1"

   Leave all the rest as-is, just don't use element "0"

 - Drop PUBLIC from subroutine definition

   FUNCTION TAILSTR$(Strng$,Delim$) PUBLIC
   FUNCTION TAILSTR$(Strng$,Delim$)

 - Change "$" into "#" for INCLUDE

   $INCLUDE "TAILSTR"
   #INCLUDE "TAILSTR"

 - Remove from Z*.BAS

   CLS

   PRINT
   PRINT "Execution completed - hit [Enter] to continue..."

 - Remove from procedures

   ' External SubProgram Library ----------------------------------------------

       $LINK "MODULE.PBL"

 - Enclose procedures into

   FUNCTION PBMAIN
   END FUNCTION

 - This order for Z-Debugging Procedure

     #INCLUDE "TAILSTR"  <-- Before PBMAIN

     FUNCTION PBMAIN

   ' DECLARE FUNCTION TAILSTR$(Strng$,Delim$)  <-- Got to comment it out or delete

 - Drop subroutine declarations - it will be all on #INCLUDEs now

   ' Declaration ------------------------------------------------------------------

   '    DECLARE FUNCTION TAILSTR$(Strng$,Delim$)

 - Change DECLARE into #INCLUDE ONCE

   ' External Function --------------------------------------------------------

        DECLARE FUNCTION DIGITAL%(Strng$,Delim$)

   ' External Function ------------------------------------------------------------

        #INCLUDE ONCE "DIGITAL"

 - Drop External SubProgram Library

   ' External SubProgram Library ----------------------------------------------

        $LINK "MODULE.PBL"

NB: No longer object module funtionality - all has obviously to be done on the
    source level - via #INCLUDEs

    Search for PBL brings only this entry:

    Keyword Differences

    $LINK Units and Libraries
    The $LINK metastatement is no longer supported.  You cannot link .OBJ files,
    units (.PBU) or static libraries (.PBL).

    Cold comfort...

    You can use the DECLARE statement for linking to Dynamic Link Libraries (DLLs).
    The PowerBASIC GUI Compiler for Windows (PB/Win) can be used to compile common
    code into .DLLs, which can then be linked to your application.

    OK, fine, but the switch is pretty drastic, and, IMHO, deservs to be explained
    at least, even if compiler speed can offset this quite senseless recompliles
    of the same code of standard modules over and over again.

    This brings us to:

    #INCLUDE metastatement

    #INCLUDE metastatements can be nested as many as twelve levels deep.

    OK, good to know, this is more than sufficient.

    If  the optional keyword ONCE is included, the specified file is included only one
    time during compilation, regardless of how many times it appears in the program.
    . . . . .
    Effectively, #INCLUDE ONCE means: "Include this file only if it has not already
    been included."

    Which means that only "#INCLUDE ONCE" format should be used for modular setup.

PRINT USING --------------------------------------------------------------------

   PRINT USING and LPRINT USING have been superceded by the FORMAT$ and USING$
   functions.  FORMAT$ takes its parameters are in the reverse order to USING,
   and accepts only one  argument, but offers a more flexible set of digit
   placeholders and format mask options.  USING$ offers the same functionality
   as PRINT USING, but takes the form of a function rather than an output
   statement, permitting greater flexibility.

   E.g.:

   PRINT USING  "###";Percent_Compl
   PRINT USING$("###",Percent_Compl)

DELAY --------------------------------------------------------------------------

   DELAY Pause!
   SLEEP Pause!

Error --- (System Variable) ----------------------------------------------------

   IF (ERRTEST=58)   ' Doesn't report error, not a word in Help, what a shame!..
   IF (ERRCLEAR=58)  ' Works OK, as expected

STOP ---------------------------------------------------------------------------

   STOP  ' Halt program execution
   END   ' Terminate program immediately

   END is intended only for temporary use in converting DOS programs to Windows.
   You should convert it to the standard EXIT FUNCTION method as soon as possible.

Execution Sample ---------------------------------------------------------------

After [Ctrl]+[M] for ZTAILSTR in PB-CC

[C:\]ALIAS BX=`%DEV%:\PBASIC\Z%1`

[C:\]BX TAILSTR
TAILSTR$(0.0)  Get Character String Tail  01-29-2010  21:59
-----------------------------------------------------------

TAILSTR$(''   ,'XYZ')=''
TAILSTR$('ABC',''   )=''
TAILSTR$('ABC','XYZ')=''
TAILSTR$('ABC','A'  )='BC'
TAILSTR$('ABC','AB' )='C'
TAILSTR$('ABC','C'  )=''

[C:\]

  


Go to:  Site entry | Site contents | Site index | Personal Computer | PBCC | Text top