HP BASIC for OpenVMS

From Wikipedia, the free encyclopedia

This article is about the BASIC dialect created at DEC, but now transferred to HP. For the dialect created at HP but now transferred to Agilent, see Rocky Mountain BASIC.

HP BASIC for OpenVMS is the latest name for a dialect of the BASIC programming language created by Digital Equipment Corporation and now owned by Hewlett-Packard. It has been implemented on a variety of DEC-derived platforms, including the PDP-11, VAX/VMS, OpenVMS on Alpha and now OpenVMS on Itanium.

Contents

[edit] Notable features

HP BASIC has many FORTRAN-like extensions, including matrix operators.

line numbers are optional, unless the "ERL" function is present. It allows you to write "WHEN ERROR" error handlers around protected statements. The more traditional but less elegant "ON ERROR" statement lacks such context or scope.

One of HP BASIC's more unique features is built-in support for OpenVMS's powerful Record Management Services (RMS). Before VAX BASIC (as it was then called), you would only get native RMS support in DEC's COBOL compiler.

[edit] History

HP BASIC for OpenVMS has gone through many name changes. It began at DEC, which was bought by Compaq, who then merged with HP. Since the company name is embedded in the product name, each new owner changed the product name. It has also been ported to a succession of new platforms as they were developed by DEC/Compaq/HP, over a period of more than 30 years.

[edit] BASIC-PLUS

Main article: BASIC-PLUS

HP BASIC began as BASIC-PLUS, created by DEC for their RSTS/E operating system and PDP-11 minicomputer. Users would sit at a terminal and type in programming language statements. The statements could either be entered into the command interpreter directly, or entered into a text editor, saved to a file, and then loaded into the command interpreter from the file. Errors in source code were reported to the user immediately after the line was entered.

A program could be stored on the system in an editable .BAS source file, using the "SAVE" command. It could also be "compiled" into a non-editable binary .BAC file, using the "COMPILE" command. This command did not produce true machine language programs. The output was a byte code called "tokens". The tokens were interpreted upon execution, in a manner similar to the more modern Java.

Programs were entered into the command interpreter starting with line numbers, integers from 1 to 32767. Lines could be continued onto multiple lines by using a line feed instead of the RETURN (ENTER) key. For ease of external editing of the source file, later versions of BASIC-PLUS also allowed the & character as a line-continuation character. Multiple statements could be placed on a single line using \ as the statement separator.

Virtual memory on the PDP-11 was limited to about 64 KB. With BASIC-PLUS, about half of this was used by the combined command interpreter and run-time library. This limited user programs to about 32 KB of memory. Large programs could be broken up into various pieces by use of the "CHAIN" instruction. Programs could chain to specific line numbers in a secondary program . The use of a shared memory section called core common also allowed programs to pass data among each other as needed; disk files could also be used but were slower.

The interpreter included a garbage collecting memory manager, used for both string data and byte-code. A running program could be interrupted, have variables examined and modified, and then be resumed. Many of the control structures used in other high-level languages existed in BASIC-PLUS, including WHILE and UNTIL. The language also supported the use of conditional modifiers on a single line. For example, the line "PRINT I UNLESS I < 10" would print the value of "I" unless I was less than 10.

[edit] BASIC Plus 2

Basic Plus 2 (BP2 or BASIC-Plus-2) was later developed by DEC to add additional features and increase performance. It used true compilation into threaded code, and wrote its output to machine language object files. These were compatible with other object files on the system, and could be assembled into libraries. A linker (the TKB taskbuilder) then created executable files from them. TKB also supported overlays; this allowed individual routines to be swapped into the main memory space as needed.

BP2 programs ran under the RSX Run Time System. This RTS only occupied 8KB of the user's address space, leaving 56KB for the user's program. These two factors allowed individual BP2 programs to be much larger than BASIC-PLUS programs, often eliminating the need for CHAINing. Unlike BASIC-PLUS (which was only available on RSTS/E), BP2 was also available for the RSX-11 operating system.

[edit] VAX BASIC and DEC BASIC

With the creation of the VAX minicomputer, DEC ported BASIC-PLUS-2 to the new VMS operating system, and called it VAX BASIC. VAX BASIC used the standard VMS calling standards, so object code produced by VAX BASIC could be linked with object code produced by any of the other VMS languages. Source code for BASIC Plus 2 would usually run without major changes on VAX BASIC.

When DEC created their Alpha microprocessor, VMS was ported to it and renamed OpenVMS. VAX BASIC was likewise ported to Alpha and renamed DEC BASIC. The BASIC interpreter was permanently dropped at this point, which meant that DEC BASIC programs could only be run as OpenVMS executables, produced by a compile followed by a link.

[edit] Compaq and HP

When DEC was purchased by Compaq in 1997/98, the products were renamed Compaq BASIC for OpenVMS VAX and Compaq BASIC for OpenVMS Alpha.

Likewise, when Compaq merged with HP in 2001/02, the products were renamed HP BASIC for OpenVMS VAX and HP BASIC for OpenVMS Alpha. HP has build new server platforms based upon Intel's Itanium chip, and there is now a HP BASIC for OpenVMS Itanium as well.

[edit] Sample code

[edit] Hello, world

10 PRINT "Hello, world!"

[edit] Celsius to Fahrenheit conversion

10 PRINT "Enter a temperature in degrees Celsius"
20 INPUT C
30 PRINT "Temperature in degrees Fahrenheit is "; (C * 1.8) + 32
40 END

[edit] External links