Compaq BASIC Translator
User Manual


Previous Contents Index


INT

The VAX BASIC or DEC BASIC INT function returns the floating-point value of the largest whole number less than or equal to a specified expression.

Translated Equivalent

Int


INTEGER

The VAX BASIC or DEC BASIC INTEGER function converts a numeric expression or numeric string to a specified or default INTEGER data type.

Translated Equivalent

DECBAS_INTEGER


Remarks

If you specify the optional conversion size, the Translator converts BYTE to DECBAS_BYTE, WORD to DECBAS_WORD, and LONG to DECBAS_LONG. The Translator converts the VAX BASIC or DEC BASIC WORD data type to the Visual Basic Integer data type. For more information, see Chapter 4.

ITERATE

The VAX BASIC or DEC BASIC ITERATE statement allows you to explicitly reexecute a loop. ITERATE label allows escape from a loop.

Translated Equivalent

GOTO DECBAS_nnnnnn


Example

VAX BASIC or DEC BASIC Input


FOR I = 1 TO 5 
    IF I > X THEN ITERATE 
NEXT 
Translator Output


FOR I = 1 TO 5 
    IF I > X THEN GOTO DECBAS_00001 
DECBAS_00001: 
NEXT 
The following code shows the form ITERATE label. VAX BASIC or DEC BASIC Input


C: 
    FOR I = 1 TO 10 
        A = A + 1 
        PRINT A; 
        IF A > 5 THEN ITERATE 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>5 THEN 
     GOTO DECBAS_000003 
    END IF 
     A=A+2 
DECBAS_000003: 
  NEXT I 


KILL

The VAX BASIC or DEC BASIC KILL statement deletes a disk file, removes the file's directory entry, and releases the file's storage space.

Translated Equivalent

Kill


Remarks

File path names on OpenVMS Alpha systems will have a different syntax from path names on Windows NT systems. When you decide where the various files used by your application are to reside, you must adjust these path names accordingly.

LBOUND

The VAX BASIC or DEC BASIC LBOUND function returns the lower bounds of a compile-time or run-time dimensioned array.

Translated Equivalent

LBound


LEFT$

The VAX BASIC or DEC BASIC LEFT$ function extracts a specified substring from a string's left side and leaves the main string unchanged.

Translated Equivalent

Left


Remarks

The Translator actually produces code with the dollar sign ($) retained; however, functionally the code is the equivalent of the Visual Basic function Left.

LEN

The VAX BASIC or DEC BASIC LEN function returns an integer value equal to the number of characters in a specified string.

Translated Equivalent

Len


LET

The VAX BASIC or DEC BASIC LET statement assigns a value to one or more variables.

Translated Equivalent

Let


Remarks

For information about performing division in Visual Basic, see Section 3.8. VAX BASIC or DEC BASIC and Visual Basic differ when assigning a floating-point value to an integer variable. VAX BASIC or DEC BASIC truncates the fractional part of the value before doing the assignment. The assignment I% = 0.625 produces the result 0. Visual Basic rounds the value first. The assignment I% = 0.625 produces the result 1. When you have an expression of the form integer_variable = expression , you can use the Fix function to achieve the same result as VAX BASIC or DEC BASIC: integer_variable = Fix ( expression ) . Visual Basic does not support multitarget assignment, whereas VAX BASIC and DEC BASIC do. The Translator includes partial support for multitarget assignment. In addition to the LET statement (including the plain assignment statement that omits the optional LET keyword), this support affects the LSET and RSET statements. To illustrate the kind of multitarget assignment supported, the following example has two assignment targets:


LET var1,var2 = the_expression 
The translation of the statement is as follows, using a temporary variable:


decbas_temp = the_expression 
LET var1 = decbas_temp 
LET var2 = decbas_temp 
In the following special case, the translation's behavior differs from that of VAX BASIC and DEC BASIC:


a(i),i = 5 
i,a(i) = 5 
In both of these statements, VAX BASIC or DEC BASIC assigns to i before assigning to a(i). There is the possibility of an unforeseen interaction between the assignment destinations and a different result from the result of the Translator's output. Because of the potential occurrence of this special problem case, each multitarget assignment is accompanied by a warning message: %DB2VB-W-MULTASN, Multiple assignment targets serialized The message accompanies every multitarget assignment (not just the problem case) because the Translator does not recognize common subexpressions.


Example

Following is a sample of source code from a program called MULTASN.BAS:


