Technical Notes |
|
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 Technical Note 1223.
For information about executing host-initiated Reflection Basic commands using VBA, see Technical Note 2148.
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 Technical Note 1278 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.
<ESC>&o<tag>t<term>G<RB script><ESC>&oH
<ESC>&o1GSub Main Dim c As Integer c = Val(InputBox$("Enter the sales amount:")) MsgBox "Your commission is: " & cEnd 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.
<DCS>2000;<term>;<tag>{<commands><ST>
<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.
Use the values and key combinations below to properly generate the following special characters in your host programming language.
| 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>+\ |
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 |
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.) |
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. |