HP 3000 Manuals

Arrays and Strings [ HP Business BASIC/XL Migration Guide ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Migration Guide

Arrays and Strings 

The migration aid automatically makes the changes described below:

When entering DIM statements and array element accesses in BASIC/V,
square brackets and parentheses are interchangeable; both always list as
square brackets.  In HP Business BASIC/XL, there is a definite syntactic
difference between the two:  parentheses indicate array references and
square brackets indicate substring designators.

DIMension Statement 

          Table 13-7.  DIM Statements 

---------------------------------------------------------------------------------------------
|                                             |                                             |
|                   BASIC/V                   |            HP Business BASIC/XL             |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DIM A[5]                                    | DIM A(5)                                    |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DIM B[5,8]                                  | DIM B(5,8)                                  |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DIM S$[5]                                   | DIM S$[5]                                   |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DIM Z1$[5,10]                               | DIM Z1$(5)[10]                              |
|                                             |                                             |
---------------------------------------------------------------------------------------------

String and Array Boundary 

The maximum string and array sizes are larger in HP Business BASIC/XL.
Use the following rule to calculate the maximum number of elements in an
array.

     maximum elements = (8190000 DIV No_of_bytes1 )

Notes 

1 No_of_bytes is the total number of bytes you need to store the data
type.

          Table 13-8.  Total Number of Bytes Needed to Store Data Types 

---------------------------------------------------------------------------------------------
|                                             |                                             |
|                  Data Type                  |                 No_of_bytes                 |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| STRING                                      | 1                                           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| SHORT INTEGER                               | 2                                           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| INTEGER                                     | 4                                           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| SHORT REAL                                  | 4                                           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| REAL                                        | 8                                           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| SHORT DECIMAL                               | 4                                           |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DECIMAL                                     | 8                                           |
|                                             |                                             |
---------------------------------------------------------------------------------------------

The maximum string length in HP Business BASIC/XL is 32760.

Substrings 

If A$ is a simple string with 12 characters, the DIM statement and the
access of substrings is the same in both languages:

          Table 13-9.  Simple Strings and the DIM Statement 

---------------------------------------------------------------------------------------------
|                                             |                                             |
|                   BASIC/V                   |            HP Business BASIC/XL             |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DIM A$[12]                                  | same                                        |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| C$ = A$[5]                                  | same                                        |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| D$ = A$[2,6]                                | same                                        |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| E$ = A$[3;2]                                | same                                        |
|                                             |                                             |
---------------------------------------------------------------------------------------------

If B$ is a string array of 5 elements, each having 12 characters, the
differences are as follows:

          Table 13-10.  String Arrays and DIM Statements 

---------------------------------------------------------------------------------------------
|                                             |                                             |
|                   BASIC/V                   |            HP Business BASIC/XL             |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| DIM B$[5,12]                                | DIM B$(5)[12]                               |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| C$ = B$[2,6]                                | C$ = B$(2)[6]                               |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| D$ = B$[2,6,12]                             | D$ = B$(2)[6,12]                            |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| E$ = B$[2,5;2]                              | E$ = B$(2)[5;2]                             |
|                                             |                                             |
---------------------------------------------------------------------------------------------



MPE/iX 5.0 Documentation