! Fill the array with recognizable items. 
for i = 0 to 10 
 a(i) = i*10 
next i 
 
! VAX&DEC BASIC assign to r before a(r) 
r = 1 
a(r),r = 9 
 
! VAX&DEC BASIC assign to r before a(r) 
r=5 
r,a(r) = 7 
 
! See what we got 
mat print a; 
 
! more multi-target examples 
    a,b,c = pi*r^2 
 here: d,e = a*b-3 
 now: let f,g,h,i = a+b*c 
    a$,b$,c$ = "123456789" 
    d$ = "1234567890123456789" 
    rset a$,b$,c$ = num$(h) 
    lset d$ = a$ + b$ 
    print "|";a$;"|";b$;"|";c$;"|";d$;"|" 
The resulting translation, MULTASN.VB, is as follows:


Attribute VB_Name = "MULTASN" 
 
SUB MAIN() 
DECBAS_INIT"%Bbo7dVXCOUON6","QybCX" 
 ' Fill the array with recognizable items. 
for i=0 to 10 
        a(i)=i*10 
next i 
 ' VAX&DEC BASIC assign to r before a(r) 
r=1 
DECBAS_TEMP=9 
a(r)=DECBAS_TEMP 
r=DECBAS_TEMP 
 ' VAX&DEC BASIC assign to r before a(r) 
r=5 
DECBAS_TEMP=7 
r=DECBAS_TEMP 
a(r)=DECBAS_TEMP 
 ' See what we got 
DECBAS_MATPRINT 0,a,,,DECBAS_SEMI 
 ' more multi-target examples 
    DECBAS_TEMP=3.141592653589793238462643383279502*r^2 
    a=DECBAS_TEMP 
    b=DECBAS_TEMP 
    c=DECBAS_TEMP 
 here:DECBAS_TEMP=a*b-3 
        d=DECBAS_TEMP 
        e=DECBAS_TEMP 
 now:DECBAS_TEMP=a+b*c 
        let f=DECBAS_TEMP 
        let g=DECBAS_TEMP 
        let h=DECBAS_TEMP 
        let i=DECBAS_TEMP 
    DECBAS_TEMP="123456789" 
    a_$=DECBAS_TEMP 
    b_$=DECBAS_TEMP 
    c_$=DECBAS_TEMP 
    d_$="1234567890123456789" 
    DECBAS_TEMP=DECBAS_NUM$(h) 
    rset a_$=DECBAS_TEMP 
    rset b_$=DECBAS_TEMP 
    rset c_$=DECBAS_TEMP 
    lset d_$=a_$+b_$ 
    DECBAS_PRINT 0,"|",DECBAS_SEMI,a_$,DECBAS_SEMI,"|",DECBAS_SEMI,b_$ _ 
     ,DECBAS_SEMI,"|",DECBAS_SEMI,c_$,DECBAS_SEMI,"|" _ 
     ,DECBAS_SEMI,d_$,DECBAS_SEMI,"|",DECBAS_EOL 
DECBAS_EXIT: 
DECBAS_END 
END SUB 


LINPUT

The VAX BASIC or DEC BASIC LINPUT statement assigns a string value, without line terminators, from a terminal or terminal-format file to a string variable.

Translated Equivalent

DECBAS_LINPUT channel, input_item, ...


Remarks

