Compaq BASIC Translator
User Manual


Previous Contents Index


OPEN

The VAX BASIC or DEC BASIC OPEN statement opens a file for processing. It transfers user-specified file characteristics to OpenVMS Record Management Services (RMS) and verifies the results.

Translated Equivalent

DECBAS_OPEN filespec, for_clause, channel, org_clause, access_clause, allow_clause, defaultname, map, recordsize, connect, temporary, unlock_explicit, location, key_list


Remarks

Some of the VAX BASIC or DEC BASIC OPEN clauses work differently in Visual Basic, and some of the clauses are not supported. Where there are differences, it is typically because there is no reasonable corresponding Visual Basic or Win32 mechanism, or because the clause conflicts with some underlying feature or architectural construct of Visual Basic or the Windows system. For example, RMS is not available as a native API on Windows systems. Although the Translator provides access to RMS files via the Translator RMS Server component, there are some VAX BASIC or DEC BASIC I/O clauses that are not currently supported by the Translator. The following VAX BASIC or DEC BASIC OPEN clauses are not currently supported:
BLOCKSIZE
BUCKETSIZE
BUFFER
CONTIGUOUS
DEFAULTNAME
EXTENDSIZE
FILESIZE
NOREWIND
NOSPAN
ORGANIZATION UNDEFINED
ORGANIZATION VIRTUAL
ORGANIZATION [any format] STREAM
RECORDTYPE
SPAN
USEROPEN
WINDOWSIZE

Note

Perhaps the most obvious and important difference in behavior involves the OPEN FOR OUTPUT clause for the local-file (Windows-resident) access mode. In VAX BASIC or DEC BASIC, if the file already exists, a new version of the file is created. The FAT file system on Windows systems does not maintain file versions. Therefore, if you specify OPEN FOR OUTPUT and the file already exists, the existing file is deleted! To keep the previous version of the file, you must either modify your VAX BASIC or DEC BASIC code before translation, or modify the translated code before executing the program. Prior to the OPEN statement, determine whether the file exists, and if it does, rename it.
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 be different 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, so it is best to check and test each usage of error codes.

Location
The Translator attempts to determine whether the file you are opening is a terminal (the terminal itself, not a terminal-format file), a locally resident sequential or relative file, or a remotely resident indexed file. There can be occasions when the Translator is unable to make the correct determination. In those cases, you would have to modify the DECBAS_OPEN procedure call in the translated code to change the LOCATION parameter (the thirteenth parameter in the DECBAS_OPEN call). The Translator always provides a channel-zero terminal emulator window for the usual console terminal I/O operations (PRINT, INPUT, and so forth). If you are opening a separate terminal window on another channel, using one of the standard designations such as SYS$INPUT, SYS$OUTPUT, SYS$ERROR, KB: or TT:, the Translator recognizes that you are opening the terminal. Otherwise, you must change the LOCATION parameter of the DECBAS_OPEN call, to be DECBAS_LOCATION_TERMINAL. Refer to Section 5.3.5 for information on how to modify the LOCATION parameter and other parameters for the various file organizations.

Keys
If you are making use of a large number of alternate keys or segmented keys, it is possible to exceed the Visual Basic maximum number of continuation lines per statement in the translated Visual Basic DECBAS_OPEN call. If this happens, you may need to shorten the length of your key variable names or perhaps even reduce the number of segments or alternate keys.


Example

VAX BASIC or DEC BASIC Input


OPEN "XYZ" AS FILE 1 
Translator Output


DECBAS_OPEN "XYZ",DECBAS_FOR_UNSPECIFIED,1,DECBAS_ORG_UNSPECIFIED _ 
   + DECBAS_ORG_RFM_UNSPECIFIED,DECBAS_ACCESS_UNSPECIFIED, _ 
   DECBAS_ALLOW_UNSPECIFIED,DECBAS_STRING_ARG_DEFAULT, _ 
   DECBAS_STRING_ARG_DEFAULT,DECBAS_RECORDSIZE_UNSPECIFIED, _ 
   DECBAS_INTEGER_ARG_DEFAULT,FALSE,FALSE,DECBAS_LOCATION_UNSPECIFIED 


