OMB*Plus extensibility - defining new command automatically during startup.
There are several ways to extend features of OMB*Plus for development.
OMB*Plus is an TCL interpreter based on
tcljava implementation (look at OWB_HOME\owb\lib\int directory - you will find jacl.jar and tcljava.jar files which are the core of tcljava interpreter).
It is quite simple in Tcl (and in OMB*Plus) add new command - after definition of new procedure you will get new command with the name of just created procedure:
OMB*Plus: Release 10.2.0.3.33
Copyright (c) 2000, 2006, Oracle. All rights reserved.
OMB+> proc MYCOMMAND {txt} {
> return $txt
> }
OMB+> MYCOMMAND "Text from procedure"
Text from procecure
OMB+>
If you have a lot such procedures (and use them extensively) you can include them in single file and execute this file with source command each time you start OMB*Plus.
It is possible to automate this procedure with Tcl
auto_load (search for auto_load or auto_path on wiki.tcl.tk site) feature. When Tcl interpreter cannot find called command withing standard (internal) commands or defined procedures it looks directory from auto_path variable for definitions of this command via tclIndex file (this file contains for each "external" command/procedure reference to file with it definition), run file with definition this command (via source Tcl command) and finally - run requested command.
To enable auto_load feature in OMB*Plus we should make three things:
- create file with definition of new procedure and place this file in selected directory (say to c:\oracle\tcllib)
- create tclIndex file in the same directory
- guide OMB*Plus where look for definitions of new procedures
First task is clear - place our MYCOMMAND procedure in file with name MyProcedure.tcl under c:\oracle\tcllib directory.
Tcl contains standard command auto_mkindex for creation tclIndex file, but tcljava implementation contains bug which prevent using this command. So we will create tclIndex file manualy (the first line is VERY IMPORTANT!):
# Tcl autoload index file, version 2.0
set auto_index(MYCOMMAND) [list source [file join $dir MyProcedure.tcl]]
Now if we add to auto_path variable our directory (MyProcedure) we will get possibility to run commands indexed in tclIndex file:
OMB+> puts $auto_path
resource:/tcl/lang/library
OMB+> info commands MY*
OMB+> MYCOMMAND
invalid command name "MYCOMMAND"
OMB+> lappend auto_path c:/oracle/tcllib
resource:/tcl/lang/library c:/oracle/tcllib
OMB+> puts $auto_path
resource:/tcl/lang/library c:/oracle/tcllib
OMB+> info commands MY*
OMB+> MYCOMMAND "Text to display"
Text to display
OMB+> info commands MY*
MYCOMMAND
OMB+>
And last thing - to set auto_path automatically it is enogh to define new environment variable TCLLIBPATH (the only problem - it seems impossible to define more than one directory via TCLLIBPATH, general method for sepparating paths on Windows OS with semicolon doesn't work for TCLLIBPATH).