Digital Equipment Corporation

DIGITAL BASIC Translator

The DIGITAL BASIC Translator automatically translates VAX BASIC and DEC BASIC code to the popular Visual Basic language. Thus it gives established VAX and DEC BASIC applications a migration path to Windows NT®, Windows® 95 and a distributed environment. Used with the highly successful family of Visual Basic products, it also offers these applications a link to the future.

Phil Hudson and Peter Haynes

(with input from the entire VAX and DEC BASIC engineering team)

ACE Group, Digital Equipment Corporation

May, 1998

Disclaimer:

Digital Equipment Corporation makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description. Views expressed in this paper are those of the author, not of the publisher.

4

EXECUTIVE SUMMARY

With an estimated 3 million users, Visual Basic has become the most successful and widely used PC-based development environment ever. Because of this success, the VAX and DEC BASIC group has incorporated Visual Basic (VB) into their migration to Windows* strategy for its customer base. This strategy includes a VAX BASIC or DEC BASIC to Visual Basic source code translator, accompanying support routines, and migration documentation. The following list gives an overview of each component:

·  DIGITAL BASIC Translator

Hosted on OpenVMS VAX and Alpha, the Translator will read in VAX or DEC BASIC source code and output Visual Basic source code. For the statements and constructs that do not translate cleanly, the Translator will generate calls to corresponding DECBAS_* support routines. Created with the translated code are Classes for RECORDS, MAPS, and COMMONS, Support Library routines and a Visual Basic Project file for easy inclusion into the Visual Basic Environment.

·  Support routines library

These support routines are written in Visual Basic and are shipped and installed with the Translator. They serve as a bridge in some instances when there is no corresponding language feature in Visual Basic or when a feature between the two languages is too disparate. The DECBAS_prefix naming convention quickly identifies each as one of the previously written support routines.

The Translator generates calls to these routines as necessary.

·  Migration Documentation

The DIGITAL BASIC Translator User Manual provided with the Translator is divided into two parts. The first part provides conceptual, general user information on topics such as elements of the Translator and its general use. This first part also provides information on I/O, data types, and error handling.

The second part is an alphabetized, reference guide to the translation of each VAX or DEC BASIC statement and function. This part provides specific migration information and discusses migration issues (if any).

Together these components deliver a comprehensive migration path for VAX and DEC BASIC customers wanting to move to a Windows and/or distributed environment.

The following sections of this document will discuss in more detail the overall migration strategy and the Translator components.

* The use of Windows® throughout this document refers to both Windows NT® and Windows® 95.MIGRATION OVERVIEW

The Translator is only one step in the process of migrating a VAX or DEC BASIC application to the Windows NT platform, a process that will differ depending on the specifics of your VAX or DEC BASIC application. The following are some example migration scenarios in which you may want to use the Translator:

·  Migrating an application, as a whole, over to the Windows NT platform.

·  Partitioning an existing application into a client/server (C/S) application, migrating only the presentation management (client) piece to the Windows NT platform.

·  Packaging your existing application as a business component (server) that will be used within a distributed environment application.

Although each scenario has its own variations on the migration process, the general process is the same. This general migration process is depicted and described below.

· Figure 1: General Migration Process Using the DIGITAL Translator

Figure 1: General Migration Process Using the DIGITAL Translator depicts the overall VAX or DEC BASIC to Windows (Visual Basic) migration strategy and the role the Translator plays within it. The steps in the migration process can be summarized as follows:

1.  Identify and isolate the VAX BASIC or DEC BASIC source files that you intend to migrate to Windows NT.

Before the VAX BASIC or DEC BASIC source files can be run through the Translator, they must be brought together into a single location. This step includes identifying which modules and routines you want to translate, then combining them into a single file, or couple of files, for translation. Depending on your scenario (as mentioned above), this process may be as simple as taking your source files as they are, to fully partitioning your existing application for C/S.

2.   Run the VAX BASIC or DEC BASIC source code through the Translator.

Depending on how much you wish to maximize the use of the Translator, its use can be an iterative process of smaller sub-steps. These sub-steps can include:

·  Running the code through the Translator

·  Reviewing all Translator messages

·  Manipulating the VAX BASIC or DEC BASIC code to achieve a higher translation rate

·  Retranslating

3.   Bring the generated project into the Visual Basic Integrated Development Environment (IDE) for further editing and debugging.

From this point on, you are doing development in the Visual Basic environment. As part of this development process, you will cycle through the edit, run, and debug steps on Windows. In going through this cycle, you will fix identified problems left unresolved during the translation steps. You will find the Translator documentation most helpful for this purpose.

4.   Deploy the generated Visual Basic Application.

Depending on your specific application model, deployment of the application may vary.

For single tier, non-C/S based applications, it may mean just packaging it with a simple setup utility.

As you can see however, the DIGITAL BASIC Translator itself is only one step in the entire migration process. It is our goal to make it the easiest phase in your migration effort.

The rest of this document is spent discussing the Translator in more detail.

TRANSLATOR FEATURES

Because of language differences between BASIC and Visual Basic, the Translator cannot achieve complete VAX and DEC BASIC language translation, so the migration process is not a one time, one way, procedure. (Once you have started modifying the generated Visual Basic code, it is expected that you won’t go back to the original VAX or DEC BASIC code.) The differences are fully documented in a helpful User Manual.

The goals for the Translator are stated in priority order, as follows:

1.  The Translator does not generate an application whose behavior differs from the original application without appropriately flagging the differences.

This rule is straightforward. If we say something translated, the translation will give results comparable to the original.

2.  The generated code and project is easily readable & maintainable.

Although the Translator will not generate VB code more readable than the original VAX or DEC BASIC code, it maintains the code’s readability in the following ways:

