8. Hints about conversion of Sources from PDS to PowerBASIC 3.x
(from Mark Junker@2:2437/47.21 / mjs@prg.hannover.sgh-net.de)
Generally you can say that PDS-Sources can be converted into PB3-
Sources. Exceptions are Sources which access foreign libraries and use
a dimensioned elements in a TYPE-Structure.
So, the following does not allow a conversion:
- Foreign libraries
(like VESA-LIB and everything else there is out there...)
- Dimensioned elements in a TYPE-Structure
Example:
TYPE tTest
TestElement1 AS LONG
TestElement2(2 to 7) AS INTEGER
TestElement3 AS LONG
END TYPE
- There may be no COMMON, but all variants of the COMMON SHARED-
Command are allowed.
Exception:
- When COMMON is used to pass parameters to a file
called by CHAIN.
- When it is irrelevant that the variables behind the
COMMON are available in all procedures.
- Arrays with more than 8 Dimensions
- REDIM PRESERVE is not flexible enough yet
- More than 16 Parameters when calling a procedure
When all of these things are not implemented, then the following
things have to be changed while converting:
Basic PDS: |PowerBASIC 3:
-------------------------------------------------------------------------
SSEG |STRSEG
SADD |STRPTR
SSEGADD |STRPTR32
|STRPTR32 is only available from PB3.2 on
VARSEG/VARPTR |IMPORTANT: PB3 passes UNSIGNED values,
|PDS passes SIGNED values.
|This can be changed using $OPTION SIGNED
|OFF.
-------------------------------------------------------------------------
Offset of a file opened with OPEN|PB starts every file, you choose,
starts with '1'! |at Zero (Standard) or at one. This can
|be changed with the following command:
|OPTION BINARY BASE 1
|for the start at '1'
-------------------------------------------------------------------------
DIM SHARED VarName% |This command can be converted in
|two ways:
|- DIM VarName%
| SHARED VarName%
|- DIM VarName AS SHARED INTEGER
-------------------------------------------------------------------------
SHARED VarName() AS STRING*3 |Here we have the problem with Strings
|of fixed length, when they can't be
|SHARED in the main program.
|You may not make any Type-statements
|('AS xxx') after SHARED.
| SHARED VarName as string
| will become: SHARED VarName$
| or: SHARED VarName :'in SUBs !
|
|You can SHARE FIXED-LENGTH-STRING-Arrays
|like this:
|DIM VarName(MIN,DimNum) AS STRING*3
|or
|DIM VarName(MAX,DimNum) AS STRING*3
|where 'DimNum' is the number of
|Dimensions of the Array and the number
|must be entered in the program directly.
-------------------------------------------------------------------------
COMMON SHARED /Block/ VarN% |All three variants of the COMMON-
COMMON SHARED VarN% |command must be replaced in the main
|program using PUBLIC and in the external
|module (under PB: UNIT) using an EXTERNAL
|You have to watch that the variable names
|MUST be identifyable, and without a Type.
|All Type-Structures 'AS xxx' are not
|valid in PB3.
|Die Block-statement (/Block/) is not
|needed, because everything is not
|chained to the name. (->Incompatibility!)
-------------------------------------------------------------------------
COMMON VarN% |Can only be converted if the variable
|after the COMMON will be passed to a
|program started with the CHAIN-Command,
|or the COMMON could be a COMMON SHARED
|i.E.
|It is not allowed to use Type-statements
|('AS xxx'), like with the COMMON SHARED.
|All Type-statements must be removed
-------------------------------------------------------------------------
'$INCLUDE: 'filename.ext' |$INCLUDE "filename.ext"
'$DYNAMIC |$DYNAMIC
'$STATIC |$STATIC
-------------------------------------------------------------------------
CONST VarName$ = "xyz" |The variable must be replaced in the
CONST VarName# = 1.23 |whole program with the specified value.
CONST VarName! = 1.23 |
CONST VarName@ = 1.23 |
-------------------------------------------------------------------------
CONST VarName% = 123 |Becomes
CONST VarName& = 123 |%VarName = 123 both times.
|If a Constant-Name is used twice,
|with different Datatypes, one of the
|two must be replaced in the entire
|source with 'VarName%' or 'VarName&'.
-------------------------------------------------------------------------
IF x THEN : ' Test |In PB only the ':' has to be
something |removed and it will be compiled without
END IF |problems.
-------------------------------------------------------------------------
DIM x AS STRING*3 |This FIXED-LENGTH-STRING can not be
CALL Test(x) |passed to a procedure without
END |problems, because PB needs a VARIABLE-
SUB Test(x$) |LENGTH-STRING or instead of the 'x$' an
END SUB |'x AS STRING * 3' in the SUB-Header.
|You have to use a temporary way over a
|temporary String:
-------------------------------------------------------------------------
It would be idle to write a converter for the Constants-Conversion,
because this would be the main part when converting big projects. At
the same time you can of course do the stuff with the COMMON SHAREDs
and the DIM SHAREDs and of course with the META-Statements, as well as
SSEG/SADD/SSEGADD.
When interrupt calls are made with a CALL INTERRUPT or CALL
INTERRUPTX, then you can rebuild the Routine 'INTERRUPTX' in the
Inline-Assembler and then convert all calls of 'INTERRUPT' to
'INTERRUPTX' or directly do it in the Inline-Assembler or you can use
the PowerBASIC 'CALL INTERRUPT'- Routine, where you will have to
convert all register statements...