Compaq BASIC Translator
User Manual


Previous Contents Index


DEF*

The VAX BASIC or DEC BASIC DEF* statement lets you define a single line or multiline function.

Translated Equivalent

Function


Remarks

Visual Basic does not have DEF* statements; they are translated to Visual Basic Function statements.

When translating programs containing DEF* statements, review the documentation for the DEF statement in the DEC BASIC and VAX BASIC for OpenVMS Systems Reference Manual. There are several pages of description regarding the subtle differences between FUNCTION statements and DEF* statements. Note that DEF* statements are declared within programs, subroutines, or functions. The resulting Visual Basic code needs to be manually rearranged to move the resulting nested Function declaration out of the enclosing routine.


Example

VAX BASIC or DEC BASIC Input


DEF* DOUBLE APLDIV (DOUBLE TT, BB) 
    IF (TT = 0) AND (BB = 0) 
    THEN 
        APLDIV = 1 
    ELSE 
        APLDIV = TT/BB 
    END IF 
END DEF 

Translator Output


FUNCTION APLDIV(ByRef TT AS DOUBLE,ByRef BB AS DOUBLE)AS DOUBLE 
    IF(TT=0)AND(BB=0)THEN 
        APLDIV=1 
    ELSE 
        APLDIV=TT/BB 
    END IF 
END FUNCTION 


DELETE

The VAX BASIC or DEC BASIC DELETE statement removes a record from a relative file or indexed file.

Translated Equivalent

DECBAS_DELETE channel


Remarks

Visual Basic does not have a corresponding function. DECBAS_DELETE, therefore, simulates a deletion on local relative files by overwriting the record with NUL characters.

In VAX BASIC or DEC BASIC, if you deleted Record No. 10, a Record Not Found error would be issued if you subsequently tried to access Record No. 10. By contrast, in Visual Basic, Record No. 10 would still exist, but would contain only NUL characters.

For more information on I/O, see Chapter 5.


Example

VAX BASIC or DEC BASIC Input


DELETE #2% 

Translator Output


DECBAS_DELETE 2 


DET

The VAX BASIC or DEC BASIC DET function returns the value of the determinant of the last matrix inverted with the MAT INV function.

Translated Equivalent

DECBAS_DET

Remarks

Because the internal format of floating-point numbers is different between VAX BASIC or DEC BASIC and Visual Basic, DECBAS_DET does not yield exactly the same result as DET. At this time, the determinant can be calculated for matrices up to 3X3 only.

For more information on floating-point differences, see Chapter 4.


Example

VAX BASIC or DEC BASIC Input


XX = DET 

Translator Output


XX=DECBAS_DET  


DIF$

The VAX BASIC or DEC BASIC DIF$ function returns a numeric string whose value is the difference between two numeric strings.

Translated Equivalent

DECBAS_DIF$


Remarks

Because Visual Basic has no decimal or string arithmetic, the Translator must pass this function to the DECBAS_DIF$ routine for processing.

The algorithm used is simple long-hand subtraction. For compatibility with VAX BASIC or DEC BASIC, DECBAS_DIF$ raises an Illegal Number error if either input string exceeds 60 characters.


Example

VAX BASIC or DEC BASIC Input


SS = DIF$ ("8128", "-1") 

Translator Output


SS=DECBAS_DIF$("8128","-1") 


DIMENSION

The VAX BASIC or DEC BASIC DIMENSION statement creates and names a static, dynamic, or virtual array. The array subscripts determine the dimensions and the size of the array. You can specify the data type of the array and associate the array with an I/O channel.

Translated Equivalent

Not Executable, Not Virtual
Dim array-name ([int-const1 TO] int-const2,...) As data-type

Executable
ReDim array-name ([int-var1 TO] int-var2,...) As data-type

Virtual
Not supported


Remarks

Visual Basic does not support virtual arrays. The Translator gives a warning when translating a virtual array and generates a standard memory array in its place.

Visual Basic does not support arrays of fixed length strings. If specified, the Translator ignores string lengths.