·  The original code structure is maintained in the generated Visual Basic code.

This means that when you go into the generated Visual Basic code to look for a piece of code, you will find it where you expect to. It also means that we preserve comments and whitespace where possible.

3.  The Translator translates as much of the developer’s VAX BASIC or DEC BASIC source code into corresponding Visual Basic source as possible.

A direct translation of VAX BASIC or DEC BASIC code into Visual Basic code is optimal since direct translation produces the most readable, and best performing, Visual Basic code. The Translator translates as much as possible of the DEC and VAX BASIC language. The Translator calls the DECBAS_* support routines only when a corresponding Visual Basic language feature does not exist or when the differences between the two languages are too great.

4.  The Translator uses prepackaged support routines as needed to achieve a higher translation rate.

Calls to the support routines add complexity to the translation but allow us to achieve higher translation rates. As a result most of the VAX BASIC and DEC BASIC language can be translated.

5.  We document all VAX and DEC BASIC language components that do not translate or that translate in a way that results in differing behavior.

Some parts of the DEC and VAX BASIC language cannot be translated cleanly (even with the help of the support routines). A detailed user Manual is provided to assist where the Translator does not and cannot translate cleanly from VAX or DEC BASIC to Visual Basic. It discusses issues specific to individual statements and functions and also provides additional material on topics such as code changes to ease migration.

TRANSLATOR DETAILS

OVERVIEW

The OpenVMS-based DIGITAL BASIC Translator reads in VAX or DEC BASIC source code and outputs Visual Basic code for the Windows platforms. It knows about the entire VAX and DEC BASIC languages because it shares common sources with their compilers. This sharing of the lexical analyzer and parser means that there is no misinterpretation of the language during the translation. The differences are in the back-ends of the products. The DEC BASIC compiler shares its code generator (GEM) with the other OpenVMS Alpha languages. On the other hand, the Translator uses a newly-written Visual Basic source code generator. This new code generator translates the VAX BASIC and DEC BASIC code, incorporates pre-written support files as needed, and generates a Visual Basic Project file, as shown by the following illustration:

· Figure 2: DEC BASIC to Visual Basic Source Code Translator

The Translator works in concert with a number of other support files. It takes all of these files working together to generate a completed Visual Basic Project. The following table describes the individual files and components that make up a complete VAX or DEC BASIC to Visual Basic translation.

Components and Generated Files of a DEC or VAX BASIC to Visual BASIC Translation

Component / Generated Files / Description
DEC/VAX BASIC source code / This is the original DEC BASIC or VAX BASIC application source code that you wish to translate.
Translator / The source code translator.
DECBAS_* routines / These pre-written, Visual Basic source routines implement the parts of the DEC and VAX BASIC language that have no counterpart in Visual Basic. In most cases, they just encapsulate a Visual Basic feature that is close to, but not equal to, that found in DEC and VAX BASIC.
Record, MAP, and COMMON Classes / Visual Basic does not support MAPs and COMMONs. It also does not support Records to the same level that DEC and VAX BASIC does (Groups and Variants). VB Classes are heavily used in order to implement these features. Each Record, Group, Variant, MAP, and COMMON has its own class generated.
Support DLL / Due to limitations of the Visual Basic language, such as a lack of a pointer type, a support DLL is shipped with translated applications. This .DLL also contains a number of other support routines such as for I/O.
I/O Classes and Terminal Form / Because of the I/O limitations of Visual Basic and Windows NT, a DEC or VAX BASIC-like file I/O structure has been layered on top of VB using VB Classes. The Classes, DECBAS_TERMINAL*, DECBAS_FILESEQ, DECBAS_FILEREL, and DECBAS_REMOTE make up I/O for Terminals, Sequential files, Relative files, and ISAM, respectively.
* The Terminal class is implemented as a form.
Project file / A Visual Basic Project file (.VBP) will be output to unify the generated source code and Classes into a single project. This allows the developer to easily bring the translated application into the Visual Basic development environment.

Now that the translation process and the components that make up this process have been described, let’s take a closer look at what can (and cannot) be translated from DEC or VAX BASIC to Visual Basic.

TRANSLATABLES AND NONTRANSLATABLES

Between direct translation and the use of support routines we can successfully translate most of the DEC and VAX BASIC language. The following lists identify the code that can and can’t be translated.

In general, the types of DEC and VAX BASIC language components that can be directly translated include:

·  DEC and VAX BASIC language executable statements that do not concern I/O or exception-handling

·  ON ERROR Exception Handling

·  Arithmetic and trigonometric functions

·  Conditionals and looping constructs

·  Most data types

·  Most miscellaneous builtin functions

·  Lexical Directives

The following items do not translate directly. They require support routines or the use of VB classes for an indirect translation:

·  Terminal I/O and Formatted I/O

·  I/O file functions (including MOVE TO and MOVE FROM)

·  String arithmetic, edit, and formatting functions

·  Conversion functions (numeric to string, string to numeric, and numeric to numeric)

·  MAPs (including overlays), COMMONs, and RECORDs including GROUPS and VARIANTs

·  Miscellaneous statements such as READ, DATA, and RESTORE

·  MAT functions

·  Arithmetic comparison functions (COMP%, MIN, MAX)

The following list identifies items that translate with limitations or differences in behavior. With a knowledge of the application being translated, most of these items can be modified by the developer to work exactly as in DEC or VAX BASIC.

·  OPTION statement

·  ISAM File Access

·  WHEN Block exception handling

·  Use of floating point numbers; DEC and VAX BASIC (G-Float, D-Float) vs. Visual Basic (IEEE)

·  Some code formatting styles (i.e. comments within a line)

·  Integer Division (rounds instead of truncating)

·  Decimal data type to the extent supported in Visual Basic V5.0