OPTION

The VAX BASIC or DEC BASIC OPTION statement allows you to set compilation qualifiers such as default data type, size, and scale factor. You can also set compilation conditions such as severity of run-time errors to handle, constant type checking, subscript checking, overflow checking, decimal rounding, and setup in a source program. The options that you set affect only the program module in which the OPTION statement occurs.

Translated Equivalent

Not fully supported


Remarks

The Translator takes the OPTION declaration into account when possible (some clauses are supported) and gives a warning message otherwise. You should review the warning messages and modify the Visual Basic source as necessary to correct problems. The following is a list of the VAX BASIC or DEC BASIC OPTION clauses with issues for each clause:

PLACE$

The VAX BASIC or DEC BASIC PLACE$ function explicitly changes the precision of a numeric string. PLACE$ returns a numeric string, truncated or rounded, according to the value of an integer argument that you supply.

Translated Equivalent

DECBAS_PLACE$


Example

VAX BASIC or DEC BASIC Input


s = PLACE$ ("9999.9999", 3) 
Translator Output


s=DECBAS_PLACE$("9999.9999",3) 


POS

The VAX BASIC or DEC BASIC POS function searches for a substring within a string and returns the substring's starting character position.

Translated Equivalent

DECBAS_POS str-exp1, str-exp2, int-exp


Example

VAX BASIC or DEC BASIC Input


p = POS ("ABCDEFG", "DEF", 1) 
Translator Output


p=DECBAS_POS("ABCDEFG","DEF",1) 


PRINT

The VAX BASIC or DEC BASIC PRINT statement transfers program data to a terminal or a terminal-format file.

Translated Equivalent

DECBAS_PRINT channel, print_item, ...


Example

VAX BASIC or DEC BASIC Input


PRINT #1, a, b 
Translator Output


DECBAS_PRINT 1,a,DECBAS_COMMA,b,DECBAS_EOL 


PRINT USING

The VAX BASIC or DEC BASIC PRINT USING statement generates output formatted according to a format string (either numeric or string) to a terminal or a terminal-format file.

Translated Equivalent

DECBAS_PRINTUSING channel, format_string, print_item, ...


Remarks

See the PRINT statement for more information.

Example

VAX BASIC or DEC BASIC Input


PRINT USING "##.##", 12.345 
Translator Output


DECBAS_PRINTUSING 0,"##.##",12.345,DECBAS_EOL 


PROD$

The VAX BASIC or DEC BASIC PROD$ function returns a numeric string that is the product of two numeric strings. The precision of the returned numeric string depends on the value of an integer argument.

Translated Equivalent

DECBAS_PROD$


Remarks

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

Example

VAX BASIC or DEC BASIC Input


n = PROD$("34.555", "297.676", 1) 
Translator Output


n=DECBAS_PROD$("34.555","297.676",1) 


PROGRAM

The VAX BASIC or DEC BASIC PROGRAM statement allows you to identify a main program with a name other than the file name.

Translated Equivalent

Sub Main()


Remarks

An explicit PROGRAM statement is translated to a Visual Basic Sub Main() statement followed by a remark (Rem Program program-name) and a call to the routine DECBAS_INIT to initialize the state of the run-time library. If the PROGRAM statement is missing (implied), a Visual Basic Sub Main() is inserted to provide an explicit entry point where the Visual Basic program can start execution.

Example

VAX BASIC or DEC BASIC Input


PROGRAM examples 
Translator Output


SUB MAIN() 
REM PROGRAM examples 


PUT

The VAX BASIC or DEC BASIC PUT statement transfers data from the record buffer to a file. PUT statements are valid on RMS sequential, relative, and indexed files. You cannot use PUT statements on terminal-format files or virtual array files.

Translated Equivalent

DECBAS_PUT CHANNEL := channel [,RECORD_NUMBER := num-exp] [,COUNT_SIZE := int-exp]


