OpenInsight Tools for U2 Integration
It is now possible to interactively run U2 programs and commands from within the CTO environment. At the standard CTO TCL prompt (“>”), issue the command:
U2TCL
If this is the first time you are issuing the command during the current session, you will be prompted for the name of the previously-defined U2 Connection to use. If successful, you will be presented with the U2TCL TCL prompt:
U>
From this prompt, any command you issue will be executed on the host system defined by the U2 Connection. You will remain at the U2TCL prompt, able to run multiple commands, until you exit. When you wish to exit the U2TCL and return to CTO, issue either the command:
U>QUIT
Or
U>EXIT
If you wish to re-enter U2TCL during the same TCL session, just reissue the command:
U2TCL
And you will be reconnected using the previously-defined U2 Connection. If you wish to change the connection you are using, issue the U2TCL command along with the name of the U2 Connection you wish to use:
U2TCL OtherU2ConnectionName
Programs run in the U2TCL can also take advantage of some advanced OpenInsight functionality. A series of support routines allows developers to include, in their U2 programs, calls to OpenInsight’s messagebox, popup, and other GUI functions. To install these support routines on a connection, issue the OIDEPLOY command from within the U2TCL:
U>OIDEPLOY
You will be prompted to enter the name of the U2 file where you want these support programs to be installed. U2TCL will put the support programs in this file, compile, and catalog them. For your convenience, there is also a record created in this file, named CTO_FUNCTIONS, which contains all the function definitions and that can be included in your U2 programs. The support programs include CTO_MSG, CTO_POPUP, CTO_RUNWIN, CTO_RUNWIN_WAIT, CTO_DIALOG_BOX, CTO_GET_PROPERTY, CTO_SET_PROPERTY, CTO_SET_PRINTER, CTO_GUI_FUNCTION, and CTO_GUI_SUBROUTINE.
It is also possible to invoke the U2TCL to execute a single command and then terminate. The syntax is:
U2TCL <connectionName>,<command to run>
For example:
U2TCL MyU2ConnectionName,RUN BP SOMEPROGRAM
Will run the program SOMEPROGRAM located in the BP file on the host defined by MyU2ConnectionName.
If there are U2 commands that you will run frequently, you can define MD entries that make running these commands more convenient. These are comparable to “cataloging” a CTO program, or creating a CTO “paragraph” or “proc”. The record layout of these MD entries is:
ID: <commandname>
1. U2
2. <connectionname>
3. <full command to run>
For example, to define a CTO command called U2TEST that runs on the connection MyU2ConnectionName and runs the U2 command RUN BP SOMEPROGRAM, you would create an MD record that looked like:
ID: U2TEST
1. U2
2. MyU2ConnectionName
3. RUN BP SOMEPROGRAM
As another convenience, if you have a U2 program file attached to your OpenInsight system, and you wish to run a program from that file, you can issue the U2RUN command. The syntax for the U2RUN command is similar to the “normal” CTO RUN command; you must specify the name of the file containing the program you wish to run, and the program name. For example:
U2RUN BP SOMEPROGRAM
The U2RUN command will retrieve the information about the U2 Connection from the definition of the U2 file contained in the OpenInsight database manager; it will (if necessary) open the connection to that U2 Connection, and invoke U2TCL to run the specified program.
U2/OI Integration Routines
You may run U2 programs via U2TCL (or via U2RUN, discussed below), without major modifications. However, if these programs will be run in the CTO environment exclusively, you can enhance them so that they can use OpenInsight functionality, such as popups, message boxes, and OIPI printer management. This functionality is available by adding calls to CTO_DIALOG_BOX, CTO_GET_PROPERTY, CTO_GUI_FUNCTION, CTO_GUI_SUBROUTINE, CTO_MSG, CTO_POPUP, CTO_RUNWIN, CTO_RUNWIN_WAIT, CTO_SET_PRINTER, and CTO_SET_PROPERTY. See the standard CTO documentation for information on how to use these functions.
In order to make these functions available to the U2 programs, you must put these support routines on the U2 system. This needs to be done only on those systems where you will modify the U2 programs to call these functions. From within U2TCL, you can issue the special command OIDEPLOY. You will be prompted to enter the name of the U2 program file where these should be created. U2TCL will then verify that the file is accessible, copy these routines to the U2 system, compile, and catalog them.
U2RUN
U2RUN allows you to run U2 programs without entering the U2TCL environment. The syntax for using U2RUN is:
U2RUN <OITableNameOfU2File> <ProgramName>
For U2RUN to work, you must have defined (via the OpenInsight Table Manager) a “connection” to the U2 system, and then defined (as accessible in OpenInsight) the file where the desired program resides. U2RUN will use the connection and table information to connect to the U2 system and run the specified program.
“Cataloged” U2 Programs
CTO supports the ability to “catalog” a U2 program so that it can be invoked just by entering the catalog name at CTO TCL. To create a “cataloged” U2 program, you must manually create a record in the MD. Name this MD record whatever you wish to use when invoking the U2 program; field 1 of the record must contain a “U2”, field 2 contains the connection name to the U2 system, and field 3 contains the full statement to run on the U2 system.
Unsupported Functionality
Since the U2 integration features only offer a basic level of U2 emulation, the following functionality is _not_ supported via U2TCL, U2RUN, or cataloged U2 programs:
- U2 pagination is not passed through to the U2TCL routine – for example, routines like LISTF keep going until they’re complete;
- In an associated issue, single-character input is not supported;
- Keystrokes entered in response to prompts from the U2 system may be echoed in the U2TCL environment