================================================================
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 us
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 with 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 right, then the following things have to
be changed while converting:
Basic PDS: ³PowerBASIC 3:
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
SSEG ³STRSEG
SADD ³STRPTR
SSEGADD ³STRPTR32
³STRPTR32 is only availble from PB3.2 on
VARSEG/VARPTR ³IMPORTANT: PB3 passes UNSIGNED values,
³PDS passes SIGNED values.
³This can be changed with $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
IXED-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
irectly.
ÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÅÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ
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
xternal
³module (unter 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
ype-statements
³('AS xxx'), like with the COMMON
HARED.
³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 problems. 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...
--- CrossPoint v3.11 R
2:2410/330.1)
---------------
* Origin: PBSOUND, PBFILES (27MB), PBFAQ, PBRULES, PBHIVGA at:
|