Sending RB Commands from a Host Program

  • 7021479
  • 30-Mar-2000
  • 01-Apr-2018

Environment

Reflection 2014
Reflection for UNIX and OpenVMS 2014
Reflection for UNIX and OpenVMS 2011
Reflection for UNIX and OpenVMS version 14.x
Reflection Standard Suite 2011
Reflection for HP version 14.x
Reflection for ReGIS Graphics version 14.x

Situation

Reflection can execute Reflection Basic (RB) commands sent from a host program. This technical note describes the syntax used in the host program and explains how to effectively use completion codes returned by Reflection.

For an overview of how host-initiated programs work with Reflection, refer to KB 7021476.

For information about executing host-initiated Reflection Basic commands using VBA, see KB 7021486.

Resolution

RB is the recommended language for writing host-initiated programs that perform complex procedures or use OLE (object linking and embedding) technology. To send a single command from a host program to Reflection, you may want to use the Reflection Command Language (RCL) instead. See KB 7021478 for details.

RB commands are procedural and can extend over multiple lines. An RB script contains multiple commands, beginning with Sub Main and ending with End Sub.

To send an RB script from a host program to Reflection, place the entire script within the following elements for your emulation type. Note that individual commands within the script are separated by a carriage return.

HP Emulation

Syntax

<ESC>&o<tag>t<term>G<RB script><ESC>&oH

Example

<ESC>&o1GSub Main
    Dim c As Integer
    c = Val(InputBox$("Enter the sales amount:"))
    MsgBox "Your commission is: " & c
End Sub<ESC>&oH


<ESC> is described in Generating Special Characters below.

<tag>t is an optional tag used to associate a return value with a host-initiated command.

<term> specifies whether or not reflection returns a completion code to the host program. See Specifying Completion Codes below for acceptable values.

VT Emulation

Syntax

<DCS>2000;<term>;<tag>{<commands><ST>

Example

<DCS>2000;1{ Sub Main
    Dim c As Integer
    c = Val(InputBox$("Enter the sales amount:"))
    MsgBox "Your commission is: " & DisplayCommission(c)
End Sub <ST>

<DCS> and <ST> are described in Generating Special Characters below.

<term> specifies whether or not reflection returns a completion code to the host program. See Specifying Completion Codes below for acceptable values.

<tag>t is an optional tag used to associate a return value with a host-initiated command.

Wyse Emulation

Syntax

<esc>\01772000;{

Example

#!/bin/sh
echo "\033\01772000;{"
echo "Sub Main"
echo "dim ie as object"
echo 'set ie = CreateObject("InternetExplorer.Application")'
echo 'ie.Navigate "https://www.attachmate.com"'
echo "ie.Visible = true"
echo "End Sub"
echo "\033\\"

Generating Special Characters

Use the values and key combinations below to properly generate the following special characters in your host programming language.

ASCII and 7-Bit Values

Special characters
Decimal
Hexadecimal
Octal
7-bit
<CR>
13
0D
15
-
<ESC>
27
1B
33
-
<DCS>
144
90
220
<ESC>+P
<ST>
156
9C
234
<ESC>+\

Specifying Completion Codes

Although many choices are available, we recommend that you use one of the following values for <term>. Other options are described in your Reflection documentation.

1
Always return a completion code
2
Never return a completion code

How Completion Codes are Returned

Reflection returns completion codes to the host program in the following format:

!RB!snnnnnn;<CR>

where

!RB!
identifies the completion code as coming from Reflection.
s
is either a minus sign (-) for a negative number or a zero (0) for a positive number.
nnnnn
represents a Reflection-trappable error code.
<CR>
signifies the end of the completion code. (In most cases, this is stripped out by the host when the completion code is read.)

Examples of Reflection Error Codes

A complete list of error codes returned by Reflection is included in the online help provided with the Reflection Basic Editor. The table below lists only the most common error codes.


Error Code
Symbolic Error Name
Meaning
10005
rcErrTimeout
Method timed out.
10009
rcErrOperationFailed
The Reflection API call failed.
10066
rcErrAlreadyConnected
A connection is currently active.
10067
rcErrConnectionError
General connection error.
10069
rcErrReflectionBusy
Reflection is busy.

Additional Information

Legacy KB ID

This document was originally published as Attachmate Technical Note 1279.