Migrating Changed Features [ HP Business BASIC/XL Migration Guide ] MPE/iX 5.0 Documentation
HP Business BASIC/XL Migration Guide
Migrating Changed Features
The BASIC/V features listed below work differently in HP Business
BASIC/XL. Change your use of these features as indicated below to avoid
problems in your applications. The items enclosed in parentheses "( )"
are user-specified expressions, statements, variables, and so on. Most
of these references contain a descriptive name that precedes the type of
the expression. This is meant as an aid to indicate what that expression
represents.
Branching to ELSE Statements
BASIC/V always executes the statements after an ELSE when you branch (via
a GOTO) to the ELSE line of an IF-THEN-ELSE structure. HP Business
BASIC/XL never executes the statements after an ELSE in this kind of
structure.
Table 10-1. Branching to an ELSE Line
---------------------------------------------------------------------------------------------
| | |
| BASIC/V | HP Business BASIC/XL |
| | |
---------------------------------------------------------------------------------------------
| | |
| 10 GOTO 50 | 10 GOTO 50 |
| 20 IF X THEN DO | 20 IF X THEN |
| 30 PRINT "TRUE" | 30 PRINT "TRUE" |
| 40 DOEND | 50 ELSE |
| 50 ELSE DO | 60 PRINT "FALSE" |
| 60 PRINT "FALSE" | 70 ENDIF |
| 70 DOEND | |
| | |
---------------------------------------------------------------------------------------------
The BASIC/V program above prints "FALSE" when executed. The HP Business
BASIC/XL version does not print anything. However, both programs print
"FALSE" if line 10 branches to line 60.
CALLs to FORTRAN 77
Routines called from BASIC/V programs might need substantial
modifications to be called from HP Business BASIC/XL programs. This is
because most of these routines rely on BASIC/V's parameter passing scheme
and on the internal representation of BASIC/V strings and arrays.
BASIC/V's parameter passing scheme is described in appendix G of the
BASIC/V Reference Manual. For example, many routines assume strings are
preceded by two bytes that contain the maximum and actual lengths of the
string. Because BASIC/V only allows strings up to 255 characters, only a
byte is needed for each length. However, in HP Business BASIC/XL,
strings can be much longer and a full word, 32 bits, is needed for
representing string length. There are similar differences for arrays.
Before rewriting these routines in another language, check to see if HP
Business BASIC/XL offers the capability provided by the routine. For
example, programmers wrote FORTRAN 77 routines as interfaces between
BASIC/V and system intrinsics. HP Business BASIC/XL can call intrinsics
directly, so these routines are no longer needed.
There are two ways to migrate BASIC/V programs that use the CALL
statement to access FORTRAN 77 routines:
1. Use the BASIC EXTERNAL statement to define the FORTRAN routine.
2. Use the ANYPARM call method.
Use the BASIC EXTERNAL statement to define the FORTRAN routine if the
BASIC/V program always calls the FORTRAN routine with the same number and
type of parameters.
Use the ANYPARM call method if the number or type of parameters varies.
Refer to the HP Business BASIC/XL Reference Manual for information about
the ANYPARM call method.
Find out whether or not the BASIC/V program always calls the FORTRAN
routine with the same number and type of parameters by checking the
format of the parameter address table that BASIC/V built for each CALL.
Include code that checks for correct calling sequences in FORTRAN
routines because BASIC/V does not check external CALLs. Refer to the
BASIC/V Interpreter Reference Manual for information about writing this
type of routine.
Recompile routines you will use in native mode and write switch stubs for
routines you will use in compatibility mode. Refer to the Switch
Programming Guide for information about the switch subsystem and
programmatic access through switch stubs.
CHAIN (Compiled)
The migration aid automatically changes CHAIN statements to GET
statements. Interpreted GET statements replace the current program with
the program specified in the GET statement. However, GET statements are
not compilable. The three migration methods explained here work in both
interpreted and compiled programs:
* Change the chained program to a SUB, then CALL it instead of chaining
it. Include a STOP immediately after the CALL (in the calling
program.) Use the SUB option of the CONVERT command to change the
chained program to a SUB.
You can either merge the SUB into the calling program, or you can
compile the SUB separately and put it in an XL. If you compile the
SUB separately and put it in an XL, include an EXTERNAL declaration
in the calling program.
* Compile the chained program with GLOBAL OPTION SUB, NONEWCOM. This
lets you CALL the MAIN subunit of this program. The name of the MAIN
consists of the source file name followed by two single quotes; if
the source file name for the chained program is INVNT3, then the MAIN
of that program is called INVNT3" when it is compiled.
Use an EXTERNAL declaration in the chaining program. Use an ALIAS
clause because single quotes are not valid in HP Business BASIC/XL
identifiers.
* Compile the chained program as a separate program file. You can
execute this separate program file from the chaining program by using
the SYSTEMRUN statement. The two programs cannot share common
variables, but you can use files to pass data between them. You can
also use the INFO parameter of the SYSTEMRUN command to send data
from the first program to the second program. Include a STOP
immediately after the SYSTEMRUN statement in the first program.
For information about migrating interpreted CHAIN statements, see chapter
13, "Reviewing What the Migration Aid Changes for You".
Data Files
The main difference between compatibility mode data files and native mode
data files is the internal representation of floating-point real format.
Data file word length is 16 bits on both MPE V and MPE XL machines.
BASIC/V program word length is 16 bits; HP Business BASIC/XL program word
length is 32 bits because of hardware and operating system differences.
However, a 16 bit word length is used for HP Business BASIC DATA files in
HP Business BASIC/XL for compatibility. Real and short real data types
are in IEEE floating-point format in all native mode data files. Real
and short real data types are in MPE V floating-point format in all
compatibility mode data files. See chapter 11, "Migrating BASIC/V
Files," for more information about data file migration.
DEF
In BASIC/V, multiline functions can access any data defined (either
explicitly or implicitly) in the MAIN program. In HP Business BASIC/XL,
multiline functions are separate procedures; global data is only
accessible if it is passed as a parameter or in a common statement. The
migration aid identifies all variables (except local variables) accessed
by multiline functions and lists them in a comment at the end of the
function.
You can do one of the following for each variable listed in the comment:
* Pass the variable as a parameter to the multiline function.
* Place the variable in common.
* Declare the variable in the function if it does not need to be shared
between the main program unit and the function.
Externals
MPE V external names are case insensitive; "myprog", "MYPROG", and
"Myprog", all reference the same procedure. MPE XL external names are
case sensitive; "myprog", "MYPROG", and "Myprog" all reference different
procedures. Native mode system intrinsics are usually in uppercase (for
example, "FOPEN"), and user procedures are usually in lowercase (for
example, "myprog"). Therefore, HP Business BASIC/XL changes all external
names to lowercase. Use the ALIAS option of the EXTERNAL statement to
call external procedures that have uppercase names.
Refer to the HP Business BASIC/XL Reference Manual for information about
using the EXTERNAL statement.
The MPE XL search order for resolving externals is similar to the MPE V
search order when you specify LIB = G, P, and S. The names of the native
mode executable libraries searched are XL instead of SL. The XL option of
the RUN command lets you specify a list of executable libraries to
search, like in the example below:
RUN MYPROG; XL="lib1,lib2,lib3"
The externals in the example above are resolved by searching the
following files in the specified order:
MYPROG ->LIB1 ->LIB2 ->LIB3 ->XL.PUB.SYS ->
NL.PUB.SYS
Filecodes of Program and Data Files
Native mode HP Business BASIC/XL program and data file filecodes are
different in HP Business BASIC/XL; the corresponding names are different,
too.
Table 10-2. Filecodes of Program and Data Files
----------------------------------------------------------------------------------------------
| | | |
| Name | Filecode | Description |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| BASFP | 1027 | BASIC/V SAVE file |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| BSVXL | 1247 | HP Business BASIC/XL SAVE |
| | | file |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| BASD | 1025 | BASIC/V DATA file |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| BDTXL | 1248 | HP Business BASIC/XL DATA |
| | | file |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| BBNCM | 1249 | MPE V binary file* |
| | | |
----------------------------------------------------------------------------------------------
Notes. * This filecode is used for native mode file access. The
migration aid adds this code where needed.
You can distinguish files by looking at the filecode in the LISTF
command. You need to change your source files if they depend on filecode
names. For example, to list all the BASIC DATA files in your group on an
MPE V machine, type the following:
CATALOG TYPE = "BASD"
To list all the BASIC DATA files in your group on an MPE XL machine, type
this instead:
CATALOG TYPE = "BDTXL"
FILES Statement
Some of these statements are automatically translated by the migration
aid. The translation method depends on the purpose of the FILES
statement.
The BASIC/V FILES statement can serve any of three purposes:
1. Open files.
2. Reserve file numbers.
3. Specify files to be shared between functions.
FILES statements that open files are automatically translated as
indicated in chapter 13, "Reviewing What the Migration Aid Changes for
You". FILES statements that reserve file numbers are automatically
changed to comments as indicated in chapter 13, "Reviewing What the
Migration Aid Changes for You". FILES statements that specify files that
are to be shared between functions must be manually translated as
indicated below.
Specify Files to be Shared Between Functions. FILES statements of the
form
FILES #3,#7
specify that access to these files is allowed from a function even though
they were assigned (using the ASSIGN statement) in main or in another
function. This has to be manually translated so the files are either
passed as parameters or placed in common.
Floating-Point Real Format
MPE XL systems represent floating point real format differently than MPE
V systems. MPE XL systems represent all real numbers in IEEE real
format.
The MPE XL real range is shown below:
[-1.79769313486231E+308 .. -4.94065645841247E-324],
0,
[ 4.94065645841247E-324 .. 1.79768313486231E+308 ]
The MPE XL short real range is shown below:
[-3.40283E+38 .. -1.401298E-45],
0,
[ 1.401298E-45 .. 3.402823E+38 ]
MPE XL default values are different. These are the minimum and maximum
values for real data types:
Table 10-3. Minimum and Maximum MPE XL Real Data Type Values
----------------------------------------------------------------------------------------------
| | | |
| Data Type | Minimum Exponent Value | Maximum Exponent Value |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| Real | -324 | +308 |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| Short Real | -45 | +38 |
| | | |
----------------------------------------------------------------------------------------------
NOTE MPE XL short real ranges are smaller than those on MPE V. This
causes potential problems because calculations and assignments
result in short real overflow when they reach these short real
limits.
MPE V real and short real ranges are both +/-77; You could change real
values to short real values without risking an overflow. This is not
true on MPE XL. You might need to develop new error handling code.
MPE XL only displays 15 significant digits for REAL data because IEEE
real format is only accurate to 15.9 digits. MPE V displays 16
significant digits because internal MPE V real format is accurate to 16.5
digits.
To change BASIC/V data (BASD) files to HP Business BASIC/XL DATA (BDTXL)
files, use the MPE XL option of the migration aid. This option changes
all MPE V real numbers to IEEE real data format. MPE V short real
numbers can have exponents between +77 and -77; MPE XL short real numbers
are only allowed exponents between +38 and -45. If there is a short real
overflow during migration, the migration aid replaces short real data
with either the minimum or maximum short real, as appropriate.
Intrinsic File
System calls from BASIC/V are only supported by calls from SPL or FORTRAN
externals in a System Library (SL). HP Business BASIC/XL supports direct
system calls by returning procedure headers in an intrinsic file.
If you do not specify a filename in the INTRINSIC definition, HP Business
BASIC/XL looks for the definition of the intrinsic routines in the
default intrinsic file (SYSINTR.PUB.SYS). The MPE V default intrinsic
file is SPLINTR.PUB.SYS. You can still specify which intrinsic file you
want searched for external procedure header information. Specify the
intrinsic file in the INTRINSIC statement.
The intrinsic file internal format is different for MPE XL native mode
programs. SPLINTR.PUB.SYS is the default file searched for intrinsic
definitions for MPE V programs and MPE XL compatibility mode programs.
The SPLINTR file and the intrinsic definition files created by MPE V
users access the SPL compiler. A limited amount of information is stored
about each procedure including the number of parameters and the type of
each. Use BUILDINT in the Pascal compiler to create SYSINTR files.
These files contain much more information about the procedure and each
parameter than SPLINTR.PUB.SYS. You can include a default value and the
anticipated alignment and offset for each parameter. The two types of
intrinsic files have dramatically different formats. Refer to the HP
Pascal Reference Manual for more information about setting up your own
intrinsic definitions in native mode.
Define all the externals that are intrinsics as INTRINSIC (not EXTERNAL)
routines. The actual name used to call the intrinsic is in the intrinsic
file. The actual name of the external's entry point returns from the
intrinsic file when HP Business BASIC/XL processes the INTRINSIC
statement definition. Hence, intrinsic calls are case sensitive with
regard to the name that you use in the HP Business BASIC/XL program.
Some intrinsics are specific to MPE V and are not available in native
mode. Intrinsic calls that are not in the intrinsic file generate error
messages. Intrinsic calls with empty parameters are not allowed unless
you specify a default value for the missing parameter in the intrinsic
file. The intrinsic name truncates after the first 60 characters.
The MPE XL intrinsic mechanism has a limited ability to specify default
values for selected types. If an intrinsic's parameter information
specifies a default for the format parameter, then you do not need to
specify an actual parameter to correspond to that formal parameter. If
the actual parameter is not supplied, then the default value from the
intrinsic file is used when the call is made. Extension parameters do
not use default values unless the parameter is a missing actual parameter
and has both a subsequent actual parameter in the parameter list and a
default value supplied.
INVOKE Statement (Compiled)
Compiled BASIC/V INVOKE statements are similar to HP Business BASIC/XL
CALL statements. The differences between the BASIC/V INVOKE statement
and the HP Business BASIC/XL CALL statement are described below:
1. In BASIC/V, INVOKE saves the current program and its data in a
temporary file, loads the invoked program and executes it. Then
the original program is read from the file and execution continues
at the line after the INVOKE. The two programs can share common
variables.
In HP Business BASIC/XL, you can either call subprograms that are
contained in the same source file as the caller or you can call
routines that have been separately compiled and placed in an XL.
You can migrate source programs that are designed to be invoked by
using the SUB option of the CONVERT command. Using the SUB option
changes the invoked program directly into an HP Business BASIC/XL
subprogram.
2. The INVOKE statement accepts string expressions as arguments. The
INent accepts constant, non-quoted strings as arguments.
3. The INVOKE statement can start program execution at a specified
line. The CALL statement cannot. You can, however, duplicate
this function by making the line number a parameter to the called
subunit, then using that parameter in a SELECT structure whose
CASEs are GOTO statements to the appropriate lines.
The three migration methods explained here work in both interpreted and
compiled programs:
* Change the invoked program to a SUB, then CALL it instead of invoking
it. Use the SUB option of the CONVERT command to change the invoked
program to a SUB.
You can either merge the SUB into the calling program, or you can
compile the SUB separately and put it in an XL. If you compile the
SUB separately and put it in an XL, include an EXTERNAL declaration
in the calling program.
* Compile the invoked program with GLOBAL OPTION SUB, NONEWCOM. This
lets you CALL the MAIN subunit of this program. The name of the MAIN
consists of the source file name followed by two single quotes; if
the source file name for the invoked program is INVNT3, then the MAIN
of that program is called INVNT3" when it is compiled.
The invoking program needs an EXTERNAL declaration. Use an ALIAS
clause because single quotes are not valid in HP Business BASIC/XL
identifiers.
* Compile the invoked program as a separate program file. You can
execute this separate program file from the invoking program by using
the SYSTEMRUN statement. The two programs cannot share common
variables, but you can use files to pass data between them. You can
also use the INFO parameter of the SYSTEMRUN command to send data
from the first program to the second program.
Type HELP CHAIN for more details and some alternatives for migration.
For information about migrating interpreted INVOKE statements, see
"Replacing Removed Features" in this chapter.
KSAM/V Intrinsic Calls
There is a special set of KSAM Intrinsics (the routines beginning with
"BK") that are only accessible from BASIC/V programs. HP Business
BASIC/XL provides a set of routines you can call instead of these
intrinsics. The migration aid automatically translates KSAM calls into
the correct format.
The migration aid changes KSAM intrinsic calls into corresponding HP
Business BASIC/XL routine calls.
BASIC/V:
1200 CALL BKREAD (F, S$, A1, B1, C$)
HP Business BASIC/XL:
1200 _BBKREAD F, S$, A1, B1, C$
The same format applies to all twelve of the BASIC/V KSAM routines.
After migration, the statements run in both the HP Business BASIC/XL
interpreter and in compiled programs. With two exceptions, you do not
need to make any manual changes:
1. Always include the status parameter in "_BBK" statements.
2. Always declare this parameter as a string variable that is at
least four characters long.
NOTE KSAM routines cannot successfully execute if you either do not
include the status parameter or do not declare the status parameter
as a string variable that is at least four characters long. You
will not be notified of a failure because this information only
passes through the status variable.
Multiline Functions
BASIC/V multiline functions can access all the data defined explicitly or
implicitly in the MAIN program. HP Business BASIC/XL multline functions
are separate procedures; global data is only accessible if you pass it as
a parameter or in common. The migration aid identifies all non-local
variables accessed by each multiline function and lists these variables
in a comment at the end of the appropriate function.
There are three ways to make these variables work:
* Pass the variables as parameters to the multiline functions.
* Place the variables in common.
* Declare the variables in the functions. This only works if the
variables don't need to be shared between main and the functions (for
example, a loop or a temporary file.)
PRINT USING Statement
Except for elements used specifically for complex numbers, anything that
is legal in a BASIC/V format string is legal and has the same meaning in
HP Business BASIC/XL.
The elements not available in HP Business BASIC/XL are: "C", "+", "-",
and "I".
Format strings that contain these elements are easy to locate because
they are only used to print complex numbers. Complex numbers are flagged
by the migration aid.
Running the Interpreter and Compiler
The commands that invoke the HP Business BASIC/XL interpreter and
compiler are different from those that invoke the Business BASIC/V
interpreter and compiler. The commands are shown below:
Table 10-4. Running the Interpreter and Compiler
----------------------------------------------------------------------------------------------
| | | |
| Function | BASIC/V | HP Business BASIC/XL |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| Interpret | BASIC | BBXL |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| Compile | BASICOMP | BBXLCOMP |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| Compile and Link | BASICPREP | BBXLLK |
| | | |
----------------------------------------------------------------------------------------------
| | | |
| Compile, Link, and Run | BASICGO | BBXLGO |
| | | |
----------------------------------------------------------------------------------------------
The parameters for the HP Business BASIC/XL commands follow:
BBXL [commandfile] [,textfile] [,listfile] [,libfile] [;INFO = "info"]
BBXLCOMP [textfile] [,object file] [,listfile] [;INFO = "info"]
BBXLLK [textfile] [,progfile] [,listfile] [;INFO = "info"]
BBXLGO [textfile] [,listfile] [,libfile] [;INFO = "info"]
On MPE XL machines, multiple compiles to the same relocatable object file
overwrite the file each time; change your command files accordingly so
they write to a different file for each compile. Refer to the HP Link
Editor/XL Reference Manual for information about linking object modules.
Remember to examine all your user-defined commands (UDCs) or command
files and make changes to the appropriate compiling and linking commands.
Subunit Size
In Business BASIC/XL, the limit is about 2000 lines. This is an estimate
of subunit size. The actual number of lines allowed depends on the
complexity of your program.
SYSTEM
SYSTEM statements and ":" commands allow execution of UDCs and command
files from HP Business BASIC/XL. The SYSTEM statement on an MPE XL
machine executes the contents of the SYSTEM string as if you input the
command directly. When a warning occurs, the JCW CIERROR changes to
reflect the new error. In the same situation on MPE V, JCW CIERROR does
not change to reflect the new error.
The following is a BASIC/V program that demonstrates the SYSTEM
statement:
10 SYSTEM S,"SETJCW CIERROR = 0" !reset CIERROR to 0
20 SYSTEM S,"PURGE notthere" !purge a file that does not exist
30 SYSTEM S,"SHOWJCW CIERROR" !show value of CIERROR
The BASIC/V result is shown below:
_____________________________________________________________________
| |
| |
| WARNING FILE NOT FOUND, NO PURGE DONE. (CIWARN 383) |
| CIERROR = 0 |
| |
_____________________________________________________________________
The similar HP Business BASIC/XL program follows:
10 SYSTEM "SETJCW CIERROR = 0" !reset CIERROR to 0
20 SYSTEM "PURGE notthere" !purge a file that does not exist
30 SYSTEM "SHOWJCW CIERROR" !show value of CIERROR
The HP Business BASIC/XL result is shown below:
_______________________________________________________________________
| |
| |
| WARNING FILE NOT FOUND, NO PURGE DONE. (CIWARN 383) |
| CIERROR = 383 |
| |
_______________________________________________________________________
MPE/iX 5.0 Documentation