Remarks

For local relative and sequential files, the Translator does not support the COUNT clause. These files have fixed record length in Visual Basic.

Example

VAX BASIC or DEC BASIC Input


PUT #5, RECORD 133, COUNT 16% 
Translator Output


DECBAS_PUT CHANNEL:= 5,RECORD_NUMBER:= 133, COUNT_SIZE:= 16 


QUO$

The VAX BASIC or DEC BASIC QUO$ function returns a numeric string that is the quotient of two numeric strings. The precision of the returned numeric string depends on the value of an integer argument.

Translated Equivalent

DECBAS_QUO$


Remarks

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

Example

VAX BASIC or DEC BASIC Input


n = QUO$ ("458996.43", "123222.444", 2) 
Translator Output


n=DECBAS_QUO$("458996.43","123222.444",2) 


RAD$

The VAX BASIC or DEC BASIC RAD$ function converts a specified integer in Radix-50 format to a 3-character string.

Translated Equivalent

None


Remarks

The Translator does not support conversion of the obsolete VAX BASIC or DEC BASIC RAD$ function.

RANDOMIZE

The VAX BASIC or DEC BASIC RANDOMIZE (RANDOM) statement gives the random number function, RND, a new starting value.

Translated Equivalent

Randomize


Remarks

The Visual Basic version of this function takes an optional argument that provides a seed value, but the Translator does not use it.

Example

VAX BASIC or DEC BASIC Input


RANDOM 
Translator Output


RANDOMIZE 


RCTRLC

The VAX BASIC or DEC BASIC RCTRLC function disables Ctrl/C trapping.

Translated Equivalent

DECBAS_RCTRLC


Example

VAX BASIC or DEC BASIC Input


Y = RCTRLC 
Translator Output


Y=DECBAS_RCTRLC() 


RCTRLO

The VAX BASIC or DEC BASIC RCTRLO function cancels the effect of Ctrl/O typed on a specified channel.

Translated Equivalent

DECBAS_RCTRLO


Example

VAX BASIC or DEC BASIC Input


Y% = RCTRLO(0%) 
Translator Output


Y__%=DECBAS_RCTRLO(0) 


READ

The VAX BASIC or DEC BASIC READ statement assigns values from a DATA statement to variables.

Translated Equivalent

No exact equivalent


Remarks

Although there is no simple, exact equivalent for the VAX BASIC or DEC BASIC READ statement, the Translator uses the DECBAS_DATA array created by the translation of the VAX BASIC or DEC BASIC DATA statement to assign values to variables. See the Example section.

Example

VAX BASIC or DEC BASIC Input


SUB RD 
DATA ABC,DEF,GHI 
READ X,Y,Z 
RESTORE 
END SUB 
Translator Output


SUB RD 
DIM DECBAS_DATA()                 
DIM DECBAS_DATA_INDEX AS VARIANT  
DECBAS_READ_RD DECBAS_DATA, DECBAS_DATA_INDEX, X,Y,Z 
DECBAS_DATA_INDEX = 0 
END SUB 
SUB DECBAS_READ_DATA_RD( DECBAS_DATA, DECBAS_DATA_INDEX ) 
REDIM DECBAS_DATA(3) 
DECBAS_DATA(0) = """ABC""" 
DECBAS_DATA(1) = """DEF""" 
DECBAS_DATA(2) = """GHI""" 
END SUB 


REAL

The VAX BASIC or DEC BASIC REAL function converts a numeric expression or numeric string to a specified or default floating-point data type.

Translated Equivalent

DECBAS_REAL


Remarks

If you have specified the optional conversion size, the Translator converts SINGLE to DECBAS_SINGLE and DOUBLE to DECBAS_DOUBLE. Also, the Translator converts GFLOAT to DECBAS_DOUBLE.

Example

VAX BASIC or DEC BASIC Input


a = REAL(rvar, SINGLE) 
Translator Output


a=DECBAS_REAL(rvar,DECBAS_SINGLE) 


Previous Next Contents Index