Unlike the VAX BASIC or DEC BASIC DIMENSION statement, Visual Basic does not propagate the data type throughout the Visual Basic Dim statement. For this reason, the Translator explicitly specifies the data type for each item within the DIMENSION statement.

There are a number of data representation differences between VAX BASIC or DEC BASIC on the OpenVMS platform and Visual Basic on the Windows NT platform. For more information, see Chapter 4.


Example

VAX BASIC or DEC BASIC Input


DIM LONG MYARRAY (S, -1 TO 1) 
DIM LONG MYARRAY (S, X) 

Translator Output


REDIM MYARRAY(S,-1 TO 1)AS LONG 
REDIM MYARRAY(S,X)AS LONG 


ECHO

The VAX BASIC or DEC BASIC ECHO function causes characters that have been entered by a user to be echoed at a terminal that is opened on a specified channel.

Translated Equivalent

For syntax, see the hardcopy manual.

Example

VAX BASIC or DEC BASIC Input


I = ECHO (0) 
I = NOECHO (0) 
Translator Output


I=DECBAS_ECHO(0) 
I=DECBAS_NOECHO(0) 


EDIT$

The VAX BASIC or DEC BASIC EDIT$ function performs one or more string editing functions, depending on the value of its integer argument.

Translated Equivalent

DECBAS_EDIT$


Remarks

If the numeric expression passed to this function is a floating-point value, VAX BASIC or DEC BASIC truncates it. Visual Basic, however, rounds off the value.

Example

VAX BASIC or DEC BASIC Input


new_string = EDIT$(old_string,32) 
Translator Output


new_string=DECBAS_EDIT$(old_string,32) 


END

The VAX BASIC or DEC BASIC END statement marks the physical and logical end of a main program, a program module, or a block of statements.

Translated Equivalent

End


Remarks

During the translation process, there is no change in the END keyword; however, the word following the END keyword can change. For example, END DEF is converted to End Function, but END SUB remains End Sub. END statements that provide a value (DEF and FUNCTION) are preceded by an assignment of the value into the function's name because that is how Visual Basic returns function values. END PROGRAM is translated to End Sub preceded by a DECBAS_END call. END HANDLER is translated as Resume Next, followed by a label of the form DECBAS_XXXX:. Because nested DEF statements become full Function statements in Visual Basic, you must edit them manually to move them out of the routine in which they were defined. The Translator displays a message reminding you to perform this edit.

ERL

The VAX BASIC or DEC BASIC ERL function returns the number of the BASIC line where the last error occurred.

Translated Equivalent

None


Remarks

In VAX BASIC and DEC BASIC, the ERL function is not supported by default. A compiler switch that turns it on suppresses some optimization. Visual Basic does not supply line number information in the ERR object, so you must modify the translation of code that relies on the error line number.

ERN$

The VAX BASIC or DEC BASIC ERN$ function returns the name of the main program, subprogram, or DEF function that was executing when the last error occurred.

Translated Equivalent

DECBAS_ERN$


Remarks

In native mode, Visual Basic does not have any way to determine what module, function, subroutine, and so on is being executed. Visual Basic provides only the project name. This routine accomplishes that function, returning the Visual Basic project name.

ERR

The VAX BASIC or DEC BASIC ERR function returns the VAX BASIC or DEC BASIC error number of the current run-time error.

Translated Equivalent

DECBAS_ERR


Remarks

The DECBAS_ERR routine converts errors that are raised with
DECBAS_CAUSEERROR to their original value. If the current error was not generated with DECBAS_CAUSEERROR, the Translator assumes it to be a Visual Basic error, and translates it to its closest VAX BASIC or DEC BASIC equivalent. It is likely that you will need to edit any code that uses the VAX BASIC or DEC BASIC ERR function.

ERT$

The VAX BASIC or DEC BASIC ERT$ function returns explanatory text associated with an error number.

Translated Equivalent

DECBAS_ERT$


Remarks

