U2-RBASIC

Configures a Reality file to be used to access a remote Basic subroutine on the U2 / Universe server. It requires a U2-SET to be active in the session.

The calling of a remote subroutine is performed by writing items to the Reality file.

ID Direction Description

Name

WRITE

The name of the remote subroutine to call.

NUM_ARGS

WRITE

The number of arguments in the subroutine call with a maximum of 10.

ARGn

READ/WRITE

Retrieve or set the value for argument n.

RESULT

READ

Execute the subroutine.

SELECT

WRITE

Specify a ENGLISH select sentence.

LIST

READ

Retrieve the list of items from the select above.

COMMAND

WRITE

Specify the command to execute .

EXECUTE

READ

Execute the command supplied above and retrieves any output.

REPLY

WRITE

Specifies the user input for a command has been executed that requires it.

Note

An attribute mark is used to signal a carriage return.

REPLY

READ

Retrieve any output from any user input supplied in a REPLY above.

FREE-CONNECTIONS

READ

Retrieve the number of U2 connections still available.

Syntax

U2-RBASIC reality_file

Example

On U2 compile and catalog a subroutine (two arguments, A is the number to be multiplied by 2 and B the returned answer).

SUBROUTINE TEST1(A,B)
B = A * 2
RETURN

On Reality use U2-SET to configure the connection then create the Reality file U2RB to access the subroutine.

U2-RBASIC U2RB

Use a Reality DataBasic program to access the subroutine remotely.

*
* Open the remote link
*
OPEN 'U2RB' TO U2RB ELSE STOP 201,'U2RB'
*
* Set the name of the subroutine to call
*
WRITE "TEST1" ON U2RB,"NAME"
*
* There are two arguments in the subroutine
*
WRITE 2 ON U2RB,"NUM_ARGS"
*
* Argument 1 will be 123 and argument 2 is the returned value (set to null)
*
WRITE 123 ON U2RB,"ARG1"
WRITE "" ON U2RB,"ARG2"
*
* Execute the subroutine (RES = 0)
*
READ RES FROM U2RB,"RESULT" ELSE STOP 202,"RESULT"
*
* Retrieve argument 2, the result
*
READ ANS FROM U2RB,"ARG2" ELSE STOP 202,"ARG2"
*
* Close the file / connection
 
CLOSE U2RB
*
* Answer should be 123 * 2 = 246
*
CRT ANS

 

Comments

If no default account was specified when U2-SET was used, an account is prompted for.

This verb is the equivalent of U2-VIEW reality_file (R