Programming with Reflection
OnEvent method
Syntax object.OnEvent EvNumber, Event, Commands, Enable, AfterEvent, String, Row, Column
Defines commands to be executed when a specified event occurs during a Reflection session. Events defined with this method are equivalent to those defined using the Event Setup dialog box. When you save your settings file, this event becomes part of that settings file and will appear in the list of events shown in the Event Setup dialog box.
Events defined by OnEvent will execute after your macro completes. You cannot use this method to accomplish actions during macro execution.
Tip
Use the macro recorder and the Event Setup dialog box to create OnEvent statements.
EvNumber Argument type: Integer or Enumeration
An index number that determines the location of this event on the list of defined events. Use 1 to add a new event to the top of the list. Use rcNextEvent to add the event to the end of the list. The EventDefined property returns the number of the most recently defined event.
Note: If two or more items on the list of defined events are triggered by the same event, Reflection executes the commands in the order that the events appear in the list, starting with the event closest to the top of the list.
Event Argument type: Enumeration
Identifies the event that will trigger the commands specified in the Commands argument. The possible values are:
rcReflectionStart
Reflection has started. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcReflectionExit
An Exit command has been executed. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcLoadSettingsFile
A settings file has been loaded. Use the String argument to specify the name and path of the file. Use 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcBlockModeEnter
The terminal has entered block mode. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcBlockModeExit
The terminal has exited block mode. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcEvConnected
A connection has been made to a host. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcEvDisconnected
Reflection has disconnected from the host. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcEnterField
The cursor has entered the field which contains the coordinates specified by the Row and Column arguments. Use an empty string ("") as the value for the String argument; this argument is not relevant for this event type.
rcExitField
The cursor has exited from the field which contains the coordinates specified by the Row and Column arguments. Use an empty string ("") as the value for the String argument; this argument is not relevant for this type of event.
rcEnterPos
The cursor has entered the position specified by the Row and Column arguments. Use an empty string ("") as the value for the String argument; this argument is not relevant for this type of event.
rcExitPos
The cursor has left the position specified by the Row and Column arguments. Use an empty string ("") as the value for the String argument; this argument is not relevant for this type of event.
rcTime
The specified amount of time has elapsed from when the event was defined. Use the String argument to specify the interval of time in HH:MM:SS format. Use 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcTimeOfDay
The event occurs at the specified time of day. Use the String argument to specify the time of day in HH:MM:SS format using a 24-hour clock (00:00:00-23:59:59). Use 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcDisplayString
The string specified in the String argument appears on screen.
rcCommString
Defines an event as the reception of the specified string from the host. Use the String argument to specify the string. Use 1 as the value for Row and Column; these arguments are not relevant for this type of event. Use rcCommString only if you are connecting to your IBM host through a gateway (such as UNIX) that uses streaming mode rather than block mode. (In streaming mode, incoming characters appear on screen in sequence, and existing lines of text scroll out of sight as new lines appear. In block mode, you see complete screen displays, beginning with the logon display screen.) If you are connecting directly to an IBM host, use rcDisplayString.
rcNewHostScreen
Defines an event as a new screen from the host. Use an empty string ("") for the String arguments, and 1 for Row and Column; these arguments are not relevant for this type of event.
rcPrinterOpened
Defines an event when the printer is opened and the print job has started. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcPrinterStartOfPage
Defines an event when a print page starts. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcPrinterEndOfPage
Defines an event when a print page ends. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcBeforePrinterClosed
Defines an event just before a printer is closed and the print job ends. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcPrinterClosed
Defines an event when the printer (or file) is closed and the print job is done. Use an empty string ("") as the value of String, and 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcPrinterString
Defines an event that occurs when the string specified in the String argument is sent to the printer. Matches are case-sensitive. Use a 1 as the value for Row and Column; these arguments are not relevant for this type of event.
rcPrinterStringReplace
Defines an event that you can use to intercept the printing of one string and replace it with a different string. Matches are case-sensitive. Use the String argument to specify both the search string and the replacement string. Use the Column argument to specify where within the String argument the replacement string begins. Use a 1 as the value for Row; this argument is not relevant for this type of event. If the value of Column is greater than the length of the String, no string replacement will take place. This example shows how to change "Find" to "Replace".
.OnEvent 1, rcPrinterStringReplace, "", rcEnable, rcEventReEnable, "FindReplace", 1, 5
Use a 1 as the value for Column, if you want to filter out all occurrences of String (replace the String with null string). This example shows how to remove all occurrences of the string "Remove" from your document:
.OnEvent 1, rcPrinterStringReplace, "", rcEnable, rcEventReEnable, "Remove", 1, 1
rcPrinterStatusString
Defines an event that occurs when the string specified in the String argument is sent to the printer status message box. Matches are case-sensitive. The most commonly seen strings in the printer sessions status box are "Printing ", "Printer Error", "Error", "Ready", "Hold", "Connected", "Disconnected", "Command Rejected", "Data Check", "Canceling", "Canceled", "Operation Check", "Host Link Down" and "COMM_CHECK".
Commands Argument type: String
The method, or sequence of methods, to be executed when the event specified by the Event argument occurs. Methods that return values can't be used. Use a space to separate multiple methods. Use double quotation marks around string arguments. For example, the following strings are all valid for this argument:
"Connect"
"TransmitAnsi ""Hello"" TransmitTerminalKey rcIBMEnterKey"
"RunMacro ""MyMacro"", """""
This string can be up to 260 characters long.
Enable Argument type: Enumeration
Specifies whether Event is enabled or disabled:
rcEnable
Event is enabled. If the event occurs, it will trigger the associated commands.
rcDisable
Event is not enabled. If the event occurs, it will not trigger the associated commands.
AfterEvent Argument type: Enumeration
Specifies what happens after Event occurs:
rcEventDisable
After the event occurs, it is still defined, but is disabled. If the event occurs again, it will not trigger the associated commands.
rcEventReenable
After the event occurs, it is still enabled. If the event occurs again, it continues to trigger the associated commands.
rcEventRemove
After the event occurs, it is removed from the list of defined events.
String Argument type: String
Specifies the string that defines string-oriented events. This argument is only relevant when the value you use for Event requires a stringthat is, when Event is rcLoadSettingsFile, rcCommString, rcDisplayString, rcTimeOfDay, or rcTime.
Row Argument type: Integer or Enumeration
Specifies the row location for screen events. This argument is relevant when Event is rcEnterField, rcExitField, rcEnterPos, rcExitPos, or rcDisplayString. When Event is rcDisplayString, you can use rcAnyRow to indicate that the event can occur at any row location.
Column Argument type: Integer or Enumeration
Specifies the column location for screen events This argument is relevant when Event is rcEnterField, rcExitField, rcEnterPos, rcExitPos, or rcDisplayString. When Event is rcDisplayString, you can use rcAnyCol to indicate that the event can occur at any column location.