home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / IMHAPI10.ZIP / IMHAPI.DOC < prev    next >
Text File  |  1991-12-07  |  39KB  |  828 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.                                  IMHAPI
  12.                                  ======
  13.  
  14.               An EHLLAPI Scripting and Development Utility
  15.  
  16.  
  17.  
  18.                               Version 1.0
  19.                               -----------
  20.  
  21.  
  22.  
  23.                         Reference Documentation
  24.                         -----------------------
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.                               Paul Firgens
  42.                           461 Glenwood Heights
  43.                   Wisconsin Rapids, WI  54494-6264  USA
  44.                      CompuServe User ID: 73577,1234
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.         Copyright (c) 1991, Paul Firgens.  All Rights Reserved.
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                               Please Note!
  63.                               ============
  64.  
  65. IMHAPI and accompanying files are offered without charge to the OS/2
  66. user community.  While no payment is required for the use of the
  67. programs contained in this document set, if you find them useful, a gift
  68. of any amount (perhaps proportional to the value IMHAPI provides you or
  69. your organization) would be appreciated.  That would help defray the
  70. cost of developing these programs and help provide the means to develop
  71. additional programs.  Regardless of your financial support, however, I
  72. would appreciate your comments, questions and reactions to these
  73. programs.  It would be a pleasure to hear from you.  Please direct your
  74. comments and, if justified by the usefulness of these programs, your
  75. financial gift, to the author at the address on the title page.
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94.  
  95.                              A  DISCLAIMER
  96.                              =============
  97.  
  98.           As is usual in these things, you must know that IMHAPI and all
  99.              programs and documentation included with it are provided on
  100.               an "AS IS" basis and with no warrantee or guarantee of any
  101.             kind, expressed or implied. Furthermore, there are no claims
  102.                      that IMHAPI and accompanying programs are fit for a
  103.                   particular purpose.  As a user of these materials, you
  104.                assume complete risk for the use and performance of these
  105.                  programs and documentation, including any incidental or
  106.                   consequential damages which may result from their use.
  107.       Finally, there is no warrantee that these programs are error free,
  108.                nor is there any assurance that these programs will bring
  109.                             whiter whites or prevent ugly, waxy buildup.
  110.  
  111.                                    P.S.  For your information, OS/2 is a
  112.                trademark of International Business Machines Corporation.
  113.  
  114. So, with that said, on to IMHAPI!
  115.  
  116.  
  117.  
  118.  
  119.                               INTRODUCTION
  120.                               ============
  121.  
  122.  
  123. IMHAPI, I(nteractively) M(anipulate) (e)H(ll)API, is a program which
  124. allows a user of IBM's OS/2 Communications Manager to issue EHLLAPI
  125. commands without the need for other programming.  IMHAPI provides a
  126. basic scripting framework for interacting with EHLLAPI and OS/2 host
  127. terminal emulation sessions.
  128.  
  129. Some of the features of IMHAPI are:
  130.  
  131.     - Commands can be accepted from any of three different sources:
  132.     interactively from a windowed or full-screen OS/2 session, from a
  133.     file or from a named pipe.
  134.  
  135.     - Protected or hidden data strings (for holding sensitive data
  136.     such as passwords, etc.) can be included in input commands.
  137.  
  138.     - Ability to pause an IMHAPI script for a period of time, which is
  139.     expressible in many different ways: as a specific date and/or time,
  140.     as a certain number of hours, minutes or seconds, or as a number of
  141.     milliseconds.
  142.  
  143.     - Commands can be echoed to the console, to help trace the execution
  144.     of those commands.
  145.  
  146.     - Optional File Logging of all commands entered, for later playback
  147.     or debugging.
  148.  
  149.     - Optional Automatic waits for mainframe responses.
  150.  
  151.     - Optional hold of EHLLAPI commands until specified strings are
  152.     found on a connected host terminal session.
  153.  
  154.     - Automatic calculation of some EHLLAPI parameter details such as
  155.     data strings and lengths.
  156.  
  157. This document outlines the operation of the IMHAPI program.  It doesn't
  158. attempt to provide a discussion of the EHLLAPI commands and their usage.
  159. I presume that a user of IMHAPI will understand EHLLAPI or at least have
  160. access to a manual on EHLLAPI (or HLLAPI, which is a large subset of
  161. EHLLAPI).  The most current IBM manual on EHLLAPI that I am aware of is
  162. the "IBM Operating System/2 Extended Edition Version 1.3 EHLLAPI
  163. Reference Manual".  If there is a need for more information on these
  164. commands, please let me know.  If there is a large demand, I could
  165. include an overview of the topic.
  166.  
  167. IMHAPI requires OS/2 version 1.3 Communications Manager to operate.
  168.  
  169.  
  170.  
  171.  
  172.                                BACKGROUND
  173.                                ==========
  174.  
  175. EHLLAPI is the interface that provides services for manipulating host
  176. terminal sessions connected to the OS/2 Communications Manager.  EHLLAPI
  177. is an acronym for Enhanced High Level Language Applications Programming
  178. Interface and has, in an "un-Enhanced" form, been around a long time in
  179. the DOS-based host terminal emulation products offered by IBM.
  180.  
  181. Through EHLLAPI, a program can control various aspects of a terminal
  182. session.  A program can issue keystrokes against a session, check for
  183. specific responses, copy strings into a session as well as copy from a
  184. session and transfer files to or from a mainframe, for example.  It is
  185. useful for providing a measure of programmatic interaction between a PC
  186. and a mainframe.  For example, it can be used to automate logon
  187. procedures or as a means of obtaining mainframe-based data for a PC
  188. application.
  189.  
  190. EHLLAPI essentially allows a program to simulate the keystroke
  191. interactions that a mainframe session would receive if a person were
  192. controlling that session.  While EHLLAPI does have its limitations, it
  193. works well for many things.  EHLLAPI works well for straightforward
  194. tasks such as automating file transfers or user logons, for example.
  195. IMHAPI was written to help develop these kinds of EHLLAPI sessions and
  196. make EHLLAPI easier to use and more accessible.
  197.  
  198. The DOS predecessor for IMHAPI was written to create HLLAPI (the DOS
  199. counterpart to EHLLAPI) scripts without the overhead of having to write
  200. programs in a standard language, like C.  When I got hooked on OS/2, I
  201. took that DOS program, spruced it up considerably and IMHAPI is the
  202. result.
  203.  
  204.  
  205.  
  206.  
  207.                          INTRODUCTION TO IMHAPI
  208.                          ======================
  209.  
  210. The basic concept behind IMHAPI is to issue EHLLAPI commands to manage
  211. host terminal sessions, but that alone is insufficient to accomplish
  212. much beyond demonstrating how EHLLAPI works, since there are other
  213. considerations which must be addressed to have something useful.  These
  214. considerations run from dealing with the particular format of the
  215. various EHLLAPI commands to allowing for mainframe response times, etc.
  216. IMHAPI attempts to address many of these concerns through its options
  217. and extensions.
  218.  
  219. IMHAPI will accept commands from any of three different sources.  If
  220. started with no command line parameters, IMHAPI will begin an
  221. interactive session, prompting for commands from the user.  If started
  222. with an argument in the format of a named pipe  (i.e.:
  223. '\pipe\<pipename>'), IMHAPI will attempt to connect to that pipe,
  224. accepting commands from and sending its results out through that pipe.
  225. If IMHAPI is started with anything else on the command line, it will
  226. assume the argument is a file name and will try to open the file and
  227. then read and process commands from that file.
  228.  
  229. The IMHAPI command format is line-oriented; IMHAPI expects one command
  230. per line.  It doesn't provide for continuing commands across lines or
  231. for stacking multiple commands on a single line.  The maximum length of
  232. a single command is 255 characters, however.  IMHAPI also expects a
  233. command to begin in the first column of the input line and will ignore
  234. any command which doesn't begin there. Comment lines in IMHAPI scripts
  235. are begun with an asterisk ('*').
  236.  
  237. IMHAPI commands themselves are of two different types.  There are
  238. commands that are directed toward EHLLAPI and commands intended for
  239. IMHAPI itself.
  240.  
  241. In and of itself, IMHAPI can accomplish quite a lot.  It can help create
  242. and execute straightforward EHLLAPI interactions, including login and
  243. file transfer sessions.  However, IMHAPI is not a "complete" scripting
  244. language in the sense of including many of the features usually expected
  245. in a language (variable declarations, control flow structures, etc.).  I
  246. didn't want to add to the language clutter of the world.  I thought that
  247. most users of IMHAPI were looking for a means of simplifying their
  248. dealings with EHLLAPI and would otherwise probably prefer to work with
  249. the languages they knew best.
  250.  
  251. Because of this, IMHAPI concentrates on those features that seemed most
  252. relevant to EHLLAPI issues; if the controls provided by a programming
  253. environment are needed, IMHAPI can be integrated through a named pipe
  254. connected to the best tool for the non-EHLLAPI end of the task.  With a
  255. named pipe connection between a user-written program and IMHAPI, a great
  256. deal of the work of directing EHLLAPI can be handled by IMHAPI, while
  257. the other control requirements can be handled with the appropriate
  258. language.  Named pipe connections are discussed in more detail below.
  259.  
  260.  
  261.  
  262.  
  263.                         EHLLAPI-Related Commands
  264.                         ========================
  265.  
  266. The IMHAPI commands intended for EHLLAPI closely follow the form
  267. expected by EHLLAPI itself, with one IMHAPI extension.  Each of the
  268. EHLLAPI-bound commands can have five parameters: FUNCTION_CODE,
  269. DATA_STRING, DATA_STRING_LENGTH, PRESENTATION_SPACE_PARAMETER and, the
  270. IMHAPI extension, WAIT_STRING.
  271.  
  272.  
  273.     FUNCTION_CODE Parameter
  274.     -----------------------
  275.     is the EHLLAPI function code number or the name of the function
  276.     code.  The function code invokes the requested EHLLAPI service.  For
  277.     example, to send keystrokes to a terminal session, the IMHAPI
  278.     command would use FUNCTION_CODE 3.  Alias names are also accepted
  279.     for the numeric codes.  These names follow the convention used in
  280.     the HAPI_C.H header file installed as part of Communications
  281.     Manager.  (Usually, this file is placed in the C:\CMLIB
  282.     subdirectory.)  The names accepted by IMHAPI are the same as those
  283.     in that file, with the "HA_" suffix removed.  The chart below shows
  284.     the correspondence between the EHLLAPI function codes and the names.
  285.  
  286.           CONNECT_PS..............1  STOP_HOST_NOTIFY.......25
  287.           DISCONNECT_PS...........2  SEARCH_FIELD...........30
  288.           SENDKEY.................3  FIND_FIELD_POS.........31
  289.           WAIT....................4  FIND_FIELD_LEN.........32
  290.           COPY_PS.................5  COPY_STR_TO_FIELD......33
  291.           SEARCH_PS...............6  COPY_FIELD_TO_STR......34
  292.           QUERY_CURSOR_LOC........7  SET_CURSOR.............40
  293.           COPY_PS_TO_STR..........8  START_CLOSE_INTERCEPT..41
  294.           SET_SESSION_PARMS.......9  QUERY_CLOSE_INTERCEPT..42
  295.           QUERY_SESSIONS.........10  STOP_CLOSE_INTERCEPT...43
  296.           RESERVE................11  START_KEY_INTERCEPT....50
  297.           RELEASE................12  GET_KEY................51
  298.           COPY_OIA...............13  POST_INTERCEPT_STATUS..52
  299.           QUERY_FIELD_ATTR.......14  STOP_KEY_INTERCEPT.....53
  300.           COPY_STR_TO_PS.........15  SEND_FILE..............90
  301.           STORAGE_MGR............17  RECEIVE_FILE...........91
  302.           PAUSE..................18  CONVERT_POS_ROW_COL....99
  303.           QUERY_SYSTEM...........20  CONNECT_PM_SRVCS......101
  304.           RESET_SYSTEM...........21  DISCONNECT_PM_SRVCS...102
  305.           QUERY_SESSION_STATUS...22  QUERY_WINDOW_COORDS...103
  306.           START_HOST_NOTIFY......23  PM_WINDOW_STATUS......104
  307.           QUERY_HOST_UPDATE......24  CHANGE_SWITCH_NAME....105
  308.                        CHANGE_WINDOW_NAME....106
  309.  
  310.     IMHAPI will accept the numeral 3 and SENDKEY interchangeably as a
  311.     valid FUNCTION_CODE, for example.  These alias names can be entered
  312.     in IMHAPI commands in upper, lower or mixed case.
  313.  
  314.     FUNCTION_CODE is the only parameter of the five EHLLAPI-bound
  315.     commands that is required.  The others may or may not be required
  316.     depending on the FUNCTION_CODE itself.  If there are an insufficient
  317.     number of parameters supplied for a command, IMHAPI will complain
  318.     and issue an error message.
  319.  
  320.  
  321.     DATA_STRING Parameter
  322.     ---------------------
  323.     is used to pass data to EHLLAPI as required by the specific
  324.     FUNCTION_CODE used.  What EHLLAPI requires in this parameter and
  325.     even if this parameter needed is dependent on the FUNCTION_CODE
  326.     preceding it.  The format of the data itself must follow whatever
  327.     EHLLAPI conventions are set for the function code used, except for
  328.     the IMHAPI extensions discussed below.
  329.  
  330.         EXAMPLE:  For the SENDKEY function (code 3), the DATA_STRING
  331.         parameter holds the characters which are to be sent to the
  332.         connected host terminal session.  Specifically, the IMHAPI
  333.         command "3 TSO@E" would invoke the EHLLAPI SENDKEY function and
  334.         pass it the DATA_STRING parameter 'TSO@E' to simulate a user
  335.         typing the letters 'T' 'S' 'O' followed by a poke of the 'ENTER'
  336.         key (the '@E' symbol).
  337.  
  338.     Usually, IMHAPI uses spaces for delimiting its command parameters.
  339.     When spaces must be imbedded in the DATA_STRING parameter, the start
  340.     and end of the entire parameter can be marked with double quotes to
  341.     have IMHAPI pass the entire string, blanks and all, to EHLLAPI.
  342.  
  343.         EXAMPLE:  To extend the example above, if the user wished to
  344.         include her user-id on the command line along with the request
  345.         for TSO, she might use '3 "TSO userid@E" ' to send the entire
  346.         string 'TSO userid' (and the "hit" of the ENTER key) to EHLLAPI.
  347.  
  348.     The double quote delimiter can be changed so that it too could be
  349.     included as a character in a data string.  How that is accomplished
  350.     is discussed below under the "-D" IMHAPI command.
  351.  
  352.     ** SPECIAL DATA STRINGS **
  353.  
  354.     There are a couple of specific types of strings which get special
  355.     treatment by IMHAPI.  The first the is symbol $INP$ (in capital
  356.     letters).  It is a "placeholder" to mark where a previously
  357.     established protected string is to be inserted.  The "-P" option
  358.     (see below) prompts the user to type in a string which will be
  359.     hidden and not displayed in the OS/2 session.  Then, when placed in
  360.     a DATA_STRING parameter, the $INP$ symbol causes IMHAPI to replace
  361.     the $INP$ symbol with the protected string at that point in the
  362.     parameter.  IMHAPI will adjust the length of the DATA_STRING
  363.     parameter to accommodate the protected parameter.  Only one hidden
  364.     parameter is available at any given time, although it can be used as
  365.     often as needed (it isn't discarded after it's used) and it also can
  366.     be reset (with "-P") as often as needed.  If $INP$ is used before a
  367.     parameter is assigned, no string will be inserted into the
  368.     EHLLAPI-bound data string.
  369.  
  370.         EXAMPLE:  Assume the -P option was used, the protected
  371.         parameter was set to 'MyPazWrd' and IMHAPI was given the
  372.         DATA_STRING '3 Userid $INP$@E'.  IMHAPI would replace '$INP$'
  373.         with 'MyPazWrd' and send '3 Userid  MyPazWrd@E' off to EHLLAPI.
  374.  
  375.     The second set of special strings allows a user to enter binary
  376.     values into the DATA_STREAM.  The EHLLAPI functions which control
  377.     the terminal windows (function numbers 101-106) often require binary
  378.     parameters.  To include these in a DATA_STRING, IMHAPI provides a
  379.     means to enter these binary parameters as hexadecimal numerals.  The
  380.     hexadecimal value is included in the DATA_STRING and preceded by a
  381.     flag to indicate the type of binary number to which it is to be
  382.     converted and ended with a '\'.  These qualifiers delimit a string
  383.     of hexadecimal digits as a particular type of binary number: '\c'
  384.     indicates a CHAR sized number, '\s' is a SHORT integer and '\l' is a
  385.     LONG integer.  IMHAPI creates signed binary values of the requested
  386.     length for these strings; '\c2\' would be converted to x'02',
  387.     '\s1000\' to x'1000' and \l1000\ to x'00001000'.  IMHAPI converts
  388.     all the hexadecimal digits it finds following these escape
  389.     sequences, up to the backslash character, '\'.
  390.  
  391.         EXAMPLE: To maximize the size of a terminal window, function
  392.         code 104 (PM_WINDOW_STATUS) is used.  EHLLAPI expects the data
  393.         string to include the short window name, a CHAR sized option
  394.         and, at least, a SHORT sized option.  IMHAPI would expect to see
  395.         a command like the following: '104 a\c1\\s800\' which would create
  396.         a data string for EHLLAPI containing 'a' as the short session
  397.         name followed by a x'01' and a x'0800'.  Please see Appendix B
  398.         for a list of these values and the actions they invoke.
  399.  
  400.  
  401.     DATA_STRING_LENGTH Parameter
  402.     ----------------------------
  403.     is often required by EHLLAPI.  IMHAPI will automatically calculate
  404.     this length, if not included as part of the command.  If it is
  405.     needed, length can also be explicitly entered.
  406.  
  407.         EXAMPLE:  The IMHAPI EHLLAPI command "3 LongString 4" would have
  408.         IMHAPI to send the four characters 'Long' to the connected
  409.         EHLLAPI session.  If the length value was left off or a '*' was
  410.         substituted for it, IMHAPI would pass EHLLAPI the length of the
  411.         full string, and EHLLAPI would, in turn, send the entire string
  412.         'LongString' to the terminal session.
  413.         
  414.     Some EHLLAPI commands require a "Presentation Space Parameter" (the
  415.     fourth parameter in the IMHAPI input string). In these cases, IMHAPI
  416.     will automatically calculate the data string length if an asterisk
  417.     ('*') is entered as the length parameter (and also pass along the
  418.     explicit PSP parameter).  So, in the case of a command such as
  419.     COPY_PS_TO_STRING (FUNCTION_CODE 8) leaving the length value to
  420.     default will have EHLLAPI pass back only the length of the
  421.     DATA_STRING itself.
  422.  
  423.         EXAMPLE: If IMHAPI is passed the command "8 * * 500", EHLLAPI
  424.         will pass back only the one character found at position 500.
  425.         More characters can be returned if EHLLAPI is given a longer
  426.         length.  If the command to IMHAPI is "8 * 4096 1", IMHAPI will
  427.         tell EHLLAPI to pass back the 4096 characters in the
  428.         presentation space beginning at screen position 1.
  429.  
  430.    PLEASE NOTE:  The maximum data string length IMHAPI can handle is
  431.    4096 bytes!
  432.  
  433.  
  434.     PRESENTATION_SPACE_PARAMETER
  435.     ----------------------------
  436.     is occasionally used for passing a parameter to EHLLAPI.  (EHLLAPI
  437.     usually uses this area for returning error codes.)  If required, it
  438.     can be included in the IMHAPI command.  An asterisk can be used as a
  439.     "place holder" if no PRESENTATION_SPACE_PARAMETER is explicitly
  440.     required for EHLLAPI but needed to provide IMHAPI a fifth parameter.
  441.     The PRESENTATION_SPACE_PARAMETER defaults to zero, if no numeric
  442.     parameter is included in an IMHAPI command.
  443.  
  444.  
  445.     WAIT_STRING Parameter
  446.     ---------------------
  447.     is a data string which IMHAPI will wait to find in the currently
  448.     connected presentation space PRIOR to sending the preceding four
  449.     parameters off to EHLLAPI.  If this parameter is included in a
  450.     command, the parameters preceding it will be sent on to EHLLAPI ONLY
  451.     after IMHAPI locates this WAIT_STRING parameter in the currently
  452.     connected terminal window.  The WAIT_STRING parameter is delimited
  453.     by the same character as the DATA_STRING parameter (as discussed
  454.     above and changed with the -D option) but it does not support the
  455.     Special Data Strings documented in the DATA_STRING section.  The
  456.     WAIT_STRING parameter useful in situations where the only reliable
  457.     means of judging that a script can continue is by the appearance of
  458.     a particular phrase in the connected window.
  459.  
  460.     CICS, for example, is notorious for unlocking the display and
  461.     keyboard after a transaction is begun, even though no response has
  462.     been supplied.  The WAIT_STRING feature helps address these kinds of
  463.     situations, without the need for programmed loops or long pauses. If
  464.     needed, the wait invoked with this parameter can be ended by poking
  465.     the ESC key; IMHAPI then sends off the command preceding the
  466.     WAIT_STRING.  IMHAPI will not wait and search for a default string
  467.     if this parameter is not included.
  468.  
  469.         EXAMPLE:   The IMHAPI command "3 userid@E * * OIDCARD" would
  470.         pause and wait UNTIL the string "OIDCARD" appeared in the
  471.         terminal window BEFORE proceeding to send the SENDKEY command
  472.         (function code 3) and DATA_STRING off to EHLLAPI.
  473.  
  474.  
  475.  
  476.  
  477.                             IMHAPI Commands
  478.                             ===============
  479.  
  480. There are several commands which control the operation of IHMAPI itself.
  481. All of these options can be entered from any of the input sources
  482. (keyboard, file or pipe) although several of them are disabled when they
  483. fed to IMHAPI from a file or a pipe.  The commands can be entered in
  484. either upper or lower case and can be intermixed among EHLLAPI-bound
  485. commands.
  486.  
  487.   COMMANDS
  488.   --------
  489.  
  490.  
  491.     -A    Toggle AutoWait on or off.  When on, the AutoWait option
  492.           automatically issues a EHLLAPI "WAIT" command after it
  493.           completes a command.  The EHLLAPI "WAIT" command tells EHLLAPI
  494.           not to return control until the keyboard is unlocked and the
  495.           "clock" or "X" in the lower left-hand corner of the terminal
  496.           screen has disappeared.
  497.  
  498.  
  499.     -B    Blank (clear) the IMHAPI screen.  This option is disabled for
  500.           non-interactive sessions (where the command source is a named
  501.           pipe or a file).
  502.  
  503.  
  504.     -C    List the EHLLAPI text commands and equivalent function codes.
  505.           This will display a table of the EHLLAPI function codes and
  506.           the corresponding alias names.  It is disabled for use with
  507.           named pipes.
  508.  
  509.  
  510.     -Dx   Change the data delimiter to the character immediately
  511.           following the '-D' (here, the 'x').  The default delimiter is a
  512.           double quote '"' (as mentioned above) but can be changed with
  513.           this command.  There is no space between the option code
  514.           and the new delimiter character.  Entry of a "-D" without any
  515.           following character (including a space), will display the
  516.           current delimiter.
  517.  
  518.  
  519.     -E    Toggle Command Echo on or off.  When on, this option will have
  520.           IMHAPI echo each of the input commands and comment lines
  521.           (those which begin with an asterisk) to the terminal display.
  522.           This is useful for debugging scripts as it will trace the
  523.           actions EHLLAPI performs in response to each IMHAPI command.
  524.           This option is unavailable for input from named pipes.
  525.  
  526.  
  527.     -L <filename>   Log IMHAPI commands to a file called <filename>.  If
  528.           no name is supplied, the default name is IMHAPI.HAP.  When on,
  529.           IMHAPI will record all the valid commands (those that make it
  530.           past IMHAPI's editing) and comment lines (those with an
  531.           asterisk in column 1) into the Log file.  This can allow a
  532.           user to build IMHAPI scripts for later execution or further
  533.           editing.  The Log file is automatically closed when a user
  534.           exits from IMHAPI.  It can also be closed by issuing the "-L"
  535.           option when logging is already on.  If a new file name is
  536.           included, the previous file will be closed and a new one
  537.           opened.  If no new name is included, the current file is
  538.           closed and no new one opened. IMHAPI expects a space between
  539.           the option code (the "-L") and the name of the log file.
  540.  
  541.           A user can run IMHAPI interactively, turn the Log option on,
  542.           issue appropriate EHLLAPI commands to manipulate a terminal
  543.           session and watch the terminal window for responses and
  544.           required entries while recording the appropriate commands in a
  545.           file.  This can save time over manually recording keystroke
  546.           sequences and help reduce mistakes.  Since insuring that every
  547.           particular keystroke or option needed to perform a particular
  548.           action is accounted for in an EHLLAPI program can be a tedious
  549.           process, interactive IMHAPI logging commands to a file, can
  550.           help relieve some of that tedium.
  551.  
  552.  
  553.     -P    Prompt for a protected (invisible) parameter.  As discussed
  554.           previously, IMHAPI allows for a symbol for a hidden parameter,
  555.           $INP$.  This option supplies the value for that symbol.  When
  556.           this option is issued, IMHAPI will pause and issue a message
  557.           to the user asking for a input string.  IMHAPI will record the
  558.           user's keystrokes until she or he hits the "Enter" key.  The
  559.           area he or she types into will not display the string on the
  560.           screen.  IMHAPI allows up to 255 characters in this protected
  561.           parameter string.
  562.  
  563.  
  564.     -S    Show current IMHAPI options status including available
  565.           terminal sessions.  This option displays the settings for the
  566.           data string delimiter and the log file.  It shows if command
  567.           Echo and AutoWait are on or off.  It also shows the status of
  568.           the connected terminal sessions: their short and long names
  569.           plus the sizes of their respective presentation spaces.
  570.  
  571.  
  572.     -V    Display the IMHAPI version release level.
  573.  
  574.  
  575.     -W "time value"   Have IMHAPI wait until the indicated time value
  576.           before continuing to execute commands.  This option is
  577.           supported for command input from any source.  The "time" value
  578.           can be in any of the following formats:
  579.  
  580.           FORMAT
  581.           ------
  582.  
  583.           HH:MM:SS   A specific time entered as Hours (HH) Minutes (MM)
  584.                      and Seconds (SS) values, separated by colons and
  585.                      based on a 24-hour clock (i.e.: 14:00 is 2:00 PM).
  586.                      IMHAPI will wait until the next occurrence of the
  587.                      indicated time before resuming execution.  The
  588.                      seconds value is optional and each value must
  589.                      include a leading zero, if it would otherwise be a
  590.                      single digit (05:02 is OK but 5:2 is not).  Example:
  591.                      "-w 21:05:30" would cause a wait until the next
  592.                      9:05:30 PM.
  593.  
  594.           xxHxxMxxS  An elapsed time value where 'xx' is the number of
  595.                      hours, minutes or seconds (the 'H', 'M', and 'S'
  596.                      respectively of the format) that are to pass before
  597.                      IMHAPI will resume execution.  Each value must be 2
  598.                      digits long, so that a zero must precede a single
  599.                      digit number.  The seconds value is optional.
  600.                      Example: "-w 21h05m30s" would have IMHAPI wait for
  601.                      21 hours, 5 minutes and 30 seconds before
  602.                      continuing.
  603.  
  604.           MM/DD/YYYY <HH:MM:SS>  A specific date and, optional, time for
  605.                      IMHAPI to resume execution.  The date value
  606.                      includes the month, day and year (the 'MM', 'DD',
  607.                      'YYYY' places respectively of the format) when
  608.                      IMHAPI will continue, separated by backslashes.
  609.                      Again, the month and day values must be preceded by
  610.                      a zero if they would otherwise be only a single
  611.                      digit.  The year value must be in the four digit
  612.                      format (ie: 1991).  IMHAPI will check for a valid
  613.                      date, including leap years, and will continue
  614.                      immediately if that date has passed.  The time
  615.                      value follows the guidelines previously mentioned.
  616.                      Example: "-w 02/29/1996 07:28:45" would have IMHAPI
  617.                      wait until Feb. 29, 1996 at 7:28:45 AM before
  618.                      continuing.
  619.  
  620.            mmmmmmmm  A number of milliseconds ('m') that IMHAPI is to
  621.                      wait before resuming execution.  The maximum wait
  622.                      value for this format is the maximum value for an
  623.                      unsigned long integer: 4,294,967,295 (about 49.7
  624.                      days).  This parameter does not require leading
  625.                      zeros.  Example: "-w 300" would have IMHAPI wait
  626.                      300 milliseconds before continuing.
  627.  
  628.  
  629.     ?     Displays on-line help information.  Not supported for named
  630.           pipe connections.
  631.  
  632.  
  633.     EXIT  Quit the IMHAPI program.
  634.  
  635.  
  636.  
  637. Named Pipe Support
  638. ------------------
  639.  
  640. IMHAPI supports a connection to a named pipe, but expects the connection
  641. to be in duplex mode (supporting both reads and writes).  The collection
  642. of files included with this document include two sample programs that
  643. demonstrate the use of IMHAPI with named pipes.  These programs are
  644. SAMPLIPE and REXXHAPI.  SAMPLIPE creates a named pipe and starts IMHAPI
  645. running in the background.  IMHAPI commands can be sent to IMHAPI from a
  646. command-line prompt and the results are displayed on the screen.  This
  647. is useful for demonstrating how IMHAPI works with named pipes and
  648. showing the results IMHAPI returns through a pipe.
  649.  
  650. As an example of integrating IMHAPI into a programming environment
  651. (REXX), I've included REXXHAPI which is a DLL which containing two REXX
  652. external functions, MkHaPipe and ToHapi.  MkHaPipe creates a named pipe,
  653. starts IMHAPI as a background task and passes back to REXX the handle
  654. number of the pipe it created.  ToHapi uses that pipe handle to connect
  655. with IMHAPI, passing along an IMHAPI command string.  ToHapi passes back
  656. to the REXX program the results it gets from IMHAPI via the pipe.  With
  657. these DLL functions, IMHAPI can be immediately used with REXX.  The
  658. source code for these programs is included in this document set and
  659. contains more information on how these programs can be used.  A sample
  660. REXX program using these functions is also included.
  661.  
  662. IMHAPI is sensitive to the source of its commands and modifies its
  663. behavior slightly depending on assumptions about who or what will be
  664. receiving the returned data.  It expects that a named pipe would be
  665. connected to another program, an interactive session to a user at a
  666. terminal and a file may likely not be attended at all.   Because of
  667. this, it doesn't expect that a program connected to IMHAPI through a
  668. named pipe would want access to options which invoke help screens or
  669. clear the display, for example.  Appendix A discusses IMHAPI messages
  670. and named pipes in more detail.
  671.  
  672.  
  673. In Conclusion
  674. -------------
  675.  
  676. That's IMHAPI.  Thanks for taking a look at IMHAPI and I hope it might
  677. be of some use to you.  Please do pass your comments, questions,
  678. problems, etc. on to me (the author) at the address below.   Thanks and
  679. may u b HAPI too!
  680.  
  681.                      Paul Firgens
  682.                      461 Glenwood Heights
  683.                      Wisconsin Rapids, WI  54494-6264  USA
  684.                      CompuServe User ID: 73577,1234
  685.  
  686.  
  687.  
  688.  
  689.  
  690.  
  691.  
  692.  
  693.                             
  694.                       Appendix A: IMHAPI Messages
  695.                       ===========================
  696.  
  697. As mentioned above, IMHAPI is aware of the source of its commands and
  698. makes an attempt to adjust the style of the output to the "audience".
  699. IMHAPI is less wordy when its command source is a named pipe, since the
  700. assumption is that IMHAPI is connected to a process.  When the command
  701. source is a file, nothing is written back into the source of the
  702. commands (that could clobber the file that contains the IMHAPI
  703. commands), but the results of the commands are echoed back to the
  704. screen.  These could, of course be re-directed into a file for later
  705. review.  When run interactively, IMHAPI assumes a human user is
  706. controlling the process and tailors its output accordingly by providing
  707. some on-line help, some messages in complete sentences and a couple of
  708. additional options.  IMHAPI does provide the same message content to all
  709. of the environments to which it directs its output.
  710.  
  711. Almost all of the IMHAPI-related option messages returned to a named
  712. pipe connection (from options such as -w, -e, etc.) all follow a similar
  713. format.  There is an unique eight character message code followed by a
  714. brief explanatory sentence.  These codes are listed in the chart below:
  715.  
  716. AUTOWOFF: AutoWait is now OFF.
  717. AUTOWSON: AutoWait is now ON.
  718. AWAITERR: Autowait ERROR, Application Not Connected to a Valid Session
  719. AWAITERR: Autowait ERROR, Wait Timeout While in XCLOCK or XSYSTEM
  720. AWAITERR: Autowait ERROR, Keyboard is locked
  721. AWAITERR: Autowait ERROR, A System Error Occurred
  722. AWAITERR: Autowait ERROR, An Unknown Error Occurred
  723. CMDNTAVL: Command <input command> not supported for piped output.
  724. ECHOCOMD: Input Command: <input command>
  725. ECHOISON: Echo is now ON.
  726. ECHOSOFF: Echo is now OFF.
  727. INSFPARM: Insufficient number of parameters included in command.
  728. INVALCMD: Unknown Command - <input command>
  729. INVDELIM: No valid delimiter character supplied.  Delimiter remains: <char>
  730. INVLDATE: Invalid date parameter.
  731. INVLGOPN: Can't open <file name>
  732. INVLTIME: Invalid time parameter.
  733. INVLWAIT: The wait value is invalid: <input time value>
  734. LOGFLCLO: Log file now closed.
  735. NOECHOAV: Command -e not supported for piped output.
  736. NOWAITPA: No wait parameter supplied.
  737. OPNERROR: Can't open <file name>.  OS/2 error code: <OS/2 Error Code>
  738. OPTNSERR: -S option returned a non-zero Query_Sessions rc: <EHLLAPI Error Code>
  739. READFAIL: Read failure on input file.  OS/2 error code: <OS/2 Error Code>.
  740. UNAVLOPT: Unused option code: <input option code>
  741. VALDELIM: Data string delimiter now set to: '<char>' (Hex value: <hex value>)
  742. VALOGOPN: Commands being logged to file <log file name>
  743.  
  744. The angle brackets ('<' and '>') indicate where a particular value or other
  745. parameter is included in the message.
  746.  
  747. For named pipe connections, there are three exceptions to this format.
  748. One is on the -WAIT option.  In this case, IMHAPI returns the time and
  749. date (at the beginning of the return message) when it resumes, as in the
  750. example below:
  751.  
  752.                  HH:MM:SS.hhh MM/DD/YYYY IMHAPI Resumes
  753.  
  754. The second named pipe exception is for the -STATUS option.  In this
  755. case, IMHAPI returns the same message text an interactive user would
  756. receive.  IMHAPI reports the settings for the various options and the
  757. status of the connected host sessions.  Finally, IMHAPI returns the
  758. message "OK" for comment lines piped to it.
  759.  
  760. Most of the messages reported for other command sources follow this same
  761. format.  A couple of them tend to be less terse or formal; however, the
  762. information content is no different from the other formats.
  763.  
  764. Finally, for information returned from EHLLAPI-bound commands, IMHAPI
  765. returns EHLLAPI's response in the following order:
  766.  
  767.         1. PRESENTATION_SPACE_PARAMETER (which is where EHLLAPI
  768.            puts its return code).
  769.         2. DATA_STRING_LENGTH parameter.
  770.         3  DATA_STRING returned from EHLLAPI.
  771.  
  772. When run interactively or with file input, IMHAPI only displays those
  773. parameters that have been set or changed by EHLLAPI.  IMHAPI returns ALL
  774. parameters when connected to a named pipe, including those that were not
  775. modified by EHLLAPI.  The first two parameters are always returned as
  776. printable ASCII characters (not binary values) and, when delivered into
  777. a named pipe, are separated from one another by a single space.
  778.  
  779.  
  780.  
  781.                  Appendix B: EHLLAPI Binary Parameters
  782.                  =====================================
  783.  
  784. Some of the terminal window manipulation functions of EHLLAPI require
  785. binary parameters.  IMHAPI can create these binary parameters for
  786. EHLLAPI from the hexadecimal numerals entered in the
  787. DATA_STRING_PARAMETER.  Function 104 (PM_WINDOW_STATUS) uses these
  788. parameters extensively, for example.  The function uses a SET or
  789. QUERY option to control its action;  the hexadecimal value for the SET
  790. option is '\c1\' and the value for the QUERY option is '\c2'.  The
  791. respective hexadecimal parameters and values for function 104 window
  792. flags are:
  793.  
  794.               Window Flag         Equivalent IMHAPI values
  795.               -----------         -----------------------
  796.                SWP_SIZE                   \s0001\
  797.                SWP_MOVE                   \s0002\
  798.                SWP_ZORDER                 \s0004\
  799.                SWP_SHOW                   \s0008\
  800.                SWP_HIDE                   \s0010\
  801.                SWP_NOREDRAW               \s0020\
  802.                SWP_NOADJUST               \s0040\
  803.                SWP_ACTIVATE               \s0080\
  804.                SWP_DEACTIVATE             \s0100\
  805.                SWP_MINIMIZE               \s0400\
  806.                SWP_MAXIMIZE               \s0800\
  807.                SWP_RESTORE                \s1000\
  808.                SWP_DEACTIVATE             \s0080\
  809.  
  810. Some of these options can be ORed together to create multiple actions.
  811. For example, combining RESTORE ('\s1000\') with ACTIVATE ('\s0080\') for
  812. the value '\s1080\' will make the connected terminal window the front
  813. and active window.
  814.  
  815. The positioning and sizing parameters for function 104 will only be
  816. recognized if the corresponding window flag is selected.  To set a
  817. window's size, SWP_SIZE ('\s0001\') must be selected and to move a
  818. window, SWP_MOVE ('\s0002\') must be used.
  819.  
  820. The relative window placement values are HWND_TOP ('\l0003\') and
  821. HWND_BOTTOM ('\l0004\').  These are only accepted if SWP_ZORDER
  822. ('\s0004\') is set in the window flag parameter.
  823.  
  824. Finally, the leading zeros on all of these hex values are optional:
  825. IMHAPI considers '\s4\' the same as '\s0004\'.
  826.  
  827.  
  828.