home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1996 October / PCO_10.ISO / filesbbs / hyperp.arj / BULLET2 < prev    next >
Encoding:
Text File  |  1990-01-06  |  5.1 KB  |  101 lines

  1. Bulletin 2 - A discussion of techniques for writing scripts
  2.  
  3. The following is a discussion about HyperPilot scripts.  The purpose of 
  4. this bulletin is to provide you with some application information that may 
  5. not be found in the HyperACCESS/5 manual.  These discussions will largely 
  6. be based on question that are frequently asked of our Product Support 
  7. Department.  This bulletin will be updated as questions and application 
  8. notes arise.  Your contributions and questions are welcome.
  9.  
  10. Subject: Error checking
  11.  
  12.      Many HyperPilot functions return a TRUE or FALSE result.  This result 
  13.      can be used to determine the success or failure of a particular 
  14.      function.  For example, the function: wait text("password:",10) will 
  15.      return a TRUE result if the match is successful within 10 seconds, 
  16.      otherwise it will return FALSE.
  17.      
  18.      One common mistake is to use these functions without checking the 
  19.      return value.  A better approach would be to include error processing 
  20.      logic to these functions.  Look at these two examples:
  21.      
  22.           Case 1:         wait text("password:",10)
  23.                           prompt("wait text was successful")
  24.            
  25.           Case 2:         ifnot wait text("password:",10) branch(100)
  26.                           prompt("wait text was successful")          
  27.           
  28.      In the first case,  if the wait text() function fails, one of two 
  29.      outcomes will occur.  First, if your script includes a label(990), 
  30.      a branch to that label will be executed (more on label(990) later).  
  31.      Second, if label(990) does not exist, an error message will appear on 
  32.      the Comm screen that points to the offending line in your HyperPilot 
  33.      script, and the script ends.  If the wait text() function returns a 
  34.      TRUE, the next script command is executed.
  35.      
  36.      In the second case, there is no question as to what will happen if 
  37.      the wait text() function fails.  The script will branch to 
  38.      label(100).  Again, if the function is successful the next line 
  39.      will be executed.
  40.      
  41.      This error trapping becomes very important if you are automating a 
  42.      process that is going to be unattended.  You don't want an error 
  43.      message to appear if nobody is around to clear the message.  It's 
  44.      also important if you're providing an automated solution for someone 
  45.      that may not understand how to recover from such an error.
  46.      
  47.      Although it takes longer to write scripts that contain good error 
  48.      checking, in the long run you'll be better off.  You don't need 
  49.      to perform this error checking on every HyperPilot function that you 
  50.      use.  Using label(990) along with some of this error checking logic in 
  51.      critical places will make for reliable scripts.
  52.  
  53. Subject: label(990)
  54.      
  55.      You can create a general purpose error trapping routine by using a 
  56.      label(990) in you scripts.  A branch to this label will take place 
  57.      whenever a HyperPilot function that returns a TRUE/FALSE value is 
  58.      used without conditional statements (if or ifnot), and that function 
  59.      fails.  This can provide for an effective method of trapping errors 
  60.      without using the 'if' or 'ifnot' conditions on every HyperPilot 
  61.      function.  Example:
  62.      
  63.      label(100)
  64.        prompt("Running this example will cause a branch to label(990)/r")
  65.        wait match("this will never match", 10)
  66.        prompt("This line should never be displayed")
  67.            
  68.      label(990)
  69.        prompt("A HyperPilot function has failed")
  70.        end()
  71.        
  72.  
  73. Subject: Variable input through scripts
  74.  
  75.      Learning a command or macro that accepts variable input is a 
  76.      snap with HyperACCESS/5.  You simply need to use the learning 
  77.      options as they appear when you press ALT-L.  This is easy if 
  78.      you're learning, but not so straight forward if you're writing a 
  79.      script.  Lets say that in the middle of your script, you wanted 
  80.      to go off to the System settings menu and change the baud rate, 
  81.      but you didn't want to hard code that rate into the script.  
  82.      Instead, you could pause the script at that menu option and 
  83.      allow the user of the script to enter the appropriate rate.  The 
  84.      following demonstrates this approach: 
  85.  
  86.           prompt("/nThis displays on the Comm screen, as do all")
  87.           prompt("/nHyperPilot scripts.  But the following type")
  88.           prompt("/ncommand will go to the System settings menu")
  89.           prompt("/nand wait for you to enter in a baud rate.") 
  90.           wait seconds(10)
  91.           type("<ALT-M>DM<ENTER>R<ALT-L>VKE<ALT-C>")
  92.           prompt("/n/nNow we're back on the Comm screen!")
  93.           end()
  94.  
  95.      The trick here is the ALT-L VKE portion of the type command.  
  96.      This tells HA5 to accept (V)ariable input from the (K)eyboard, 
  97.      and that (E)nter will terminate the input.  The E portion of 
  98.      this type command could have also been an 'A'.  This would 
  99.      have allowed the user to continue working on any of the menus 
  100.      (after entering a baud rate), until ALT-R was pressed.
  101.