The Translator provides a terminal emulation window on your Windows display. This serves as the standard terminal for typical terminal input and output operations, including LINPUT. From this terminal emulation window, LINPUT (as well as LINPUT # from a terminal-format file) works in much the same manner as under VAX BASIC or DEC BASIC. As with most of the other Translator statements and functions, use caution when dealing with explicit VAX BASIC or DEC BASIC error codes, which can differ from those in Visual Basic. The Translator attempts to map between VAX BASIC or DEC BASIC and Visual Basic error codes, but some codes do not convey equivalent meanings. It is important that you check and test each usage of error codes. For more information on I/O, see Chapter 5.

Example

VAX BASIC or DEC BASIC Input


LINPUT  "type two words", Z, "type something else"; N 
Translator Output


DECBAS_LINPUT 0,"type  two  words",DECBAS_COMMA, Z , "type  something 
else",DECBAS_SEMI, N 


LOC

The VAX BASIC or DEC BASIC LOC function returns a longword integer specifying the virtual address of a simple or subscripted variable or the address of an external function. For dynamic strings, the LOC function returns the address of the descriptor rather than the address of the data.

Translated Equivalent

DECBAS_LOC

or

AddressOf


Remarks

Visual Basic does not have the capability to determine the memory address of a variable, an array element, or a descriptor. There is no Visual Basic function that is equivalent to the VAX BASIC or DEC BASIC LOC function. The Visual Basic Loc function, which returns the current read/write position within an open file, is unrelated. Address of a Function In Version 4.0, Visual Basic cannot determine the memory address of a function. As of Version 5.0, Visual Basic adds the AddressOf operator, which can determine the memory address of a function, but only when used as a parameter in a function call; for example:


FNC1(A, AddressOf FNC2, B) 
In VAX BASIC and DEC BASIC, the LOC function does not have this restriction, and is valid independent of context. Therefore, LOC (fnc_name) is sometimes impossible to translate, in which case, the Translator issues an error message. The Translator can directly translate LOC to AddressOf if both of the following conditions are met:

VAX BASIC or DEC BASIC Input


VALUE1 = FNC1(A, LOC(FNC2), B) 
Translator Output


VALUE1 = FNC1(A, AddressOf FNC2, B) 
Address of a Variable If the Translator determines that the LOC parameter is a variable, it translates the LOC statement to a call to the DECBAS_LOC function, which takes the LOC parameter as its parameter. See the following example. VAX BASIC or DEC BASIC Input


VAR_ADRS = LOC (COUNT_VAR) 
Translator Output


VAR_ADRS = DECBAS_LOC (COUNT_VAR) 
If the Translator is unable to determine whether the LOC parameter is a function or a variable, it issues an error message and does not attempt to translate it. Warning: Visual Basic variables can move in memory. You should take the address of a variable immediately before you use it.


LOG

The VAX BASIC or DEC BASIC LOG function returns the natural logarithm (base e) of a specified number. The LOG function is the inverse of the EXP function.

Translated Equivalent

Log


LOG10

The VAX BASIC or DEC BASIC LOG10 function returns the common logarithm (base 10) of a specified number.

Translated Equivalent

DECBAS_LOG10 (real-exp)


Remarks

Because the internal format of floating-point numbers is different between VAX BASIC or DEC BASIC and Visual Basic, DECBAS_LOG10 does not yield exactly the same result as the LOG10 function. For more information on floating-point differences, see Chapter 4.

LSET

The VAX BASIC or DEC BASIC LSET statement assigns left-justified data to a string variable. LSET does not change the length of the destination string variable.

Translated Equivalent

LSet


Remarks

The VAX BASIC or DEC BASIC LSET statement allows multitarget assignment, while the Visual Basic statement allows only one. The Translator includes partial support for multitarget assignments. See the LET statement for a description and examples.

MAG

The VAX BASIC or DEC BASIC MAG function returns the absolute value of a specified expression. The returned value has the same data type as the expression.

Translated Equivalent

Abs


MAGTAPE

The VAX BASIC or DEC BASIC MAGTAPE function permits your program to control unformatted magnetic tape files.

Translated Equivalent

None


Remarks

Visual Basic does not support access to magnetic tapes; therefore, the Translator does not support conversion of the MAGTAPE function.

MAP

The VAX BASIC or DEC BASIC MAP statement defines a named area of statically allocated storage called a PSECT, declares data fields in the record, and associates them with program variables.

Translated Equivalent

Visual Basic Class


Remarks

Visual Basic does not have MAP statements; they are translated to Visual Basic classes. Refer to Section 4.2.6 for detailed information on the MAP statement.

MAP DYNAMIC

The VAX BASIC or DEC BASIC MAP DYNAMIC statement names the variables and arrays whose size and position in a storage area can change at run time. The MAP DYNAMIC statement is used in conjunction with the REMAP statement. The REMAP statement defines or redefines the position in the storage area of variables named in the MAP DYNAMIC statement.

Translated Equivalent

None


Remarks

Because Visual Basic does not have a concept that corresponds to dynamic mapping, the Translator does not support conversion of the MAP DYNAMIC statement. The Translator produces a warning and converts the code as if it were a MAP statement. Strings, if not specified, default to a size of 16 bytes.

MAR

The VAX BASIC or DEC BASIC MAR function returns the current margin width of a specified channel.

Translated Equivalent

DECBAS_MAR


Example

VAX BASIC or DEC BASIC Input


width = MAR(0) 
Translator Output


width = DECBAS_MAR(0) 


MARGIN

The VAX BASIC or DEC BASIC MARGIN statement specifies the margin width for a terminal or for records in a terminal-format file.

Translated Equivalent

DECBAS_MARGIN


Example

VAX BASIC or DEC BASIC Input


MARGIN 60 
Translator Output


DECBAS_MARGIN 0,MARGIN_WIDTH:=60 


MAT

The VAX BASIC or DEC BASIC MAT statement lets you delete and manipulate one- and two-dimensional arrays. You can use the MAT statement to assign values to array elements or to redimension a previously dimensioned array. You can also perform matrix arithmetic operations such as multiplication, addition, and subtraction, and other matrix operations such as transposing and inverting matrices.
For syntax, see the hardcopy manual.

Remarks

Visual Basic does not support the VAX BASIC or DEC BASIC MAT statement. Therefore, the Translator translates all calls to the MAT statement to calls to DECBAS_MAT* support routines. Output variables must exist and must be declared explicitly because Visual Basic does not allow the implicit creation and deletion of one- and two-dimensional arrays. Also, if the output variable needs to be resized, it must be declared a dynamic array. The DECBAS_MAT* support routines use the Variant type as a way to pass arrays into the functions. Although the Translator performs a clean translation, note that Visual Basic does not support arrays of fixed-length strings or user-defined types as Variants and will generate a run-time error if used. As with most of the other Translator statements and functions, use caution when dealing with explicit VAX BASIC or DEC BASIC error codes, which can differ from those in Visual Basic. The Translator attempts to map between VAX BASIC or DEC BASIC and Visual Basic error codes, but some codes do not convey equivalent meanings. It is important that you check and test each usage of error codes.

Examples

The following table shows examples of VAX BASIC or DEC BASIC input and Visual Basic output:

Purpose VAX BASIC or DEC BASIC Input Translated Output
Initialization MAT NA_ME$ = NUL$(5,5) DECBAS_MATNUL NA_ME_$(),5,5
Numeric Initialization MAT CONVERT = zer(10,10) DECBAS_MATZER Convert(),10,10
Array Arithmetic MAT NEW_INT = OLD_INT - RSLT_INT DECBAS_MATSUB NEW_INT(), OLD_INT(), RSLT_INT()
Scalar Multiplication MAT Z40 = (4.24) * Z DECBAS_MATMUL Z40(), 4.24, Z()
Transposition MAT Q% = TRN (Z) DECBAS_MATTRN Q__%(),Z()
Inversion MAT A=INV(XYZ) DECBAS_MATINV A(),XYZ()


MAT INPUT

The VAX BASIC or DEC BASIC MAT INPUT statement assigns values from a terminal or terminal-format file to array elements.

Translated Equivalent

DECBAS_MATINPUT channel, item, ...


Remarks

The Translator provides a terminal emulation window on your Windows display. This serves as the standard terminal for typical terminal input and output operations, including MAT INPUT. From this terminal emulation window, MAT INPUT (as well as MAT INPUT # from a terminal-format file) works in much the same manner as under VAX BASIC or DEC BASIC. For more information on I/O issues, see Chapter 5. One major behavioral difference between VAX BASIC or DEC BASIC and the Translator is that the Translator cannot create the matrix within the MAT INPUT function if the matrix (array) does not already exist. If your current VAX BASIC or DEC BASIC code makes use of this feature, you must modify this code before translation to explicitly create the array that is used in the MAT INPUT statement. The DECBAS_MATINPUT support routine uses the Variant type as a way to pass arrays into the function. Although the Translator performs a clean translation, note that Visual Basic does not support arrays of fixed-length strings or user-defined types as Variants and will generate a run-time error if used. See DIMENSION for any functional differences regarding redimensioning arrays (an optional feature of MAT INPUT). The standard Visual Basic ReDim statement is used if redimensioning is requested in MAT INPUT. As with most of the other Translator statements and functions, use caution when dealing with explicit VAX BASIC or DEC BASIC error codes, which can differ from those in Visual Basic. The Translator attempts to map between VAX BASIC or DEC BASIC and Visual Basic error codes, but some codes do not convey equivalent meanings. It is important that you check and test each usage of error codes.

Example

VAX BASIC or DEC BASIC Input


MAT INPUT XYZ(5,5) 
Translator Output


DECBAS_MATINPUT 0,XYZ,5,5 


Previous Next Contents Index