DECBAS_ERT$ accepts a VAX BASIC or DEC BASIC error number and returns the associated VAX BASIC or DEC BASIC error text if associated error text is found.

EXIT

The VAX BASIC or DEC BASIC EXIT statement lets you exit from a main program, a SUB or FUNCTION subprogram, a multiline DEF, a statement block, or a handler.

Translated Equivalent

Exit


Remarks

During the translation process, the VAX BASIC or DEC BASIC EXIT keyword is translated to the Visual Basic Exit keyword without any changes; however, the keyword following EXIT can be changed. For example, EXIT DEF is converted to Exit Function. Table 7-1 shows all variations of the EXIT keyword and its translations.

Table 7-1 EXIT Statement Keyword Translation
VAX BASIC or DEC BASIC Keyword Translation
DEF Function
FUNCTION Function
SUB Sub
HANDLER Err.Raise Number=Err.Number
PROGRAM Sub
label label
When VAX BASIC or DEC BASIC EXIT statements that provide a value (DEF and FUNCTION) are translated, they are preceded by an assignment of the value into the function's name because that is how Visual Basic returns function values. See the Example section.


Example

VAX BASIC or DEC BASIC Input


EXIT FUNCTION B 
Translator Output


ABC=B 
EXIT FUNCTION 
The following code shows the translation of an EXIT label statement: VAX BASIC or DEC BASIC Input


C: 
FOR I = 1 TO 10 
    A = A + 1 
    PRINT A; 
    IF A > 7 THEN EXIT C END IF 
    A = A+2 
NEXT I 
Translator Output


C: 
  FOR I=1 TO 10 
    A=A+1 
    DECBAS_PRINT 0,A,DECBAS_SEMI 
    IF A>7 THEN 
     GOTO DECBAS_000002 
    END IF 
     A=A+2 
  NEXT I 
DECBAS_000002: 


EXP

The VAX BASIC or DEC BASIC EXP function returns the value of the mathematical constant e raised to a specified power.

Translated Equivalent

Exp


Remarks

For a discussion of floating-point differences, see Chapter 4.

EXTERNAL

The VAX BASIC or DEC BASIC EXTERNAL statement declares constants, variables, functions, and subroutines external to your program. You can describe parameters for external functions and subroutines.

Translated Equivalent

External Variable Declaration
Not supported. The Translator flags as an error.

External Constant Declaration
Not supported. The Translator flags as an error.

External Function Declarations
Declare Function name "<Place DLL name here>" (params) As data-type

External Subroutine Declarations
Declare Sub name "<Place DLL name here>" (params)


Remarks

Visual Basic does not support external variables and external constants. The Translator flags these as an error and does not generate any Visual Basic code for these statements. Depending on your use of the external variable or constant, you may be able to use a Visual Basic Public variable or constant. Another, more systemwide, alternative is to create an OLE server to house the global variables and constants. Then, you can reference the OLE server from within the Visual Basic development environment using the Tools/References menu. Access to the global constants are automatic, while access to the global variables can be obtained through the use of properties. Refer to the Visual Basic documentation for more information. Because of the Visual Basic ability to track routines defined within a project, you may not need external declarations of SUB statements and FUNCTION statements; however, because the Translator cannot determine where the externally referenced routines reside, it always generates a corresponding Visual Basic Declare statement. If the routine to which you are making an external reference resides within the current Visual Basic project, you no longer need the external reference and you must delete the generated Declare statement. If the routine to which you are making an external reference resides within an OLE Automation server, you no longer need the external declaration and you must delete the generated Declare statement. Instead, this reference is set up using the Tools/References menu within the Visual Basic development environment. If the routine that you are externally referencing resides within a standard (non-OLE) DLL, then the Declare statement must stay. Note that the Translator leaves a placeholder "<Place DLL Name Here>" for you to replace with the DLL location and name when they are known. Pass by DESC is not supported in Visual Basic. The Translator flags these as errors and translates them to pass by REF parameters. Although multiple FUNCTION or SUB statements can be declared within a single EXTERNAL statement, the Translator splits them so that there is one Declare statement per declaration. Visual Basic Version 4.0 does not support typed Optional parameters to be specified within a Declare statement. All Optional parameters must be of the Variant data type. The Translator flags these with a warning message, but still generates the specified data types. If left this way, Visual Basic Version 4.0 flags these with an error message; however, as of Visual Basic Version 5.0, typed Optional parameters are supported and the generated Declare statements are valid. Visual Basic does not support parameters specified as fixed length strings within the Declare statement. The Translator flags these with an informational message and translates them to Dynamic Strings. Refer to the Visual Basic Language Reference documentation on the Declare statement for more information. All Declare statements are generated within the project-wide *_GBLS.VB file.

