home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / diags / pandor23.zip / PANDORA.DOC < prev    next >
Text File  |  1992-01-03  |  47KB  |  1,069 lines

  1.                              User Guide to Pandora
  2.  
  3.                                 For version 2.3
  4.  
  5.                       Pete Maclean [75776,660 on CompuServe]
  6.                            Copyright 1991 Pete Maclean.
  7.  
  8.  
  9.  
  10. This document comprises a introduction to Pandora plus a summary of what is new 
  11. in version 2.x.  As a user manual, it is not intended to substitute for my 
  12. original article describing the program, then called PAN, that was published in 
  13. PC Magazine (Volume 9, Number 9, May 15 1990).
  14.  
  15. Pandora is a scripting program for automating the operation of other programs.  
  16. To make use of Pandora it is necessary to do a little programming in Pandora's 
  17. script langauge.  Commands are provided to load and run programs, to feed 
  18. programs simulated keyboard input, to interact with a user, and to detect what a 
  19. program is doing primarily by checking what is displayed on the screen.
  20.  
  21. Pandora can be used either to set up a program to run all by itself, even in the 
  22. middle of the night, or to provide a user with a modified user interface to a 
  23. program.  It also has application in testing programs in development.
  24.  
  25. Pandora's script commands are completely described below.
  26.  
  27. For anyone proposing to use Pandora it is vital to be aware of certain 
  28. restrictions imposed.  Most of these restrictions reflect original design 
  29. decisions made to keep the project within manageable bounds and the program to a 
  30. reasonable size.  The precise limitations are:
  31.  
  32. (1)  Pandora is designed to be used only with text-mode programs.  It is not 
  33. impossible to use it with graphics programs -- one user has very succesfully 
  34. done so -- but certain commands will be useless with graphics-mode video output 
  35. and there are no facilities oriented to graphics.
  36.  
  37. (2)  It is very difficult to use Pandora to automate memory-resident 
  38. applications.  This is not so much because of limitations in Pandora but because 
  39. the design of DOS makes it nearly impossible.  If you want to use Pandora with a 
  40. TSR program, do try -- you may be lucky -- but be prepared to find that it's 
  41. hopeless.
  42.  
  43. (3)  It is difficult to use Pandora with remote-control programs such as Carbon 
  44. Copy, Takeover, Close Up, Remote2, and pcANYWHERE.  This is unfortunate because 
  45. a lot of people have wanted to do so, but the fact is that such programs seize 
  46. control of the PC at such a low level that Pandora just cannot slide in 
  47. underneath in order to work its magic in the normal way.  Despite this warning, 
  48. there are some people who have been successful so, again, give it a try if you 
  49. will but be cautious.
  50.  
  51. (4)  Pandora does not work with Windows programs.  It can, however, be used as 
  52. normally with DOS applications that are launched from Windows.
  53.  
  54. (5)  Pandora does not work with CIM, the CompuServe Information Manager.  This 
  55. is because CIM was intentionally designed and written in a manner that thwarts 
  56. its use with programs like Pandora.
  57.  
  58.  
  59.  
  60. Controlling Programs with Pandora
  61. ----------- -------- ---- -------
  62. This section describes how Pandora operates.  The discussion is necessarily a 
  63. little technical but an understanding of the principles involved is essential 
  64. to making effective use of the utility.  I suggest that you study this once you 
  65. have played with Pandora a little and have gained a sense of what it can do, but 
  66. before you embark on writing any Pandora scripts.
  67.  
  68. DOS provides support for two types of program:  transient programs and TSRs 
  69. (memory-resident programs).  Transient programs include all those regular 
  70. applications that you use such as word processors, spreadsheet programs, etc.  
  71. When you run a transient program, it takes primary control of the PC and 
  72. normally retains that control until you terminate it.  The most obvious aspect 
  73. of this control is that the program essentially owns the screen and keyboard.
  74.  
  75. DOS allows only one transient program to run at a time but compensates to a 
  76. small degree for this limitation by allowing one transient program to execute 
  77. another in a nested fashion.  The original program becomes dormant after 
  78. starting up a second program, then regains control after that second program 
  79. quits.  You may be familiar with the idea of "shelling out" of an application, a 
  80. facility implemented by means of this capability.  Since the dormant program 
  81. remains in memory, the degree to which this nesting can be done is severely 
  82. limited by the amount of program memory available.
  83.  
  84. Pandora works by running as a transient program itself, and then executing 
  85. another program (or a sequence of programs).  Once it has has started a "child" 
  86. program, Pandora does not, however, go dormant; rather it plays some tricks 
  87. normally used by TSRs to retain a measure of control so that it can act in the 
  88. role of a "puppeteer" to the child.
  89.  
  90. A Pandora script, at its simplest, covers three phases of operation:
  91.  
  92.      1.  Loading a child program and otherwise preparing for its execution.
  93.  
  94.      2.  Running the child program while exerting control over its actions.
  95.  
  96.      3.  Terminating the child or waiting for it terminate, and cleaning up
  97.          after it.
  98.  
  99. In a Pandora script you set a child program running by means of the Go command.  
  100. From then on until the child dies there are two threads of execution proceeding:  
  101. the child itself and the thread represented by Pandora performing the commands 
  102. that you have written for it.  Control alternates back and forth between these 
  103. two threads and the key to successful use of Pandora scripting is managing 
  104. synchronization between the two.
  105.  
  106. Beyond the "Go" point Pandora can interact with the child in one of two ways:  
  107. asynchronously or synchronously.
  108.  
  109. Pandora's primary means of asynchronous interaction is feeding simulated 
  110. keyboard input to the child.  Pandora stuffs characters into the BIOS keyboard 
  111. buffer and the child reads them in its own time.  This is asynchronous because 
  112. there is no synchronization between Pandora's "feeding" the characters and the 
  113. child's "eating" them.
  114.  
  115. Asynchronous character feeding works a lot of the time but there are also 
  116. situations where synchronization is necessary.  Consider an application that 
  117. displays a prompt for the user to type something and, at the point of displaying 
  118. that prompt, flushes the keyboard buffer -- that is, discards any waiting input 
  119. to be sure that the characters it processes are fresh and pertinent.  If Pandora 
  120. is to respond to the prompt then it must first wait for it to appear on the 
  121. screen.
  122.  
  123. Synchronization is achieved by a set of commands with names starting "Wait".  
  124. Each such command instructs Pandora to wait for some event before proceeding 
  125. with further commands.  For this reason, most Wait commands are valid only 
  126. during the child-execution phase.  (One partial exception is WaitUntil which can 
  127. be invoked anywhere in a script to delay until a given time of day.)
  128.  
  129. To further enhance synchronization between Pandora and its child, several other 
  130. commands have been added, such as IfScreen which tests for the presence of a 
  131. string on the screen.
  132.  
  133.  
  134.  
  135. Version 2
  136. ------- -
  137. Many of the changes in this second-generation Pandora arose from my realization 
  138. that, in version 1, there was not a sufficiently clear distinction between 
  139. commands that had synchronous effects and those that had asynchronous effects 
  140. [see the previous section].  The changes made in version 2 may "break" some 
  141. existing Pandora scripts but only trivial modifications should be necessary to 
  142. fix them.  (To be precise, it may be necessary to change some GetKey commands to 
  143. WaitKey, some Pause commands to WaitPeriod, and no more.)
  144.  
  145. The biggest problem lay in the GetKey command.  Although the documentation never 
  146. made this fact sufficiently clear, GetKey operated asynchronously.  That meant 
  147. that a GetKey caused Pandora to wait for the user to press a key before 
  148. continuing (with its next command).  GetKey had no effect on the child which 
  149. would continue to execute indefinitely.
  150.  
  151. GetKey has been recoded to operate synchronously.  Now when Pandora reaches a 
  152. GetKey, it stops the child and waits for the user to press a key.  Nothing 
  153. happens until that keypress is made.
  154.  
  155. The new command, WaitKey, has been added to do what GetKey did previously.  The 
  156. name "WaitKey" ties the operation to all the other Wait commands which have 
  157. similar effects.  A Wait command causes Pandora to wait; the child continues to 
  158. run.
  159.  
  160. Synchronization has also been facilitated by the addition of the Kill and 
  161. OnDeath commands.  The former allows Pandora to forcibly terminate a child.  I 
  162. had not provided that capability before because I had not understood how to do 
  163. it.  OnDeath lets you synch up a script with a child that terminates 
  164. asynchronously.  See Pandora Commands for more.
  165.  
  166. Pandora now supports BIOS Enhanced Keyboard Services.  This allows it to operate 
  167. with programs such as WordPerfect with which it was not compatible previously.
  168.  
  169. Finally, you will find several other new commands that I have not had occasion 
  170. to mention above.  VideoFore and VideoBack, for example, let you set screen 
  171. colors more easily.  ScreenWrite and ScreenRead allow you to save and restore 
  172. screen images to create slideshows or other similar effects.  PassKey enables 
  173. you to filter the keystrokes sent from the keyboard to an application.
  174.  
  175. Version 2.3 saw the introduction of the CtrlBreak command and a necessary 
  176. redesign of the Break On/Off command.
  177. ******************************************************************************
  178.  
  179.  
  180. *
  181.                                 Pandora Commands
  182.                                 ------- --------
  183.  
  184.                       (for Pandora v2.2 and later versions)
  185.  
  186.  
  187.                          by Pete Maclean [CIS: 75776,660]
  188.                            Copyright 1991 Pete Maclean.
  189.  
  190.  
  191. This provides documentation on writing scripts for Pandora (originally 
  192. published as PAN).  Please note that many commands have been added since the 
  193. PAN article was published in PC Magazine.  The behavior of a few other commands 
  194. has been changed slightly.
  195.  
  196. Commands are written one per line with any amount of white space (blanks and 
  197. tabs) thrown in before and between fields.  Each command starts with a keyword 
  198. such as "Output" or "Label".  Keywords may be written in any mixture of upper 
  199. and lower case.  String arguments may be delimited by any non-blank character 
  200. although for readability double quotes are suggested.
  201.  
  202. You can include comment lines in Pandora scripts.  Pandora treats any line that 
  203. begins with an asterisk as commentary, for example:
  204.  
  205.      * This is a comment line that Pandora ignores.
  206.  
  207. As is acknowledged in many of the command descriptions, Pandora does little 
  208. error checking.  If a script does not do what you expect, consider the 
  209. possibility that there is some error that a compiler or other typical language 
  210. processor would catch but which Pandora does not.
  211.  
  212.  
  213. Command Groups
  214. ------- ------
  215. Commands fall into functional groups as follows:
  216.  
  217. Loading, starting and terminating programs:  Load, IfLoad, Go, KillChild, 
  218. OnDeath, WaitChild, Env, SetMemory.
  219.  
  220. Simulating keyboard input to programs:  CtrlBreak, Key, KeyFile, OpenKeyFile, 
  221. TypeRate.
  222.  
  223. Displaying text on the screen:  Cursor, Output, ReadScreen, Screen, Mode, Video, 
  224. VideoBack, VideoFore, Wipe, WriteScreen.
  225.  
  226. Controlling user interaction with a program:  Alt, Ctrl, CapsLock, NumLock,
  227.      LeftShift, RightShift, Break, Flush, ScrollLock, Lock, UnLock.
  228.  
  229. Timing events;  Pause, IfAfter, IfBefore, WaitPeriod, WaitUntil.
  230.  
  231. Script control:  Call, Return, If..., Else, EndIf, Jump, Quit.
  232.  
  233. Detecting program activity:  IfScreen, WaitScreen.
  234.  
  235. Miscellaneous:  DOS, Tone.
  236.  
  237.  
  238. Command Descriptions
  239. ------- ------------
  240.  
  241. Alt On/Off
  242.      (See section on Keyboard Control Commands below.)
  243.  
  244. Break On/Off
  245.      Sets the condition for how Pandora handles a Control-Break.  Please
  246.      note that the effect of this command was changed in the transition
  247.      from Pandora version 2.2 to 2.3.
  248.  
  249.      By default (the condition set by "Break Off") Pandora pays no attention
  250.      to a Ctrl-Break.  If a child program is running then the child
  251.      handles Ctrl-Break according to its design.  For many programs, this
  252.      key combination serves as an abort signal and DOS provides some facilities
  253.      for handling it as such.  Programs may, however, treat Ctrl-Break in
  254.      other ways.
  255.  
  256.      By issuing a "Break On" command, you tell Pandora to intercept a
  257.      Ctrl-Break and use it as a signal to abort processing of the script.
  258.      Then, when the user presses Ctrl-Break, Pandora steps out of the way
  259.      and leaves the program to continue running as if it (Pandora) were no
  260.      longer there.  There may be no apparent indication of this happening!
  261.  
  262.      Setting "Break On" can be useful, for example, when you set up a script
  263.      to run a program over and over again in a loop.  You might do this with
  264.      a program that displays the status of something that changes over time
  265.      such as the load average on a LAN.  Instead of having your script
  266.      laboriously intercept every keypress and check for some signal to
  267.      terminate, you may be able to just set enable termination by Control-
  268.      Break.
  269.  
  270.      Issue a Break command prior to starting the child program.  Pandora
  271.      will generate an error if it meets a Break while running a program.
  272.  
  273. Call label
  274.      Call coupled with the Return command gives Pandora a primitive
  275.      subroutine capability.  When Pandora performs a Call command it
  276.      pushes a pointer to the next command onto an internal stack.  When
  277.      a Return is issued that pointer is popped.  No system is provided
  278.      for passing arguments to a subroutine.  Here's an example:
  279.  
  280.               Call procedure
  281.               .....
  282.               .....
  283.               Quit
  284.  
  285.               Label procedure
  286.               Output "This message come from a subroutine!"
  287.               Return
  288.  
  289.      Warning:  This facility is provided as an interim measure.  It may
  290.      in future be supplanted by a more powerful subroutine mechanism.
  291.      I make no guarantee to continue supporting the current facility.
  292.  
  293. CapsLock On/Off
  294.      Simulates toggling the CapsLock key.  The argument must be "On" or "Off".
  295.      The setting of CapsLock affects keyboard input typed by the user; it
  296.      does *not* affect simulated keyboard input generated by the Key command.
  297.      To ensure that CapsLock is off when starting a program, for example, use
  298.      the command:
  299.  
  300.               CapsLock Off
  301.  
  302. Ctrl On/Off
  303.      (See section on Keyboard Control Commands below.)
  304.  
  305. CtrlBreak
  306.      Simulates the user's pressing Ctrl-Break.  Feeding a Ctrl-Break
  307.      to a program is accomplished by this command rather than via the
  308.      Key command because Ctrl-Break is interpreted as an abort signal
  309.      and handled in a special way at a low level in the PC (actually by
  310.      the BIOS keyboard driver).
  311.  
  312.      Simulating a Ctrl-Break condition is tricky and this command is known
  313.      to not work correctly with certain programs such as Microsoft Flight
  314.      Simulator.
  315.  
  316. Cursor <row> <column>
  317.      Repositions the cursor to a location on (or possibly off) the screen.  
  318.      As with all other commands that refer to screen coordinates, rows and 
  319.      columns are numbered from zero with the top left corner being row 0, 
  320.      column 0.  The row and column arguments are decoded as decimal integers 
  321.      and their values are not checked.  If an argument is omitted or invalid 
  322.      (i.e., non-numeric) then a default value of zero is used; *no* error 
  323.      indication is given.  The cursor can be made to "disappear" by moving it 
  324.      to a location beyond the bounds of the screen, for instance with the 
  325.      command:
  326.  
  327.                Cursor 25 0
  328.  
  329. DOS "command"
  330.      Runs a copy of the DOS command interpreter to execute the supplied command.
  331.      Pandora allows the execution of any command that you can type at the DOS 
  332.      prompt.  It can be used for such purposes as changing the current 
  333.      directory, getting directory listings, and deleting files.  All standard 
  334.      command options are supported including redirection and batch files.
  335.  
  336.      Here are some examples:
  337.  
  338.               DOS "cd \new"
  339.               DOS "del blah.dat"
  340.               DOS "E:"
  341.               DOS "call batch"
  342.               DOS "dir *.exe >tmp"
  343.  
  344.      Don't forget to enclose the command in quotes!
  345.  
  346.      Note:  The DOS command is not available while Pandora is running a program.
  347.  
  348.      This facility depends on COMSPEC being defined in the environment table.  
  349.      Pandora uses the COMSPEC string to find the command interpreter, 
  350.      COMMAND.COM.  If COMSPEC is not defined then the DOS command will fail.
  351.  
  352. Else
  353.      Reverses conditional execution inside an If-EndIf command group.
  354.  
  355. EndIf
  356.      Terminates the effect of an If command (i.e. IfKey, IfLoad, IfScreen,
  357.      etc.).  Every If must have a matching EndIf.
  358.  
  359. Env
  360.      Several early users had trouble getting Pandora to pass on the desired 
  361.      environment to its children.  To accomodate all needs the Env command 
  362.      allows you to select between two options.  The valid forms of the command
  363.      are:
  364.  
  365.               Env Own
  366.               Env Master
  367.  
  368.      The "Own" argument tells Pandora to pass on copies of its own environment.  
  369.      This is the default.  The "Master" argument tells Pandora to pass on copies 
  370.      of the master environment.  Note that if you use Pandora's DOS command to 
  371.      change environment strings, as in:
  372.  
  373.               DOS "Set magic=teapot"
  374.  
  375.      it is the master environment that is affected.
  376.  
  377.      The issue of which environment gets inherited is tricky.  If you see no 
  378.      reason to care then don't worry about it; the default should suit you.
  379.  
  380. Flush
  381.      Flushes the keyboard holding buffer.  The Flush command is used mostly 
  382.      in association with the GetKey command to discard any accumulated key
  383.      codes before soliciting a keypress from the user.
  384.  
  385. GetKey
  386.      Waits for the user to depress a key on the keyboard which then becomes
  387.      available for testing with the IfKey command or passing on to the child
  388.      with Passkey.
  389.  
  390.      See also IfKey, PassKey and WaitKey.
  391.  
  392. Go "arguments"
  393.      Initiates execution of a child program that has been loaded with a Load
  394.      or IfLoad command.  The child is run as if it had been started from the
  395.      DOS prompt with the given argument string.
  396.  
  397. IfAfter <time>
  398.      Tests if the time kept by DOS is equal to or greater than the time given.  
  399.      The argument should be expressed in the format HH:MM using the 24-hour 
  400.      system.  For example, the following will hold true if it is 10:15 pm or
  401.      later:
  402.  
  403.               IfAfter 22:15
  404.  
  405. IfBefore <time>
  406.      Tests if the time maintained by DOS is before that specified.  As with the 
  407.      previous command, the time must be expressed in the form HH:MM where HH is 
  408.      an hour in the range 0 to 24 and MM is a minute in the range 0 to 59.  The 
  409.      following command, for instance, will hold true if it is earlier than
  410.      6:05 am:
  411.  
  412.               IfBefore 6:05
  413.  
  414. IfExist "file"
  415.      This works exactly like DOS' IF EXIST command for batch files.  This
  416.      example should make it clear:
  417.  
  418.               IfExist "XRB.BAT"
  419.                       DOS "XRB ABC"
  420.               Else
  421.                       Output "ERROR:  Cannot find the batch file XRB.BAT"
  422.                       Quit
  423.               EndIf
  424.  
  425.      IfExist detects the presence of regular files plus hidden and system
  426.      files.  It does not directly detect subdirectories or volume labels.
  427.      Nevertheless, as with the DOS command, you can test if a given
  428.      directory exists by testing for NUL within that directory, as in.
  429.  
  430.               IfExist "C:\DOS\NUL
  431.               Else
  432.                       Output "ERROR:  You don't have a C:\DOS directory"
  433.                       Quit
  434.               EndIf
  435.  
  436. IfKey "list"
  437.      Tests if the last keypress (that captured by a GetKey command) matches 
  438.      one of those in the given list.  If there is a match the subsequent      
  439.      commands are executed.  If the match fails then command execution is      
  440.      inhibited until a matching Else or EndIf command is encountered.
  441.      The following command, by way of example, would result in a match if
  442.      the key in question was any digit:
  443.  
  444.                IfKey "1234567890"
  445.  
  446. IfKeyFileEOF
  447.      Tests for an end-of-file condition on the file opened by the last
  448.      OpenKeyFile command and processed by the KeyFile command.
  449.  
  450.      A typical sequence of commands is:
  451.  
  452.               OpenKeyFile "INPUT"
  453.               Label keyer
  454.               [Wait for some prompt]
  455.               KeyFile Line
  456.               IfKeyFileEOF
  457.               Else
  458.                   Jump keyer
  459.               EndIf
  460.  
  461. IfLoad "file"
  462.      Attempts to load a program into memory for subsequent execution.  The
  463.      argument supplies the filename in which the extension ("EXE" or "COM")
  464.      must be included.  Execution of the loaded program does not start until
  465.      a Go command is performed.  The commands following the IfLoad are
  466.      performed if the load is successful; if it fails, the commands following
  467.      an Else or EndIf are performed.  For example:
  468.  
  469.                IfLoad "c:\program.com"
  470.                     Output "The program has been loaded successfully!^M^J"
  471.                     Go
  472.                     Quit
  473.                Else
  474.                     Output "The program could not be loaded!^M^J"
  475.                     Quit
  476.                EndIf
  477.  
  478. IfScreen <row> <column> "string"
  479.      Checks if the given string appears on the screen at the given position.
  480.      (This command, obviously, is closely related to WaitScreen.)  For
  481.      example:
  482.  
  483.                IfScreen 24 0 "OK"
  484.                     Jump success
  485.                EndIf
  486.                IfScreen 24 0 "Error"
  487.                     Quit
  488.                EndIf
  489.  
  490.      checks for two strings that a program may display, and takes appropriate
  491.      action for each.
  492.  
  493. Jump label
  494.      Transfers control to the given label (defined in a Label command).
  495.  
  496. Key "string"
  497.      Feeds the given string of characters to the running program by
  498.      entering them, one by one, into the keyboard holding buffer.  This
  499.      simulates a user typing the same characters at the keyboard.  This
  500.      example has the equivalent effect of a user typing "Yes" then pressing
  501.      the Enter key:
  502.  
  503.                Key "Yes[Enter]"
  504.  
  505.      The Key command is valid only while Pandora is running a program.
  506.  
  507.      The rate at which keycodes are fed to the program can be moderated by
  508.      means of the TypeRate command.
  509.  
  510.      If you want to feed a Ctrl-Break signal to a program you must do so
  511.      using Pandora's CtrlBreak command.  It is not possible to issue a
  512.      Ctrl-Break with the Key command.
  513.  
  514. KeyFile Char/Line
  515.      KeyFile is a lot like Key but feeds characters read from a file into
  516.      the keyboard buffer.  Each invocation of KeyFile feeds either a character
  517.      or a line from the file opened in an OpenKeyFile command.
  518.  
  519.      Each byte from the file is read as one literal character.
  520.      Thus only ASCII and extended-ASCII characters can be fed in this manner;
  521.      there is no way to introduce Alt-shifted keys, function keys, etc.
  522.  
  523.      Pandora strips linefeeds from the file and passes everything else.  If
  524.      any user finds a need to strip other characters, or to not strip linefeeds,
  525.      then I shall add a mechanism to permit such.
  526.  
  527.      KeyFile is valid only while Pandora is running a program.
  528.  
  529.      The rate at which keycodes are fed to the program can be moderated by
  530.      means of the TypeRate command.
  531.  
  532.      See also IfKeyFileEOF which provides for end-of-file detection.
  533.  
  534. KillChild
  535.      Kills the child program.  An error occurs if this command is used when
  536.      no program is running.
  537.  
  538.      This command should be seen as a brute-force method of terminating a
  539.      child program.  If you have the option of feeding the program some
  540.      appropriate keystrokes to tell it to quit, then do that instead.
  541.  
  542.      If a program traps any device interrupts then terminating it with
  543.      KillChild may result in an error condition that forces a reboot.
  544.      This applies, for example, to most communication programs.
  545.  
  546. Label label
  547.      Defines a label that can be used as the object of a Jump command.  This
  548.      command is a no-operation in most respects.
  549.  
  550. LeftShift On/Off
  551.      (See section on Keyboard Control Commands below.)
  552.  
  553. Load "file"
  554.      Loads a program into memory for subsequent execution.  The argument 
  555.      supplies the filename in which the extension ("EXE" or "COM") must be 
  556.      included.  Execution of the loaded program does not start until a Go 
  557.      command is performed.  Should the load fail for any reason, Pandora emits
  558.      a suitable diagnostic and quits.  If you want Pandora to maintain
  559.      control after a failed load then use IfLoad instead.
  560.  
  561. Lock
  562.      This command locks the keyboard.  If you want Pandora to have full control
  563.      over keyboard input to the child program then you should use this
  564.      command at an appropriate point.  Locking the keyboard prevents
  565.      user keypresses from getting interspersed with the simulated input
  566.      generated by Pandora's Key commands.
  567.  
  568.      After a Lock, the keyboard remains locked until either an Unlock
  569.      command is performed or Pandora quits.  If the user presses a key while
  570.      the keyboard is locked, the system beeps and otherwise the action is
  571.      ignored.  (In fact, the behavior is identical to that taken by DOS
  572.      when the type-ahead buffer is full.)
  573.  
  574. Mode
  575.      Commands such as Screen and IfScreen operate by delving into the video
  576.      buffer, that is the block of memory that holds a character-by-character
  577.      image of what appears on the screen.  When Pandora starts up it determines
  578.      the memory address for the current screen buffer and then uses that
  579.      same address whenever the need arises.  Some programs change the video
  580.      mode; in such a case the address of the effective video buffer may
  581.      change too.  The Mode command forces Pandora to reevaluate the address for the 
  582.      video buffer.
  583.  
  584.      Very few people will need the Mode command, especially as Pandora offers
  585.      so little assistance in automating graphics applications.  Should you
  586.      write a script and find that WaitScreen commands do not take effect then
  587.      consider the possibility that you need to add a Mode command.
  588.  
  589. NumLock On/Off
  590.      Simulates toggling the NumLock key.  The argument must be "On" or "Off".
  591.      The setting of NumLock affects keyboard input typed by the user; it
  592.      does *not* affect simulated keyboard input generated by the Key command.
  593.      To ensure that NumLock is off when starting a program, for example, use
  594.      the command:
  595.  
  596.               NumLock Off
  597.  
  598. OnDeath <label>
  599.      OnDeath is Pandora's one asynchronous command.  It allows you to establish
  600.      a label to which control is transferred when a child dies.  Here is a
  601.      simple example of its use:
  602.  
  603.               Load "program.exe"
  604.               Go
  605.               OnDeath Obituary
  606.               Label Loop
  607.               GetKey
  608.               IfKey "[Ins]"
  609.               Else
  610.                     PassKey
  611.               EndIf
  612.               Goto Loop
  613.  
  614.               Label Obituary
  615.               ...[continued]
  616.  
  617.      This script feeds keyboard input to a program filtering out the Insert
  618.      key.  When the child terminates, control is automatically switched from
  619.      the loop to the command following "Label Obituary".
  620.  
  621.      You can use this form of script in more sophisticated ways to build
  622.      application-specific keyboard-macro processors.
  623.  
  624. OpenKeyFile "filename".
  625.      Opens a file for use with the KeyFile command.  If the file cannot be 
  626.      opened then Pandora displays a diagnostic and aborts.  The file opened
  627.      by this command remains open either until another OpenKeyFile is performed
  628.      or until Pandora quits.  For further information, see the entry for
  629.      KeyFile.
  630.  
  631. Output "string"
  632.      Displays a string on the screen at the current cursor location.  The
  633.      cursor is updated in the process.  The Output command should be used
  634.      to display stuff when animating applications that use the screen in a
  635.      simple scrolling manner (like DOS utilities).  The Screen command, by
  636.      contrast, should be used with screen-oriented applications.
  637.      Here is an example:
  638.  
  639.                Output "This string scrolls onto the screen.^M^J"
  640.  
  641.      The "^M^J" part stands for a carriage return plus a linefeed.
  642.  
  643.      You may redirect Output to a file in the same way as you would
  644.      using redirection on the DOS command line.  For example:
  645.  
  646.               Output "This gets written to a file^M^J"  > thisfile
  647.               Output "This gets appended to a file^M^J" >> thatfile
  648.  
  649. PassKey
  650.      Passes the keycode obtained by the last GetKey or WaitKey to the
  651.      child program.  GetKey and PassKey can be used in combination to
  652.      provide a keyboard macro facility for a program, as in this
  653.      example:
  654.  
  655.               Label keyer
  656.               GetKey
  657.               IfKey "[Alt]M"
  658.                      Key "This is a macro"
  659.               Else
  660.                      PassKey
  661.               EndIf
  662.               Jump keyer
  663.  
  664.      These commands can also be used to filter keycdoes to ensure that
  665.      selected codes never reach a program.
  666.  
  667.      See also GetKey, Ifkey and WaitKey.
  668.  
  669. Pause <n> Ticks/Seconds/Minutes
  670.      Pauses for the specified period.  Permissible times are:
  671.                1 - 255 ticks
  672.                1 - 255 seconds
  673.          or    1 - 60  minutes
  674.      A tick refers to the period between clock ticks on a standard PC; such
  675.      ticks occur at a rate of 18.2 to a second. The following example 
  676.      invokes a delay of two and a half minutes:
  677.  
  678.                Pause 2 minutes
  679.                Pause 30 seconds
  680.  
  681.      Pandora interprets only the first letter of the units field, looking for
  682.      't', 's' or 'm'.  If the units field is omitted, Pandora assumes seconds.
  683.  
  684. PrintScreen
  685.      This command, which takes no arguments, has the same effect as pressing the 
  686.      <PrtSc> key on the PC keyboard.  (Internally this invokes interrupt number 
  687.      5.)  It is compatible with PC Magazine's PRN2FILE utility.
  688.  
  689.  
  690. Quit
  691.      Terminates Pandora.  If Pandora has no child running then it quits
  692.      immediately.  If a child is active then Pandora quits only when
  693.      that child quits.
  694.  
  695. ReadScreen <filename>
  696.      Restores a screen image from a file.  Use the WriteScreen command to
  697.      create suitable files.
  698.  
  699. Return
  700.      Return from a subroutine.  (See Call.)
  701.  
  702. RightShift On/Off
  703.      (See section on Keyboard Control Commands below.)
  704.  
  705. Screen <row> <column> "string"
  706.      Writes a string of characters to the screen starting at the character
  707.      position defined by the <row> and <column> arguments. The operation is 
  708.      performed using a direct write to the video buffer.  For example:
  709.  
  710.            Screen 10 40 "This appears on line 10 starting at column 40"
  711.  
  712.      Note that for this, as for all purposes in Pandora, rows are numbered
  713.      from 0 to 24 and columns from 0 to 79.  The video attribute used is that
  714.      set by the last Video, VideoFore and/or VideoBack command(s).
  715.  
  716. ScrollLock On/Off
  717.      Simulates toggling the ScrollLock key.  The argument must be "On" or "Off".
  718.  
  719. SetMemory
  720.      SetMemory is a command intended for programmers who need to test their 
  721.      products running in limited amounts of memory.  It is likely to be of no 
  722.      value to most Pandora users.  The following command, for example:
  723.  
  724.               SetMemory 100
  725.  
  726.      artificially sets the largest block of free DOS memory to a size of 100
  727.      kilobytes.  The argument is a decimal number that is interpreted as a KB
  728.      count.  The effect of a SetMemory lasts until either another SetMemory is
  729.      performed or until Pandora exits.
  730.  
  731. Tone
  732.      The Tone command enables you to generate a tone on the PC's speaker.  
  733.      Normally, it takes two arguments:  a frequency and a duration.  The 
  734.      frequency is a number of Hertz between 50 and 15000.  Selecting 50 Hz 
  735.      results in a low buzz while 15000 Hz is sufficiently high-pitched that most 
  736.      PC speakers will not even succeed in reproducing it.  The duration is the 
  737.      period of time that you want the tone sounded for.  Here's an example:
  738.  
  739.               Tone  262 1s
  740.  
  741.      This will generate a 262-Hz tone (that's middle C, I believe) for a period 
  742.      of one second.  The duration argument is expressed in exactly the same way 
  743.      as an argument to the Pause command.  The shortest available duration is 
  744.      one tick, that is approxiamtely one eighteenth of a second.  You can play 
  745.      some primitive tunes by writing a sequence of Tone commands.  (Would 
  746.      someone volunteer to compose the Pandora theme tune?)
  747.  
  748.      A further option on the Tone command lets you have a tone sounding while 
  749.      other Pandora commands are executing.  If the duration argument is given as 
  750.      zero (or is simply omitted) the tone will be generated until the next Tone 
  751.      command is performed.  To shut off a tone started in this way, use a Tone 
  752.      command with a first argument of zero.  Here's an example:
  753.  
  754.               Tone 98 0
  755.               Output "The tone you are hearing has a frequency of 98 Hz^M^J"
  756.               Output "Press any key when you are sick of it!"
  757.               GetKey
  758.               Tone 0
  759.  
  760. TypeRate <ticks>
  761.      Controls the rate at which characters are fed by the Key command into 
  762.      the keyboard holding buffer.  For most situations setting the TypeRate 
  763.      to zero is the best choice; then the keys are fed to the animated 
  764.      program as fast as it will accept them.  If you want the user to 
  765.      clearly see what is being "typed" then set the TypeRate to some number
  766.      between 2 and 9.  The number represents the count of 18.2-to-a-second
  767.      ticks that are forced to pass between each pair of keyed characters.
  768.  
  769. Unlock
  770.      Unlocks the keyboard if it was previously locked by a Lock command.  If
  771.      the keyboard is not locked then this command does nothing.
  772.  
  773. Video <attribute>
  774.      Sets a video attribute for writes by subsequent Screen commands.
  775.      The argument is interpreted as a hexadecimal number.  The default screen
  776.      attribute (70 hex) is for white foreground and black background.
  777.  
  778.      The Video command is provided for historical reasons.  Most users will
  779.      prefer to use VideoBack and VideoFore.
  780.  
  781. VideoBack <background_color>
  782.      Sets the background color for subsequent Screen commands.  Valid colors
  783.      are:
  784.  
  785.           Black, Blue, Green, Cyan, Red, Magenta, Brown and White
  786.  
  787. VideoFore <background_color>
  788.      Sets the foreground color for subsequent Screen commands.  Valid colors
  789.      are:
  790.  
  791.           Black, Blue, Green, Cyan, Red, Magenta, Brown, White,
  792.           Grey, LightBlue, LightGreen, LightCyan, LightRed
  793.           LightMagenta, Yellow and BrightWhite
  794.  
  795.      Composite color names must be written as one word, as shown.
  796.  
  797. VideoNormal
  798.      Restores "normal" video after reverse video has been selected by
  799.      the VideoReverse command.
  800.  
  801. VideoReverse
  802.      Reverses the foreground and background colors.
  803.  
  804. WaitChild
  805.      Suspends Pandora activity until the child program terminates.
  806.  
  807. WaitKey
  808.      Suspends Pandora activity until the user presses a key.  The child
  809.      program continues running but is blocked from getting keyboard input.
  810.      WaitKey is valid only while a child program is running.
  811.  
  812.      Note the difference between GetKey and WaitKey.  If no child is running
  813.      then GetKey should be used.  GetKey suspends both Pandora itself and
  814.      the child program until the user presses a key.  WaitKey suspends
  815.      Pandora but lets the child run unmolested.
  816.  
  817.      Here's a simple example of the use of WaitKey:
  818.  
  819.               Load "program.exe"
  820.               Go
  821.               WaitKey
  822.               KillChild
  823.  
  824.      This starts up a program and lets it run until the user presses
  825.      a key, any key.  Obviously this assumes that said program runs
  826.      without asking for any keyboard input.  WaitKey can be very useful
  827.      in scripts written to demo programs.
  828.  
  829.      See also GetKey, IfKey and PassKey.
  830.  
  831. WaitPeriod <n> Ticks/Seconds/Minutes
  832.      Suspends Pandora activity for the specified period of time.  The
  833.      argument has exactly the same form as that for the Pause command.
  834.  
  835.      Suppose you want to set up a program for people to try at a trade
  836.      show.  You want to limit each user to running the program for 3
  837.      minutes in order to gove plenty of people an opportunity.  The
  838.      following script will give you an idea of how to do it.
  839.  
  840.               Label next
  841.               Wipe
  842.               Screen 0 0 "Press any key for a 3-minute try"
  843.               GetKey
  844.               Load "program.exe"
  845.               Go
  846.               WaitPeriod 3 minutes
  847.               KillChild
  848.               Jump next
  849.  
  850.      Note the difference between WaitPeriod and Pause.  Pause suspends
  851.      both Pandora and the child program (if any) for the given period.
  852.      WaitPeriod suspends Pandora but lets the child run.  The following
  853.      example demonstrates this with a script fragment that runs a
  854.      program in slow motion by alternately letting it run for one tick
  855.      and then freezing it for three.  The effect may be rather jerky.
  856.  
  857.               Label SlowDown
  858.               WaitPeriod 1t
  859.               Pause 3t
  860.               Jump SlowDown
  861.  
  862. WaitScreen <row> <column> "string"
  863.      Waits for the given string to appear on the screen starting at the
  864.      given position.  Pandora continually searches for the string in the video 
  865.      buffer.  Use this command with care:  Pandora will wait forever if 
  866.      necessary for the string to appear and there may be no way to interrupt 
  867.      the wait other than by pressing Ctrl-Alt-Del.
  868.  
  869. WaitUntil <time>
  870.      Suspends Pandora activity until the given time of day.  Times should be
  871.      expressed using 24-hour-clock notation.  Thus to wait until 10:15 pm,
  872.      one should code:
  873.  
  874.                WaitUntil 22:15
  875.  
  876.      This command may be used in any context, that is with or without
  877.      a child program running.  When there is no child running you can
  878.      abort a WaitUntil by pressing the Escape key.
  879.  
  880. Wipe
  881.      Clears the screen.  (A BIOS function is used to do this.)
  882.  
  883. WriteScreen <filename>
  884.      Writes a copy of the current screen image to the named file.  The
  885.      image can be restored using the ReadScreen command.  Note that this
  886.      command works only with 25x80-character text-mode screens, and that
  887.      the screen attributes are stored along with the characters.
  888.  
  889.      You can create simple slideshows using WriteScreen and ReadScreen.
  890.  
  891.  
  892.  
  893. Keyboard Control Commands
  894. -------- ------- --------
  895. I added some commands so that I could experiment with using Pandora to control 
  896. pop-up memory-resident programs with hot keys.  The commands are Alt, Ctrl, 
  897. LeftShift and RightShift.  Each takes an argument of On or Off.  The effect of,
  898. for example:
  899.  
  900.               Alt On
  901.  
  902. is to duplicate pressing the Alt key on the keyboard.  Suppose that you have a 
  903. memory-resident program that pops up when you press both shift keys 
  904. simultaneously; then you can make Pandora pop it up with the commands:
  905.  
  906.               LeftShift On
  907.               RightShift On
  908.  
  909. Note that once you have used such a command, the effect is as if you had pressed 
  910. the equivalent key and remained pressing it.  To release the key, you must give 
  911. a command such as:
  912.  
  913.               LeftShift Off
  914.  
  915. otherwise you may experience strange keyboard behavior.
  916.  
  917. Also please note that these commands, like CapsLock etc., affect only the real 
  918. keyboard.  They have no effect on simulated keyboard input generated by the Key 
  919. command.
  920.  
  921.  
  922. Wait Commands
  923. ---- --------
  924. All of the Wait commands cause Pandora to suspend command processing until some 
  925. external event occurs.  Normally this is an event triggered by the child program 
  926. such as its displaying a certain message on the screen.
  927.  
  928. Waits allow you to synchronize your Pandora scripts with events in the child 
  929. program.  It is also possible to synchronize with external events such as the 
  930. user pressing a key (WaitKey) or a certain time of day rolling around 
  931. (WaitUntil).
  932.  
  933.  
  934. Key strings
  935. --- -------
  936. A string provided as an argument to the Key or IfKey command contains symbols 
  937. identifying keys on the standard IBM keyboard.  With the IfKey command, the 
  938. string expresses a list of keys to be matched to the last keypress; the order in 
  939. which the keys are expressed is immaterial.
  940.  
  941. The rules for naming keys are as follows:
  942.  
  943.      Any printable character (except '~' or '[') represents the key that
  944.      generates it.
  945.           e.g., "ABC..., abc..., 123..., !#$%&*()-=+\|`;:'".,/?><{}"
  946.  
  947.      The caret (^) and open square bracket ([) are used as escape characters
  948.      and if intended literally must be doubled.
  949.           e.g., "^^ signifies a caret and [[ a bracket."
  950.  
  951.      A named key is represented by the name in square brackets.  Here is a
  952.      complete list of the key names that Pandora recognizes:
  953.  
  954.           [Esc] [Bksp] [Tab] and [Enter]
  955.           [Home] and [End]
  956.  
  957.           [Ins] or [Insert], [Del] or [Delete]
  958.           [PgUp] or [PageUp], [PgDn] or [PageDown]
  959.  
  960.           [F1] [F2] [F3] [F4] [F5] [F6] [F7] [F8] [F9] [F10] [F11] and [F12]
  961.  
  962.      Arrow keys are identified as follows:
  963.  
  964.           [Up], [Down], [Left] and [Right]
  965.  
  966.      A pure ASCII or extended-ASCII code, equivalent to that generated at
  967.      the keyboard by holding down the Alt key and entering a decimal code on
  968.      the numeric keypad, can be indicated by putting the appropriate number
  969.      in square brackets.
  970.           e.g. "[227] becomes a pi."
  971.  
  972.      Any character may be prefaced by one or more shift indicators:
  973.      [Alt], [Ctrl] or [Shift].  The caret is an alternative for [Ctrl].
  974.  
  975.      Literal control characters should not be included in strings.  Any
  976.      that are present will be ignored.  Use the ^[key] or [Ctrl][key] notation.
  977.  
  978. I acknowledge that this scheme for naming characters is not complete.  One 
  979. cannot, for example, distinguish between the two Enter keys.
  980.  
  981. Here are some examples of key names:
  982.  
  983.      [Alt][F10]      Alt-F10
  984.      [Shift]2        @        (more simply expressed just by @ itself)
  985.      [Esc]           Esc
  986.      ^[[             Esc
  987.      [Ctrl][Enter]   Ctrl-Enter
  988.      [3]             Ctrl-C   (^C would be more usual, however)
  989.      ^2              Null
  990.  
  991.  
  992. Other strings
  993. ----- -------
  994. Strings supplied as arguments to commands such as Screen and Output may contain 
  995. printable characters representing themselves and control characters expressed in 
  996. the common keyboard-equivalent notation.  Control-X is indicated by a caret 
  997. followed by an X (that is, '^X') for any suitable X.  In this notation, carriage 
  998. return is '^M' and linefeed is '^J'.  A literal caret is expressed by doubling 
  999. the character, that is by '^^'.
  1000.  
  1001.  
  1002.  
  1003. Some tips for creating Pandora scripts
  1004. ---- ---- --- -------- ------- -------
  1005. Use the Cursor and Output commands with programs, such as DOS utilities, that 
  1006. write their screen output in scrolling or teletype fashion.  Use the Screen 
  1007. command with programs that do full-screen output.
  1008.  
  1009. Don't let yourself get confused by the differences between key strings (used 
  1010. with Key and IfKey) and character strings (used with other commands).  The 
  1011. latter style of string is a standard in programming but a key string will be new 
  1012. to many people.  Remember that a key string identifies a sequence of codes 
  1013. generated by keys on a keyboard, including many for which there are no 
  1014. equivalent characters.  In a key string, for example, "[Home]" serves to 
  1015. identify a particular key while in a character string it represents a sequence 
  1016. of six characters: [-H-o-m-e-].
  1017.  
  1018. Pandora can be used to run a sequence of programs or one program repeatedly.  
  1019. After one program terminates and Pandora regains control with an OnDeath, Kill 
  1020. or WaitChild command, another Load and Go can be issued.
  1021.  
  1022. Often when you are having trouble debugging a Pandora script, it helps to make 
  1023. it operate in slow motion by throwing in a TypeRate command with an argument of 
  1024. 10 or 20.  A few programs cannot cope at all with keyboard input fed at the 
  1025. maximum rate Pandora is capable of; with these programs, judicious use of 
  1026. TypeRate is a must.
  1027.  
  1028.  
  1029. Using Pandora with Large Programs
  1030. ----- ------- ---- ----- --------
  1031. If you are animating a large program, you may need to watch the length of your 
  1032. Pandora script.  The presence of comment lines never hurts because they are 
  1033. stripped off as the script is loaded.  Also it never costs to indent commands 
  1034. because leading whitespace on a line is also removed.  Ways of reducing memory 
  1035. requirements for a script include keeping labels short (say to two characters) 
  1036. and limiting each field separator to a single character.
  1037.  
  1038. With programs that are memory-hogs, occupying nearly all of available low 
  1039. memory, you may find insufficient space to squeeze in Pandora, small though it 
  1040. is.  You may be tempted to seek a solution in loading Pandora into high memory 
  1041. (using, for example, DOS 5's LOADHIGH or QEMM's LOADHI) leaving all of low 
  1042. memory for the application.  Unfortunately, because of the way these loaders 
  1043. operate, this does not work.  I am looking for a way around this problem but 
  1044. have no confidence that I shall succeed in finding one.
  1045.  
  1046.  
  1047. Notes
  1048. -----
  1049. Pandora seems to be incompatible with SUPER PCKWIK.  Should you run this 
  1050. program, do not rely on Pandora working correctly.
  1051.  
  1052. The OpenKeyFile, KeyFile and IfKeyFileEOF commands were added in version 1.6.  I 
  1053. do not guarantee that support for these commands will be maintained in future 
  1054. versions.  Equivalent functionality will always be provided but the commands 
  1055. involved are subject to change.
  1056.  
  1057. Sample Scripts for version 2.1 still work with this version.
  1058.  
  1059. ---------
  1060.  
  1061. In the May 16, 1990 issue of PC Magazine, a utility called PAN
  1062. was published. PAN is a registered trademark for electronic
  1063. services for the entertainment industry owned by the Pan
  1064. Network. In the event anyone may have been confused, the
  1065. utility -- which continues to be available -- has been
  1066. renamed to PANDORA. Further information regarding PAN can be
  1067. obtained by contacting THE PAN NETWORK at P.O. Box 162,
  1068. Shippack, PA 19474, (215) 584-0300.
  1069.