home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PROGRAMS / UTILS / TECLADO / PANDORA.ZIP / PANDORA.DOC < prev   
Encoding:
Text File  |  1990-11-07  |  24.3 KB  |  568 lines

  1.                                 Pandora Commands
  2.                                 ------- --------
  3.  
  4.                                (for Pandora v1.2)
  5.  
  6.                            by Pete Maclean [75776,660]
  7.  
  8. This file provides documentation on writing scripts for Pandora (originally 
  9. published as PAN).  Please note that several commands have been added since 
  10. the PAN article was published in PC Magazine.  These new commands are:  
  11. CapsLock, DOS, IfAfter, IfBefore, IfScreen, Lock, NumLock, ScrollLock, Unlock 
  12. and Mode.  The behavior of a few other commands has been changed trivially.
  13.  
  14. Commands are written one per line with any amount of white space (blanks and 
  15. tabs) thrown in before and between fields.  Each command starts with a keyword 
  16. such as "Output" or "Label".  Keywords may be written in any mixture of upper 
  17. and lower case.  String arguments may be delimited by any character although 
  18. for readability double quotes are suggested.
  19.  
  20. You can include comment lines in Pandora scripts.  Pandora treats any line 
  21. that begins with an asterisk as commentary, for example:
  22.  
  23.      * This is a comment line that Pandora ignores.
  24.  
  25. As is acknowledged in many of the command descriptions, Pandora does little 
  26. error checking.  If a script does not do what you expect, consider the 
  27. possibility that there is some error that a compiler or other typical language 
  28. processor would catch but which Pandora does not.
  29.  
  30.  
  31. Break On/Off
  32.      Sets the condition for how Pandora handles a Control-C.  If the GetKey 
  33.      command retrieves a Control-C when Break is set on then Pandora treats it 
  34.      as an abort and terminates (as long as no program is being run).  If 
  35.      Break is set off then a Control-C is handled as any other character.  
  36.      Note that Control-Breaks are not handled in any special way -- but 
  37.      this may be changed in future.
  38.  
  39. CapsLock On/Off
  40.      Simulates toggling the CapsLock key.  The argument must be "On" or "Off".
  41.      The setting of CapsLock affects keyboard input typed by the user; it
  42.      does *not* affect simulated keyboard input generated by the Key command.
  43.      To ensure that CapsLock is off when starting a program, for example, use
  44.      the command:
  45.  
  46.               CapsLock Off
  47.  
  48. Cursor <row> <column>
  49.      Repositions the cursor to a location on (or possibly off) the screen.  
  50.      As with all other commands that refer to screen coordinates, rows and 
  51.      columns are numbered from zero with the top left corner being row 0, 
  52.      column 0.  The row and column arguments are decoded as decimal integers 
  53.      and their values are not checked.  If an argument is omitted or invalid 
  54.      (i.e., non-numeric) then a default value of zero is used; *no* error 
  55.      indication is given.  The cursor can be made to "disappear" by moving it 
  56.      to a location beyond the bounds of the screen, for instance with the 
  57.      command:
  58.  
  59.                Cursor 25 0
  60.  
  61. DOS "command"
  62.    Submits a string to the DOS command interpreter.  This powerful addition to 
  63.    Pandora allows the execution of any command that you can type at the DOS 
  64.    prompt.  It can be used for such purposes as changing the current 
  65.    directory, getting directory listings, and deleting files.  All standard 
  66.    command options are supported including redirection and batch files.
  67.  
  68.      Here are some examples:
  69.  
  70.               DOS "cd \new"
  71.               DOS "del blah.dat"
  72.               DOS "E:"
  73.               DOS "call batch"
  74.               DOS "dir *.exe >tmp"
  75.  
  76.      Don't forget to enclose the command in quotes!
  77.  
  78.    Warning:  This facility in Pandora depends on the resident portion of the 
  79.    DOS Command Interpreter (COMMAND.COM) being loaded.  Pandora does its best 
  80.    to check that the requisite program is present but if your system is set up 
  81.    to use an alternate command processor then the DOS command may produce 
  82.    strange  results or hang the system.
  83.  
  84.    Further warning:  Pandora takes advantage of an undocumented feature of DOS 
  85.    to make this command work.  It should be reliable but cannot be guaranteed 
  86.    to work with all versions of DOS.
  87.  
  88.  
  89. Else
  90.      Reverses conditional execution inside an If-EndIf command group.
  91.  
  92. EndIf
  93.      Terminates the effect of an If command (i.e. IfKey, IfLoad or IfScreen).  
  94.      Every If must have a matching EndIf.
  95.  
  96. Flush
  97.      Flushes the keyboard holding buffer.  The Flush command is used mostly 
  98.      in association with the GetKey command to discard any accumulated key
  99.      codes before soliciting a keypress.
  100.  
  101. GetKey
  102.      Waits for the user to depress a key on the keyboard which then becomes 
  103.      available for testing with the IfKey command.
  104.  
  105. Go "arguments"
  106.      Initiates execution of a program that has been loaded with a Load or
  107.      IfLoad command.  The program is run as if it had been started from the
  108.      DOS prompt with the given argument string.
  109.  
  110. IfAfter <time>
  111.      Tests if the time kept by DOS is equal to or greater than the time given.  
  112.      The argument should be expressed in the format HH:MM using the 24-hour 
  113.      system.  For example, the following will hold true if it is 10:15 pm or
  114.      later:
  115.  
  116.               IfAfter 22:15
  117.  
  118. IfBefore <time>
  119.     Tests if the time maintained by DOS is before that specified.  As with the 
  120.     previous command, the time must be expressed in the form HH:MM where HH is 
  121.     an hour in the range 0 to 24 and MM is a minute in the range 0 to 59.  The 
  122.      following command, for instance, will hold true if it is earlier than
  123.      6:05 am:
  124.  
  125.               IfBefore 6:05
  126.  
  127. IfKey "list"
  128.      Tests if the last keypress (that captured by a GetKey command) matches 
  129.      one of those in the given list.  If there is a match the subsequent      
  130.      commands are executed.  If the match fails then command execution is      
  131.      inhibited until a matching Else or EndIf command is encountered.
  132.      The following command, by way of example, would result in a match if
  133.      the key in question was any digit:
  134.  
  135.                IfKey "1234567890"
  136.  
  137. IfLoad "file"
  138.      Attempts to load a program into memory for subsequent execution.  The
  139.      argument supplies the filename in which the extension ("EXE" or "COM")
  140.      must be included.  Execution of the loaded program does not start until
  141.      a Go command is performed.  The commands following the IfLoad are
  142.      performed if the load is successful; if it fails, the commands following
  143.      an Else or EndIf are performed.  For example:
  144.  
  145.                IfLoad "c:\program.com"
  146.                     Output "The program has been loaded succesfully!^M^J"
  147.                     Go
  148.                     Quit
  149.                Else
  150.                     Output "The program could not be loaded!^M^J"
  151.                     Quit
  152.                EndIf
  153.  
  154. IfScreen <row> <column> "string"
  155.      Checks if the given string appears on the screen at the given position.
  156.      (This command, obviously, is closely related to WaitScreen.)  For
  157.      example:
  158.  
  159.                IfScreen 24 0 "OK"
  160.                     Jump success
  161.                EndIf
  162.                IfScreen 24 0 "Error"
  163.                     Quit
  164.                EndIf
  165.  
  166.      Checks for two strings that a program may display, and takes appropriate
  167.      action for each.
  168.  
  169. Jump label
  170.      Transfers control to the given label (defined in a Label command).
  171.  
  172. Key "string"
  173.      Feeds the given string of characters to the running program by
  174.      entering them, one by one, into the keyboard holding buffer.  This
  175.      simulates a user typing the same characters at the keyboard.  This
  176.      example has the equivalent effect of a user typing "Yes" then pressing
  177.      the Enter key:
  178.  
  179.                Key "Yes[Enter]"
  180.  
  181.      The Key command is valid only when Pandora is running a program.
  182.  
  183. Label label
  184.      Defines a label that can be used as the object of a Jump command.  This
  185.      command is a no-operation in most respects.
  186.  
  187. Load "file"
  188.      Loads a program into memory for subsequent execution.  The argument 
  189.      supplies the filename in which the extension ("EXE" or "COM") must be 
  190.      included.  Execution of the loaded program does not start until a Go 
  191.      command is performed.  Should the load fail for any reason, Pandora emits
  192.      a suitable diagnostic and quits.  If the user wishes Pandora to maintain
  193.      control after a failed load then the IfLoad command should be used
  194.      instead.
  195.  
  196. Lock
  197.     This command locks the keyboard.  If you want Pandora to have full control
  198.     over keyboard input to the target program then you should use this
  199.     command at an appropriate point.  Locking the keyboard prevents
  200.     user keypresses from getting interspersed with the simulated input
  201.     generated by Pandora's Key commands.
  202.  
  203.      After a Lock, the keyboard remains locked until either an Unlock
  204.      command is performed or Pandora quits.  If the user presses a key while
  205.      the keyboard is locked, the system beeps and otherwise the action is
  206.      ignored.  (In fact, the behavior is identical to that taken by DOS
  207.      when the type-ahead buffer is full.)
  208.  
  209. Mode
  210.      Commands such as Screen and IfScreen operate by delving into the video
  211.      buffer, that is the block of memory that holds a character-by-character
  212.      image of what appears on the screen.  When Pandora starts up it determines
  213.      the memory address for the current screen buffer and then uses that
  214.      same address whenever the need arises.  Some programs change the video
  215.      mode; in such a case the address of the effective video buffer may
  216.      change too.  The Mode command forces Pandora to reevaluate the address 
  217.      for the video buffer.
  218.  
  219.      Very few people will need the Mode command, especially as Pandora offers
  220.      so little assistance in automating graphics applications.  Should you
  221.      write a script and find that Output commands do not take effect then
  222.      consider the possibility that you need to add a Mode command.
  223.  
  224. NumLock On/Off
  225.      Simulates toggling the NumLock key.  The argument must be "On" or "Off".
  226.      The setting of NumLock affects keyboard input typed by the user; it
  227.      does *not* affect simulated keyboard input generated by the Key command.
  228.      To ensure that NumLock is off when starting a program, for example, use
  229.      the command:
  230.  
  231.               NumLock Off
  232.  
  233. Output "string"
  234.      Displays a string on the screen at the current cursor location.  The
  235.      cursor is updated in the process.  The Output command should be used
  236.      to display stuff when animating applications that use the screen in a
  237.      simple scrolling manner (like DOS utilities).  The Screen command, by
  238.      contrast, should be used with screen-oriented applications.  Because
  239.      Output invokes a DOS service to write to the screen, it cannot be used
  240.      while Pandora is running a program.  Here is an example:
  241.  
  242.                Output "This string scrolls onto the screen.^M^J"
  243.  
  244.      The "^M^J" part stands for a carriage return plus a linefeed.
  245.  
  246. Pause <n> Ticks/Seconds/Minutes
  247.      Pauses for the specified period.  Permissible times are:
  248.                1 - 255 ticks
  249.                1 - 255 seconds
  250.          or    1 - 60  minutes
  251.      A tick refers to the period between clock ticks on a standard PC; such
  252.      ticks occur at a rate of 18.2 to a second. The following example 
  253.      invokes a delay of two and a half minutes:
  254.  
  255.                Pause 2 minutes
  256.                Pause 30 seconds
  257.  
  258.      Pandora interprets only the first letter of the units field, looking for
  259.      't', 's' or 'm'.  If the units field is omitted, Pandora assumes seconds.
  260.  
  261. Quit
  262.      Terminates Pandora.  If Pandora is not running a program then it quits
  263.      immediately.  If Pandora is running a program then it quits only when
  264.      that program quits.
  265.  
  266. Screen <row> <column> "string"
  267.      Writes a string of characters to the screen starting at the character
  268.      position defined by the <row> and <column> arguments. The operation is 
  269.      performed using a direct write to the video buffer.  For example:
  270.  
  271.            Screen 10 40 "This appears on line 10 starting at column 40"
  272.  
  273.     Note that for this, as for all purposes in Pandora, rows are numbered from 
  274.     0 to 24 and columns from 0 to 79.  The video attribute used is that set by
  275.     the last Video command.
  276.  
  277. ScrollLock On/Off
  278.      Simulates toggling the ScrollLock key.  The argument must be "On" or 
  279.      "Off".
  280.  
  281. TypeRate <ticks>
  282.      Controls the rate at which characters are fed by the Key command into 
  283.      the keyboard holding buffer.  For most situations setting the TypeRate 
  284.      to zero is the best choice; then the keys are fed to the animated 
  285.      program as fast as it will accept them.  If you want the user to 
  286.      clearly see what is being "typed" then set the TypeRate to some number 
  287.      between 2 and 9.  The number represents the count of 18.2-to-a-second 
  288.      ticks that are skipped between each pair of keyed characters.
  289.  
  290. Unlock
  291.      Unlocks the keyboard if it was previously locked by a Lock command.  If
  292.      the keyboard is not locked then this command does nothing.
  293.  
  294. Video <attribute>
  295.      Sets a video attribute for writes by subsequent Screen commands.
  296.      The argument is interpreted as a hexadecimal number.  The default screen
  297.      attribute (70 hex) is for white foreground and black background.
  298.  
  299. WaitChild
  300.      Suspends Pandora activity until the animated program terminates.
  301.  
  302. WaitScreen <row> <column> "string"
  303.      Waits for the given string to appear on the screen starting at the
  304.      given position.  Pandora continually searches for the string in the video 
  305.      buffer.  Use this command with care:  Pandora will wait forever if 
  306.      necessary for the string to appear and there may be no way to interrupt 
  307.      the wait other than by pressing Ctrl-Alt-Del.
  308.  
  309. WaitUntil <time>
  310.      Suspends activity until the given time of day.  Times should be 
  311.      expressed using 24-hour-clock notation.  Thus to wait until 10:15 pm, 
  312.      one should code:
  313.  
  314.                WaitUntil 22:15
  315.  
  316. Wipe
  317.      Clears the screen.  (A BIOS function is used to do this.)
  318.  
  319.  
  320.  
  321. Key strings
  322. --- -------
  323. A string provided as an argument to the Key or IfKey command contains symbols 
  324. identifying keys on the standard IBM keyboard.  With the IfKey command, the 
  325. string expresses a list of keys to be matched to the last keypress; the order 
  326. in which the keys are expressed is immaterial.
  327.  
  328. The rules for naming keys are as follows:
  329.  
  330.      Any printable character (except '~' or '[') represents the key that
  331.      generates it.
  332.           e.g., "ABC..., abc..., 123..., !#$%&*()-=+\|`;:'".,/?><{}"
  333.  
  334.      The caret (^) and open square bracket ([) are used as escape characters
  335.      and if intended literally must be doubled.
  336.           e.g., "^^ signifies a caret and [[ a bracket."
  337.  
  338.      A named key is represented by the name in square brackets.
  339.           e.g., "[Esc] [Home] [End] [Enter] [Ins] [Del] [PgUp] and [PgDn]"
  340.           and   "[F1] [F2] [F3] [F4] [F5] [F6] [F7] [F8] [F9] and [F10]"
  341.  
  342.      Arrow keys are identified as follows: [Up], [Down], [Left] and [Right].
  343.  
  344.      A pure ASCII or extended-ASCII code, equivalent to that generated at the
  345.      keyboard by holding down the Alt key and entering a decimal code on
  346.      the numeric keypad, can be indicated by putting the appropriate number
  347.      in square brackets.
  348.           e.g. "[227] becomes a pi."
  349.  
  350.      Any character may be prefaced by one or more shift indicators:
  351.      [Alt], [Ctrl] or [Shift].  The caret is an alternative for [Ctrl].
  352.  
  353.      Literal control characters should not be included in strings.  Any
  354.      that are present will be ignored.  Use the ^[key] or [Ctrl][key] 
  355.      notation.
  356.  
  357. I acknowledge that this scheme for naming characters is not complete.  One 
  358. cannot enter F11 or F12, for example, nor can one distinguish between the two 
  359. Enter keys.
  360.  
  361. Here are some examples of key names:
  362.  
  363.      [Alt][F10]      Alt-F10
  364.      [Shift]2        @        (more simply expressed just by @ itself)
  365.      [Esc]           Esc
  366.      ^[[             Esc
  367.      [Ctrl][Enter]   Ctrl-Enter
  368.      [3]             Ctrl-C   (^C would be more usual, however)
  369.      ^2              Null
  370.  
  371.  
  372. Other strings
  373. ----- -------
  374. Strings supplied as arguments to commands such as Screen and Output may 
  375. contain printable characters representing themselves and control characters 
  376. expressed in the common keyboard-equivalent notation.  Control-X is indicated 
  377. by a caret followed by an X (that is, '^X') for any suitable X.  In this 
  378. notation, carriage return is '^M' and linefeed is '^J'.  A literal caret is 
  379. expressed by doubling the character, that is by '^^'.
  380.  
  381.  
  382. Some tips for creating Pandora scripts
  383. ---- ---- --- -------- --- -------
  384. Use the Cursor and Output commands with programs, such as DOS utilities, that 
  385. write their screen output in scrolling or teletype fashion.  Use the Screen 
  386. command with programs that do full-screen output.
  387.  
  388. Don't let yourself get confused by the differences between key strings (used 
  389. with Key and IfKey) and character strings (used with other commands).  The 
  390. latter style of string is a standard in programming but a key string will be 
  391. new to many people.  Remember that a key string identifies a sequence of codes 
  392. generated by keys on a keyboard, including many for which there are no 
  393. equivalent characters.  In a key string, for example, "[Home]" serves to 
  394. identify a particular key while in a character string it represents a sequence 
  395. of six characters: [-H-o-m-e-].
  396.  
  397. Pandora can be used to run a sequence of programs or one program repeatedly.  
  398. After one program terminates and Pandora regains control with a WaitChild 
  399. command, another Load and Go can be issued.
  400.  
  401. If you are animating a large program, you may need to watch the length of your 
  402. Pandora script.  The presence of comment lines never hurts because they are 
  403. stripped off as the script is loaded.  Also it never costs to indent commands 
  404. because leading whitespace on a line is also removed.  Ways of reducing memory 
  405. requirements for a script include keeping labels short (say to two characters) 
  406. and limiting each field separator to a single character.
  407.  
  408.  
  409.                          What's New in Pandora 1.4
  410.                          ------ --- -- ------- ---
  411.  
  412.                          Pete Maclean  [75776,660]
  413.  
  414. Keyboard Control
  415. -------- -------
  416. I added some commands so that I could experiment with using Pandora to control 
  417. pop-up memory-resident programs with hot keys.  The commands are Alt, Ctrl, 
  418. LeftShift and RightShift.  Each takes an argument of On or Off.  The effect of,
  419. for example:
  420.  
  421.               Alt On
  422.  
  423. is to duplicate pressing the Alt key on the keyboard.  Suppose that you have a 
  424. memory-resident program that pops up when you press both shift keys 
  425. simultaneously; then you can make Pandora pop it up with the commands:
  426.  
  427.               LeftShift On
  428.               RightShift On
  429.  
  430. Note that once you have used such a command, the effect is as if you had 
  431. pressed the equivalent key and remained pressing it.  To release the key, you 
  432. must give a command such as:
  433.  
  434.               LeftShift Off
  435.  
  436. otherwise you may experience strange keyboard behavior.
  437.  
  438. Also please note that these commands, like CapsLock etc., affect only the real 
  439. keyboard.  They have no effect on simulated keyboard input generated by the Key 
  440. command.
  441.  
  442.  
  443.                          What Was New in Pandora 1.3
  444.                          ---- --- --- -- ------- ---
  445.  
  446. Screen Handling
  447. ------ --------
  448. Thanks to some better understanding that I have gained of PC video modes and 
  449. BIOS screen functions, I have improved Pandora's screen handling in various 
  450. ways.  The Wipe command is now implemented in a completely different way and 
  451. should work consistently.  (Previously, it sometimes had no effect and 
  452. sometimes changed the video mode.)  The Mode command is also improved and gives
  453. an error if an application program sets a video mode that Pandora cannot handle
  454. (i.e., a graphics mode).
  455.  
  456. Please note that Pandora is not designed for use with graphics-mode programs.  
  457. You may, nevertheless, be able to automate such programs with Pandora as long as 
  458. you scrupulously avoid all commands that affect the screen:  Mode, Screen, 
  459. IfScreen, WaitScreen and Wipe.
  460.  
  461.  
  462. Environment Tables
  463. ----------- ------
  464. Several early users had trouble getting Pandora to pass on the desired 
  465. environment to its children.  To accomodate all needs I have added an Env 
  466. command to select between two options.  The valid forms of the command are:
  467.  
  468.      Env Own
  469.      Env Master
  470.  
  471. The "Own" argument tells Pandora to pass on copies of its own environment.  This 
  472. is the default.  The "Master" argument tells Pandora to pass on copies of the 
  473. master environment.  Note that if you use Pandora's DOS command to change 
  474. environment strings, as in:
  475.  
  476.      DOS "Set magic=teapot"
  477.  
  478. it is the master environment that is affected.
  479.  
  480. The issue of which environment gets inherited is tricky.  If you see no reason 
  481. to care then don't worry about it; the default should suit you.
  482.  
  483.  
  484.                          What Was New in Pandora 1.2
  485.                          ---- --- --- -- ------- ---
  486.  
  487. For legal reasons the program, originally known as PAN, was renamed Pandora.  
  488. This change keeps it nicely in line with my previous PC Magazine utilities Bess 
  489. and Emma.
  490.  
  491.  
  492. CapsLock/NumLock/ScrollLock
  493. ---------------------------
  494. Three commands were added for setting the condition of CapsLock, NumLock, and 
  495. ScrollLock.  The commands follow the keynames and take an argument of "On" or 
  496. "Off".  To set CapsLock on, for example, the appropriate command is:
  497.  
  498.               CapsLock On
  499.  
  500. Note that these lock keys affect only characters typed by the user on the 
  501. keyboard.  They do *not* affect the interpretation of arguments to Pandora's 
  502. Key command.  Thus, the command:
  503.  
  504.               Key "abc"
  505.  
  506. delivers the precise string "abc" to the running program irrespective of the 
  507. CapsLock setting.
  508.  
  509. My thanks to Fran Finnegan for suggesting this enhancement.
  510.  
  511.  
  512.                          What Was New in PAN version 1.1
  513.                          ---- --- --- -- --- ------- ---
  514.  
  515. Three new commands have been added in this first update to PAN:  DOS, IfAfter, 
  516. and IfBefore.  In addition, the IfScreen command has been fixed and a couple of 
  517. other minor bugs corrected.
  518.  
  519. PAN is known to have problems operating with certain screen and printer drivers.  
  520. These are being investigated.  Also it is known that PAN does not work correctly 
  521. with WordPerfect.
  522.  
  523. Here rae descriptions of the new commands:
  524.  
  525. DOS "command"
  526.      Submits a string to the DOS command interpreter.  This powerful addition to 
  527.      PAN allows the execution of any command that you can type at the DOS 
  528.      prompt.  It can be used for such purposes as changing the current 
  529.      directory, getting directory listings, and deleting files.  All standard 
  530.      command options are supported including redirection and batch files.
  531.  
  532.      Here are some examples:
  533.  
  534.               DOS "cd \new"
  535.               DOS "del blah.dat"
  536.               DOS "E:"
  537.               DOS "call batch"
  538.               DOS "dir *.exe >tmp"
  539.  
  540.      Don't forget to enclose the command in quotes!
  541.  
  542.      Warning:  This facility in PAN depends on the resident portion of the DOS 
  543.      Command Interpreter (COMMAND.COM) being loaded.  PAN does its best to check 
  544.      that the requisite program is present but if your system is set up to use 
  545.      an alternate command processor then the DOS command may produce strange 
  546.      results or hang the system.
  547.  
  548.      Further warning:  PAN takes advantage of an undocumented feature of DOS to 
  549.      make this command work.  It should be reliable but cannot be guaranteed to 
  550.      work with all versions of DOS.
  551.  
  552. IfAfter <time>
  553.      Tests if the time kept by DOS is equal to or greater than the time given.  
  554.      The argument should be expressed in the format HH:MM using the 24-hour 
  555.      system.  For example, the following will hold true if it is 10:15 pm or
  556.      later:
  557.  
  558.               IfAfter 22:15
  559.  
  560. IfBefore <time>
  561.      Tests if the time maintained by DOS is before that specified.  As with the 
  562.      previous command, the time must be expressed in the form HH:MM where HH is 
  563.      an hour in the range 0 to 24 and MM is a minute in the range 0 to 59.  The 
  564.      following command, for instance, will hold true if it is earlier than
  565.      6:05 am:
  566.  
  567.               IfBefore 6:05
  568.