Example

VAX BASIC or DEC BASIC Input


EXTERNAL DOUBLE FUNCTION FUNC1 BY REF (LONG, , STRING, SINGLE BY VAL) 
Translator Output


DECLARE FUNCTION FUNC1 "<Place DLL Name Here>" (ByRef VBarg AS LONG, 
        ByRef VBarg AS LONG, ByRef VBarg AS STRING, 
        ByVal VBarg AS SINGLE) AS DOUBLE 


FIELD

The VAX BASIC or DEC BASIC FIELD statement dynamically associates string variables with all or parts of a record buffer. FIELD statements do not move data; instead, they permit direct access through string variables to sections of a specified record buffer.

Translated Equivalent

None


Remarks

The Translator does not support conversion of the VAX BASIC or DEC BASIC FIELD statement. The Translator produces the following message: %DB2VB-E-VBNOFIELD, FIELD statement can not be translated, please use MAPs

FIND

The VAX BASIC or DEC BASIC FIND statement locates a specified record in a disk file and makes it the current record for a GET, UPDATE, or DELETE operation. FIND statements are valid on RMS sequential, relative, and indexed files.

Translated Equivalent

DECBAS_FIND CHANNEL:=channel [ , position-clause] [,lock-clause] [,WAIT_VALUE := int-exp]


Remarks

Unlike VAX BASIC or DEC BASIC, for local sequential and local relative files, Visual Basic does not support the LOCK clause or its ALLOW subclause, or any of the values of LOCK and ALLOW. Please refer to Chapter 5 for more information on I/O.

Example

VAX BASIC or DEC BASIC Input


FIND #3, RECORD 2, WAIT 20 
Translator Output


DECBAS_FIND CHANNEL:= 3 ,POS_CLAUSE_TYPE:= DECBAS_RECORD, _ 
        RECORD_NUMBER:= 2,WAIT_VALUE:= 20, _ 
        LOCK_CLAUSE_TYPE:= DECBAS_LOCK_WAIT 


FIX

The VAX BASIC or DEC BASIC FIX function truncates a floating-point value at the decimal point and returns the integer portion represented as a floating-point value.

Translated Equivalent

Fix


FNEND

The VAX BASIC or DEC BASIC FNEND statement is a synonym for the VAX BASIC or DEC BASIC END DEF statement. See the DEC BASIC and VAX BASIC for OpenVMS Systems Reference Manual for more information.

Translated Equivalent

End Function


Remarks

Visual Basic does not support the equivalent of the VAX BASIC or DEC BASIC DEF and DEF* statements. DEF and DEF* statements are translated to the Visual Basic Function statement; therefore, END DEF and END DEF* (synonymous with FNEND) are translated to End Function. Any value returned from the function is moved to the previous line in an assignment to the function name. DEF statements can be defined within FUNCTION and SUB statements, but FUNCTION statements must be defined at the outermost level. You must edit the result to move the FUNCTION (originally, DEF) out to the top level. The DEC BASIC and VAX BASIC for OpenVMS Systems Reference Manual discusses in detail the differences among the DEF, DEF*, and FUNCTION statements. You should review this material to determine whether those differences are significant to your program. Finally, revisit those FUNCTION statements where the differences are significant and verify that they are translated to execute with the desired behavior.


Previous Next Contents Index