HP 3000 Manuals

Input and Output Operations [ HP Business BASIC/XL Migration Guide ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Migration Guide

Input and Output Operations 

File Input and Output 

Most aspects of file input and output are similar in HP Business BASIC/XL
and BASIC/260 even though the HP 3000 offers more file types than the HP
260.  HP Business BASIC/XL tries to make the interface to each file type
transparent.  However, the different file types behave differently during
read and write operations.  If you are new to the HP 3000, familiarize
yourself with the specifics.

Deleted Statements.  There are a some statements that HP Business
BASIC/XL does not support.  Generally, these statements have no meaning
on the MPE XL based HP 3000.

     AVAIL
     BUFFER#
     CATLINE and CATFILE
     CHECKREAD ON/OFF
     DIRECT/INDIRECT/NOUPDATE
     DOOR LOCK/UNLOCK
     DUPTEST
     HOLE
     PRINT LABEL
     READ LABEL

The following statements are used for reading and writing IBM diskette
media on the HP 260.  They are not available in HP Business BASIC/XL. The
utility DISCCOPY/3000 is available for moving IBM floppies to the HP
3000.

     ASSIGN;EBCDIC
     ASSIGN;EBCDIK
     CREATE;CHAR
     DELETE #
     DUPLICATE
     IBMDUMP
     IBMWREC
     LINPUT #  (still works for normal files)

File Names.  In many ways, the HP 3000 file system restricts file names
relative to the HP 260.  You might need to manually change file names.
Here are three main differences:

 *  MPE does not distinguish between upper case and lower case in file
    names.  To reduce the number of code changes, do not use a naming
    convention that depends on file names that are identical except for
    casing.

 *  Special characters are not allowed in file names.  HP 3000 names must
    begin with a letter.  The letter can be followed by letters or
    digits.  Temporary files on the HP 260 often start with "$" or "%" so
    they are easy to find and purge.  Because you can not use these
    characters in HP Business BASIC/XL file names, use another file
    naming convention for temporary names.

 *  HP 3000 file names can be eight characters long, instead of six.  If
    a program reserves only six characters for file names, string
    overflows might occur after migration.

    For example, the USRID (HP 260 TASKID) function can return three
    digit numbers.  This function is often used to form a suffix for file
    names so names are unique.  However, if a program uses four
    characters plus the USRID value, a seven character string could
    result.  Although the MPE file system accepts this, the program might
    get a string overflow.

    The best solution is to provide for eight character file names on the
    HP 260.  This means that, after meeting the other conditions above,
    you will not need to make other changes to file names.

Volume Identifiers.  On the HP 260, it is important to distribute the
file load evenly across available disk drives.  Some techniques for doing
this have been developed, including adding a volume name to the filename.
This, allows separate disks for databases, work files, and spool files.
The volume identifier can be up to seven characters long, plus the comma
that identifies it as a volume name.

The HP 3000 does not support volume names.  The file system automatically
distributes the file load across available disks.  However, it can be
advantageous to continue your disk strategy, logically distributing the
files on the HP 3000.  You can do this by changing volume identifiers to
HP 3000 group names.

Changing volume names to group names requires some manual effort.  Group
names can be eight characters long (just like file names).  However, they
are separated from the file name by a period instead of a comma.

Use nine characters for volume names instead of eight.  If you use nine
characters, you only need to change the comma.

MSI Statement.  The HP 260 MSI statement is changed automatically to a
FILES ARE IN statement.  Check each FILES ARE IN statement after
migration to make sure it is correct.

Using the MSI statement instead of volume names reduces the migration
effort because fewer MSI statements are necessary.  However, many
applications might not be able to use this feature because of file
distribution.

HP 3000 Accounts.  In addition to multiple groups, the HP 3000 supports
multiple accounts.  To use account names to qualify volumes, leave an
additional 9 characters of space.  Account names follow the same naming
rules as files and are separated from the group by a period.

Migration is harder when HP 260 programs do not allow room for account
names.  The error risk is high.

In addition, file access with multiple accounts is limited by the HP 3000
file system.  Investigate this before using more than one account for an
application.  Use both a file name and an account name when you access
files.  Otherwise, you might access a file that has the same name but is
in the wrong account.

BASIC DATA Files.  The HP Business BASIC/XL BASIC DATA is the equivalent
to a normal HP 260 data file.  This file type includes type markers and
data, its structure is similar to both HP 260 and BASIC/V data files.
The differences in this file type are noted below.

Storage Requirements.  The HP Business BASIC/XL BASIC DATA file has a
type marker for every data item.  BASIC/260 does not include type markers
for the SHORT type.  Table 17-7 compares byte lengths required by items
in data files:

          Table 17-7.  Comparison of Byte Lengths of Items in Data Files 

----------------------------------------------------------------------------------------------
|                              |                              |                              |
|             Type             |       BASIC DATA File        |            HP 260            |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| SHORT INTEGER                | 4                            | 4                            |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| INTEGER                      | 6                            | Not applicable.              |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| SHORT DECIMAL                | 6                            | 4                            |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| DECIMAL                      | 10                           | 10                           |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| SHORT REAL                   | 6                            | Not applicable.              |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| REAL                         | 10                           | Not applicable.              |
|                              |                              |                              |
----------------------------------------------------------------------------------------------
|                              |                              |                              |
| String (length X)            | X+4                          | X+4                          |
|                              |                              |                              |
----------------------------------------------------------------------------------------------

Direct Word Access.  The different sizes required in BDATA files means
direct word access into the file might not work correctly.  The migration
program cannot translate this automatically, so you need to manually
change these.

For increased compatibility, avoid direct word access.  Use direct record
access instead.  Skip any data before the data you want.  For example, if
a file contains a string followed by 2 numbers, you might normally use
the following:

     READ #1,1,Wordnum;Var

Use the statement below instead:

     READ #1,1;Dummy$, Dummy, Var

This statement works even if string length and variable type change.

PRINT #1;END.  BASIC/260 allows the following program:

     FOR I=1 TO 10
        PRINT #1;I;END
     NEXT I

This program results in a file containing the values 1 to 10, followed by
an end-of-file marker; EOF marks are overwritten each time a write is
done.

HP Business BASIC/XL BDATA files are written differently.  The program
above results in the expected 10 values, but an EOF mark follows each
value; the program must use direct record reads to avoid an end of file
condition.

The following program is compatible with HP Business BASIC/XL, and is
clearer and faster:

     FOR I=1 TO 10
        PRINT #1;I
     NEXT I
     PRINT #1;END

Errors and Status.  Error codes and status numbers returned by HP
Business BASIC/XL do not always match those in BASIC/260.  Although most
BASIC/260 error numbers are mapped automatically, the STATUS code used in
ASSIGN (and other input/output statements) is usually different.

The easiest solution is to use variables as constants for expected status
values.  The example below illustrates:

                   BASIC/260         Business BASIC
     Filenotfound=    1                    52

The status code returned by ASSIGN and other file statements is usually
(but not always) the MPE file system error number.  A non-zero value is
always returned if the statement fails.

In BASIC/260, when a BASIC DATA file is created with 20 records, each
record in that file containes an EOF marker.  Therefore, if you write to
record 9 and try to read record 5, you will get an EOF error.

On MPE XL, when a BASIC DATA file is created with 20 records, each record
in the file contains an EOR marker.  If you write to record 9 and try to
read record 5, no error is generated.  HP Business BASIC/XL skips EOR
markers to find the next available data which, in this case, is in record
9.

SIZE Function.  The HP Business BASIC/XL SIZE function does not accept
negative values as parameters.  In BASIC/260, SIZE(-1) returns the
logical record length of a workfile.  Dividing this value by 2 results in
the THREAD length for the workfile.

HP Business BASIC/XL does not support logical thread length in a
workfile.  There is only a physical record length.  Since the THREAD
statement is now a static statement, the length is easy to see in the
program.

To increase compatibility, use a variable to remember thread length.
Avoid using the SIZE(-1) function.

Screen Input and Output 

HP 3000 screen input and output are similar to HP 260 screen input and
output.  Most differences are caused by the different hardware and
operating systems of the two machines.  Do not expect an HP 3000 to
exactly duplicate HP 260 behavior.

EDIT.  The EDIT statement is not supported by HP Business BASIC/XL. Use
one of the other input statements instead.

LINPUT.  The BASIC/260 LINPUT statement returns everything on the current
line, including any prompt produced by the LINPUT statement.  The HP
Business BASIC/XL LINPUT statement only returns the characters typed in
response to the LINPUT statement; it does not return the prompt and other
data on the line.

The program segment and table comparing BASIC/260 results to HP Business
BASIC/XL results illustrates:

     DIM A$[80]
     LINPUT "Hello ";A$
     DISP A$

     RUN
     Hello ABC

          Table 17-8.  LINPUT Comparison 

---------------------------------------------------------------------------------------------
|                                             |                                             |
|              BASIC/260 Result               |         HP Business BASIC/XL Result         |
|                                             |                                             |
---------------------------------------------------------------------------------------------
|                                             |                                             |
| Hello ABC                                   | ABC                                         |
|                                             |                                             |
---------------------------------------------------------------------------------------------

There are many ways to increase program compatibility in the example
above.  For instance, always put the prompt on a separate line from the
response; A$ will only return the characters typed.

If the program needs the prompt, use the LENTER statement instead.  This
provides the same result in both HP Business BASIC/XL and BASIC/260:

     DIM A$[80]
     LINPUT "Hello ";    ! Read into nothing.
     DISP Up_one_line$;  ! Moves up a line on the screen
     LENTER A$

The value of Up_one_line$ differs between the HP 260 and the HP 3000, but
this is easier to document and change this in one place than it is to
change every LINPUT statement.

Input and Softkeys.  HP Business BASIC/XL softkey interaction with input
statements differs significantly from BASIC/260.  Consider the following
HP 260 program:

     ON KEY #8: "PRESS HERE" GOSUB Softkey
     LOOP
        A$=B$=""
        INPUT A$,B$
        DISP A$,B$
     END LOOP
     STOP
     Softkey: RETURN

HP 260 softkeys are true interrupts.  The INPUT sequence can be
interrupted in any situation and returns to the exact point from which it
came.  A softkey does not terminate input, nor does it affect the
characters typed for the input.

However, HP 3000 softkeys terminate input; any characters typed or
variable entered are lost.

For example, each machine will react differently if you type "ABC,BC" in
response to the INPUT statement above, then press softkey 8.  In
BASIC/260, the GOSUB completes and returns, then the INPUT of B$
continues.  If you type "D" and a return after this, B$ will have the
value "BCD".

In HP Business BASIC/XL, the softkey terminates the entire INPUT
statement.  The value "ABC" is assigned to A$, but B$ stays the same.
The "BC" you enter is ignored.  In addition, execution resumes at the
following DISP statement.

Program segments like this are usually coded as follows in HP Business
BASIC/XL (the migration aid helps with this):

     ON KEY 8 GOSUB Softkey;LABEL="PRESS HERE"
     LOOP
        A$,B$=""
        LOOP
           INPUT A$,B$
           EXIT IF RESPONSE > 1   ! Key not hit.
        END LOOP
        DISP A$,B$
     END LOOP
     STOP
     Softkey: RETURN

This program segment does not duplicate BASIC/260 behavior exactly.  The
main difference is that this program requires you to re-enter all the
input instead of continuing to type.


NOTE The interaction of input and softkeys applies to all input statements (like INPUT, LINPUT, ACCEPT, TINPUT) on the terminal. This is true even when a JOINFORM is active; this can affect the forms user interface.
CURSOR. The CURSOR statement is different in HP Business BASIC/XL. Unavailable Options. The CURSOR statement no longer supports the following options: IF OF RIF ROF PL UL PALL UPALL (IF and OF are different from IF# and OF#) PALL and UPALL. Instead of using the PALL and UPALL options, use the memory lock feature of HP 3000 terminals to simulate PALL and UPALL options. The program segment below illustrates: SUB Pall(SHORT INTEGER Line) CURSOR(Line+1) DISP '27"l"; ! Turn on memory lock SUBEND SUB Upall(SHORT INTEGER Line) DISP '27"m"; ! Turn off memory lock SUBEND Enhancements. The CURSOR statement defines screen enhancements like blinking and inverse video characters. However, HP 3000 terminals do not work the same as HP 260 terminals and the migration aid can not correctly translate every CURSOR statement. The following CURSOR statement demonstrates this problem: Half=40 CURSOR (10,10),IV(Half),HB(Half) CURSOR (10,10),IV(Half),HB(Half) On the HP 260, this statement moves to position 10-10 then displays 40 characters in half-bright, inverse video. These lines are changed as follows: Half=40 CURSOR (10,10),("I",Half),("H",Half) On an HP 3000 terminal, this statement moves to 10-10, uses inverse video for 40 characters, then uses half-bright video for the same forty characters; the half-bright is not added to the inverse video, but overrides the enhancement. This results in 40 half-bright characters. You need to manually change this type of CURSOR statement. The resulting statement might look like this: Half=40 CURSOR (10,10),("IH",Half) This CURSOR statement uses inverse and half-bright video enhancements at the same time. RPOS and CPOS. The RPOS and CPOS functions (YPOS and XPOS in BASIC/260) work the same. However, because of the difference in softkey interaction, some programs produce incorrect results. Imagine a text processor that sets line length by positioning the cursor then pressing a softkey: Line=Defaultlen ON KEY#1: "LINELEN :"&VAL$(Line) GOSUB Set_line_length LOOP LINPUT "";Line$ ENDLOOP Set_line_length: Line=XPOS ON KEY#1:"LINELEN :"&VAL$(Line) GOSUB Set_line_length RETURN This program waits for softkey 1 to determine the line length. This works on the HP 260 because softkeys interrupt the LINPUT statement. But HP Business BASIC/XL terminates the LINPUT statement. In addition, pressing the softkey causes the cursor to move to the beginning of the next line; CPOS always returns "1". By using TINPUT with the NOLF option, you can force RPOS to return the correct line; CPOS still returns "1". The only solution is to use the ACCEPT statement. In this case, both CPOS and RPOS return the proper position. Replace the LOOP above with the following program segment: LOOP DISP '27"&k1M"; ! turn MODIFY mode on ACCEPT Line$ DISP '27"&k0M"; ! turn MODIFY mode off ENDLOOP
NOTE When using the ACCEPT statement, MODIFY mode displays typed characters on the terminal. If this terminal mode is not on, the characters do not display; turn off MODIFY mode in each possible branch out of the loop.
Printer Output Printer specifications are different in BASIC/260 and HP Business BASIC/XL. The migration aid automatically changes the syntax of the PRINTER IS statement; however, the device numbers used on the HP 260 are usually nonsense on the HP 3000. Device Specifications. The SEND OUTPUT TO statement does not accept device numbers. Use keywords and string expressions instead. Certain device numbers have a particular meaning; these are changed as shown in Table 17-9: Table 17-9. Device Specification Keywords --------------------------------------------------------------------------------------------- | | | | BASIC/260 Device Number | HP Business BASIC/XL Keyword | | | | --------------------------------------------------------------------------------------------- | | | | 0,1 | PRINTER | | | | --------------------------------------------------------------------------------------------- | | | | 8 | DISPLAY | | | | --------------------------------------------------------------------------------------------- | | | | 9 | NULL | | | | --------------------------------------------------------------------------------------------- If you use another number, or use a variable in the PRINTER IS (or PRINT ALL) statement, HP Business BASIC/XL will not syntax the device number. You must replace the device numbers with correct HP 3000 references before the program runs. In addition to the keywords, HP Business BASIC/XL accepts certain names for these keywords in strings; you can manually change the following syntax: Table 17-10. Comparison of Device Specification Syntax --------------------------------------------------------------------------------------------- | | | | BASIC/260 | HP Business BASIC/XL | | | | --------------------------------------------------------------------------------------------- | | | | PRINTER IS N | SEND OUTPUT TO N$ | | N | N$ | | 0,1 | .PRINTER. | | 8 | .DISPLAY. | | 9 | .NULL. | | | | --------------------------------------------------------------------------------------------- This lets a program request a device name; if a device is not supplied, a default name can still be used for any of the above. A statement like the following will still work if you use the strings above. SEND OUTPUT TO N$
NOTE Since HP 3000 names are not case sensitive, strings like ".printer." can be either upper or lower case.
Special Characters and Escape Sequences. HP Business BASIC/XL counts each character sent to a printer as output. This is also true of escape sequences used to print graphics and special characters. BASIC/260 often recognizes a set of characters as using no space on paper, and does not count them. For instance, sequences used to change character sets. In a normal printer configuration, the printer width is 132 characters. When the 132 characters is filled, an automatic CR-LF is inserted. This produces unexpected results when you are printing special characters and escape sequences. Reconfigure the printer to a larger width. Between 300 and 400 characters usually allows enough space for extra escape sequences. Some HP 260 display control characters can not be displayed. These control characters are changed to escape sequences.


MPE/iX 5.0 Documentation