home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / TELIX.ZIP / TELIX351.DAT / SIMPLE.DOC < prev    next >
Text File  |  1996-05-01  |  55KB  |  1,651 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.      T E L I X
  27.  
  28.      ────────────────────────────────────────────────────────────
  29.  
  30.      SIMPLE Programming Manual
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.                 Copyright (C) 1986-96 deltaComm Development, Inc.
  43.  
  44.                               ALL RIGHTS RESERVED.
  45.  
  46.  
  47.  
  48.  
  49.                            deltaComm Development, Inc.
  50.  
  51.                       P.O. Box 1185, Cary, NC  27512   USA
  52.  
  53.             (919)-460-4556 / (919)-460-4531 fax / (919)-481-9399 BBS
  54.      Telix v3.5x - SIMPLE Programming                       COPYRIGHT    ii
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.                                 Copyright Notice
  63.  
  64.  
  65.  
  66.  
  67.  
  68.      Telix is Copyright (c) 1986-1996 by deltaComm Development, Inc.
  69.  
  70.      SIMPLE is Copyright (c) 1990-1996 by deltaComm Development, Inc.
  71.  
  72.      This document is Copyright (c) 1990-1996 by deltaComm Development, Inc.
  73.  
  74.      No parts of Telix or this document may be copied in part or in whole,
  75.      except as provided in the License in the following pages.
  76.  
  77.  
  78.  
  79.  
  80.  
  81.      Disclaimer
  82.  
  83.      deltaComm Development, Inc., makes no warranty of any kind, either
  84.      express or implied, including but not limited to implied warranties of
  85.      merchantability and fitness for a particular purpose, with respect to
  86.      this software and accompanying documentation.
  87.  
  88.      IN NO EVENT SHALL DELTACOMM DEVELOPMENT, INC., BE LIABLE FOR ANY DAMAGES
  89.      (INCLUDING DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
  90.      LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING OUT OF THE
  91.      USE OF OR INABILITY TO USE THIS PROGRAM, EVEN IF DELTACOMM DEVELOPMENT,
  92.      INC., HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
  93.  
  94.  
  95.  
  96.      Trademarks
  97.  
  98.      Telix is a trademark of deltaComm Development, Inc.
  99.  
  100.      SIMPLE is a trademark of deltaComm Development, Inc.
  101.  
  102.      SALT is a trademark of deltaComm Development, Inc.
  103.  
  104.      Many product names found throughout this manual are trademarks of var-
  105.      ious companies.
  106.      Telix v3.5x - SALT Programming                         Contents    iii
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.                                  C O N T E N T S
  118.  
  119.  
  120.  
  121.      1.  The Telix SIMPLE Language........................................1
  122.          1.1  What Can Be Accomplished With Simple?.......................1
  123.          1.2  Comparing SIMPLE to SALT....................................1
  124.          1.3  Creating SIMPLE Scripts.....................................1
  125.  
  126.      2.  Syntax...........................................................3
  127.  
  128.      3.  Program Structure................................................5
  129.          3.1  .i.Variables................................................5
  130.          3.2  System Variables............................................5
  131.  
  132.      4.  Built-in Functions...............................................7
  133.  
  134.      5.  Program Control.................................................25
  135.          5.1  The Waitfor Command........................................25
  136.          5.2  The If Command.............................................26
  137.          5.3  The Whenever Loop..........................................30
  138.  
  139.      6.  Index...........................................................33
  140.      Telix v3.5x - SIMPLE Programming                     Introduction    1
  141.  
  142.  
  143.  
  144.  
  145.  
  146.      1.  The Telix SIMPLE Language
  147.  
  148.  
  149.      Telix has a built-in programming language called SALT (Script
  150.      Application Language for Telix).  SALT is extremely powerful, and much
  151.      of that power is due to its semblance to the C programming language.
  152.      Along with that power comes a degree of difficulty, however.  For
  153.      those not comfortable in a structured programming environment such as
  154.      SALT, a second scripting language, SIMPLE (Salt IMPLEmentation) is
  155.      also provided.
  156.  
  157.      Simple takes a loosely structured program resembling a stream of
  158.      English sentences and transforms it into SALT for you. No programming
  159.      experience is necessary.  Its SIMPLE!
  160.  
  161.  
  162.  
  163.      1.1  What Can Be Accomplished With Simple?
  164.      ──────────────────────────────────────────────────────────────────────
  165.  
  166.      SIMPLE scripts can be used to automate logins to bulletin boards,
  167.      automate repetitive tasks such as mail transfers, or can be programmed
  168.      to watch for multiple strings, offering up the proper response to each
  169.      no matter the order in which they arrive.  SIMPLE offers you much of
  170.      the power of SALT without the learning curve.
  171.  
  172.  
  173.  
  174.      1.2  Comparing SIMPLE to SALT
  175.      ──────────────────────────────────────────────────────────────────────
  176.  
  177.      SALT's complexity allows it to do much more than SIMPLE can.  For
  178.      example, the Host+ bulletin board that comes with Telix was written
  179.      primarily in SALT, but such a task would not be possible in SIMPLE.
  180.      SALT offers access to most screen-related functions in Telix; SIMPLE
  181.      offers only a pair of commands to place information on the screen.
  182.      SALT offers full color control; SIMPLE does not.  Other differences
  183.      make SALT the preferable language for complex scripts.
  184.  
  185.      If your copy of Telix is registered, the SIMPLE compiler, CSS can
  186.      leave a copy of the translated script on your hard drive in SALT
  187.      source format.  SIMPLE is primarily a tool for helping you to master
  188.      SALT, and study of these translations are an excellent way to get
  189.      started.
  190.  
  191.  
  192.  
  193.      1.3  Creating SIMPLE Scripts
  194.      ──────────────────────────────────────────────────────────────────────
  195.  
  196.      A SIMPLE script is basically a sequence of instructions for Telix to
  197.      follow, using a loosely defined syntax.  You may use any text editor
  198.      to produce this script file, as long as its output is normal ASCII
  199.      text (this means that if you use your word processor, you must
  200.      Telix v3.5x - SIMPLE Programming                     Introduction    2
  201.  
  202.  
  203.  
  204.  
  205.  
  206.      explicitly tell it to write out the file using ASCII format and not to
  207.      embed any special codes in the file).  You may give any name you wish
  208.      to a SIMPLE script, although we recommend that you always use the
  209.      extension .SIM for clarity.  For example, a script to log on to the
  210.      Telix Support BBS might be called TELIX.SIM.
  211.  
  212.      Once you have written you script file and saved it to disk, it must be
  213.      compiled.  The program CSS.EXE included with Telix reads your "source"
  214.      script and compiles it into a form which Telix can understand.  The
  215.      compiled script can be loaded more quickly by Telix, and is also
  216.      smaller.
  217.  
  218.      To compile a SIMPLE script file, type:
  219.  
  220.           CSS <SIMPLEname> <SALTname>
  221.  
  222.      <SIMPLEname> is the name of the script we are trying to compile, and
  223.      <SALTname> is the optional name of the SALT source file to create.
  224.      <SALTname> may only be used with registered versions of Telix.
  225.  
  226.      CSS knows the naming conventions of Telix, and expects that an input
  227.      file ends in .SIM and an output file ends in .SLT, so you may simply
  228.      type:
  229.  
  230.           CSS TELIX TELIX
  231.  
  232.      If you do not supply an output name, CSS assumes the output name is
  233.      the input name followed by .SLC.  The simplest way to compile
  234.      TELIX.SIM is:
  235.  
  236.           CSS TELIX
  237.  
  238.      The CS.EXE SALT compiler must be in the DOS path in order to use CSS.
  239.  
  240.      When the script compiler finds an error in your source file, it will
  241.      abort the compile process and give you the line number on which the
  242.      error occurred, as well as the type of error.  The error should then
  243.      be fixed and the source recompiled.  This is repeated until the
  244.      compiled detects no more errors in your script file.
  245.  
  246.      The compiled script can then be run in Telix using several methods.
  247.      It may be run using the 'Run Script' command, as a command line
  248.      parameter to Telix, as a linked script to a dialing directory entry
  249.      (i.e. automatically, when you connect to a system), or from another
  250.      script.  The first three methods are described in the Telix manual,
  251.      while the last is described later in this manual.
  252.      Telix v3.5x - SIMPLE Programming                           Syntax    3
  253.  
  254.  
  255.  
  256.  
  257.  
  258.      2.  Syntax
  259.  
  260.  
  261.      Case is not important in command, function, and variable names. The
  262.      only time case matters is inside a string constant (e.g., "Hello" is
  263.      not the same string as "hello"). Whitespace (such as the space, the
  264.      tab, the Carriage Return, or the Line Feed character) is not impor-
  265.      tant. The script compiler does not care where you place items, so that
  266.      you may arrange the program as you see fit. For example,
  267.  
  268.           If Online Then Send String25
  269.           Else Dial "11" MaxOf 23 RunScript
  270.  
  271.      is equivalent to
  272.  
  273.           If Online Then
  274.             Send String25
  275.           Else
  276.             Dial "11" MaxOf 23 RunScript
  277.  
  278.      or even to
  279.  
  280.           If
  281.           Online
  282.           Then
  283.           Send
  284.           String25
  285.           Else
  286.           Dial
  287.           "11"
  288.           MaxOf
  289.           23
  290.           RunScript
  291.  
  292.      The only time whitespace matters is when it would split up key-words
  293.      or function name, or in a string. For example, the key-word 'whenever'
  294.      must not be split up if it is to be recognized. The same applies to
  295.      other key-words or function names. As well, there must be space be-
  296.      tween the letters of a command and other letters. For example,
  297.      'whenever' is not the same as 'wheneverabc'. In the interest of
  298.      clarity, it is recommended that you try to make your script easy to
  299.      understand, by indenting where appropriate, and by using space ef-
  300.      fectively. There is no reason, for example, to put more than one
  301.      statement on a line, even if it is perfectly legal. Another poor
  302.      example above, however, is one where a complete line is broken up for
  303.      no good reason.  A good example of program style can be found by
  304.      looking at the sample SIMPLE scripts included with Telix.
  305.  
  306.      A string constant is a sequence of ASCII characters enclosed in
  307.      quotes, for example, "Hello", "Good-bye", or "Telix".  String
  308.      constants and their use are discussed later.
  309.      Telix v3.5x - SIMPLE Programming                 Program Structure   5
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.      3.  Program Structure
  317.  
  318.      A SIMPLE script has no set format beyond a few easy-to-follow rules.
  319.      These rules will be discussed as the apply to the individual commands
  320.      when necessary.  Otherwise, simply add commands to your script to do
  321.      whatever is necessary.
  322.  
  323.      It is highly recommended that you read this manual sequentially, as
  324.      each command builds on the last.  By the end of the manual we will
  325.      have worked into more complex examples, and will actually construct a
  326.      script to log on to the Telix Support BBS.
  327.  
  328.  
  329.      3.1  Variables
  330.      ──────────────────────────────────────────────────────────────────────
  331.  
  332.      A SIMPLE script may use up to 255 string "variables", or groups of
  333.      characters that you can change as you see fit.  You need not do
  334.      anything special to use a string.  Just use the word "StringXX"
  335.      wherever you need the string, where XX is the number the string.  All
  336.      SIMPLE strings are exactly 80 characters in length.  These will be
  337.      referred to as StringXX variables throughout this documentation.
  338.      Examples of StringXX use might be as follows:
  339.  
  340.      To create string number 20, and make it contain the phone number of
  341.      the Telix BBS, you might have a line:
  342.  
  343.      Assign String20, "1-919-481-9399"
  344.  
  345.      Note that you do not have to use all 80 characters of a string.
  346.      SIMPLE knows where to end a string if you don't fill it up.
  347.  
  348.      To create a string that contains today's date, you could simply use:
  349.  
  350.      Date String15
  351.  
  352.      If you need to use either the quote character itself in a string, or
  353.      the carat symbol (the shitfed-6), both have special meaning in Telix,
  354.      and must be dereferenced.  To dereference the character, precede it
  355.      with a carat.  Examples of this are:
  356.  
  357.      Assign String1, "A quote, ^", needs a carat in front."
  358.  
  359.      Assign String2, "A carat, ^^, is represented by two carats."
  360.  
  361.  
  362.      3.2  System Variables
  363.      ──────────────────────────────────────────────────────────────────────
  364.  
  365.      SIMPLE has four system variables which may be used as part of certain
  366.      statements.  Their use will be explained in greater detail as part of
  367.      the commands that may access them.  These variables are:
  368.      Telix v3.5x - SIMPLE Programming                 Program Structure   6
  369.  
  370.  
  371.  
  372.  
  373.  
  374.      BBSNumber:     This variable will contain the dialing directory entry
  375.                     number after dialing and connecting to a system.  It
  376.                     changes only when a connection is made.
  377.  
  378.      TransferStatus:This variable will contain the result code of a file
  379.                     transfer performed in SIMPLE. The values of these
  380.                     results will be explained later in the documentation as
  381.                     part of file transfers.
  382.  
  383.      ReturnCode:    This variable is explained in detail under the If
  384.                     directive in chapter 5.
  385.  
  386.      BBSPassword:   This variable contains your password for the system you
  387.                     last connected to, as read from the dialing directory.
  388.                     This variable makes it possible to write a script that
  389.                     doesn't have to be recompiled every time you change
  390.                     your password.  The script can just use this variable
  391.                     instead of a String variable.  All you need to do when
  392.                     changing your password is to edit the dialing directory
  393.                     within Telix, and insert the new password.
  394.      Telix v3.5x - SIMPLE Programming                Built-in Functions   7
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.      4.  Built-in Functions
  402.  
  403.  
  404.  
  405.      ALARM
  406.      ──────────────────────────────────────────────────────────────────────
  407.  
  408.      ■  Summary
  409.  
  410.      Alarm <integer>
  411.  
  412.      ■  Description
  413.  
  414.      The Alarm function causes an alarm sound (similar to the connect alarm
  415.      of Telix) to ring for <integer> seconds.
  416.  
  417.      ■  Example
  418.  
  419.      Alarm 5
  420.  
  421.  
  422.  
  423.      ASSIGN
  424.      ──────────────────────────────────────────────────────────────────────
  425.  
  426.      ■  Summary
  427.  
  428.      Assign <String1>, <String2>
  429.  
  430.      ■  Description
  431.  
  432.      The Assign function assigns the value of <String2> to <String1>.
  433.      Neither string need be defined prior to an assign.  Either string may
  434.      be a StringXX variable, and <String2> may be a literal string in
  435.      quotes.  The comma between the two strings is required.
  436.  
  437.      ■  Example
  438.  
  439.      Assign String24, "Telix Support BBS"
  440.  
  441.      Assign String40, String24
  442.      Telix v3.5x - SIMPLE Programming                Built-in Functions   8
  443.  
  444.  
  445.  
  446.  
  447.  
  448.      BEGIN
  449.      ──────────────────────────────────────────────────────────────────────
  450.  
  451.      ■  Summary
  452.  
  453.      Begin
  454.  
  455.      ■  Description
  456.  
  457.      The Begin command denotes the start of a group of code that belongs
  458.      together.  It is typically used to keep a group of code together in
  459.      conjunction with If statements (see If).  Every Begin command must
  460.      have a corresponding End command.  Begin and End commands may be
  461.      nested within each other.
  462.  
  463.      It is recommended that indentation be used to help keep track of the
  464.      Begin and End pairs.
  465.  
  466.      ■  See Also
  467.  
  468.      End
  469.  
  470.      ■  Example
  471.  
  472.      if Online then
  473.        Begin
  474.          Assign String4, "TELIX.REP"
  475.          Alarm 3
  476.        End
  477.  
  478.  
  479.      The use of the If statement will be discussed shortly.  The example
  480.      above is primarily to illustrate the Begin and End pairs.
  481.      Telix v3.5x - SIMPLE Programming                Built-in Functions   9
  482.  
  483.  
  484.  
  485.  
  486.  
  487.      CAPTURELOG
  488.      ──────────────────────────────────────────────────────────────────────
  489.  
  490.      ■  Summary
  491.  
  492.      CaptureLog (<String>/Off/On/Pause/Unpause)
  493.  
  494.      ■  Description
  495.  
  496.      The CaptureLog function controls the status of the Telix Capture file,
  497.      in much the same was as Alt-L does from the keyboard in Telix.  You
  498.      may turn on the capture log by passing a StringXX or constant string,
  499.      pause, unpause, or turn off the capture file entirely.  Only one of
  500.      these actions may be performed per CaptureLog command.  CaptureLog On
  501.      opens the capture log to the default Telix log name.
  502.  
  503.      ■  Examples
  504.  
  505.      CaptureLog "TEMP.CAP"
  506.      CaptureLog Pause
  507.      CaptureLog Unpause
  508.      CaptureLog Off
  509.  
  510.      CaptureLog On
  511.      CaptureLog Off
  512.  
  513.      Assign String16, "TELIX.CAP"
  514.      CaptureLog String16
  515.      CaptureLog Off
  516.  
  517.  
  518.      CHANGEDIR
  519.      ──────────────────────────────────────────────────────────────────────
  520.  
  521.      ■  Summary
  522.  
  523.      ChangeDir <String>
  524.  
  525.      ■  Description
  526.  
  527.      The ChangeDir function provides access to the DOS "CD" command.  You
  528.      may change to any valid directory with this command.  Invalid
  529.      directories are simply ignored, and Telix will remain in the current
  530.      directory.  <String> may be either a StringXX variable or a literal
  531.      string in quotes.
  532.  
  533.      ■  Examples
  534.  
  535.      Assign String64, "D:\TELIX\DOWN"
  536.      ChangeDir String64
  537.      ChangeDir "C:\TELIX"
  538.      Telix v3.5x - SIMPLE Programming               Built-in Functions   10
  539.  
  540.  
  541.  
  542.  
  543.  
  544.      CLEARSCREEN
  545.      ──────────────────────────────────────────────────────────────────────
  546.  
  547.      ■  Summary
  548.  
  549.      ClearScreen
  550.  
  551.      ■  Description
  552.  
  553.      The ClearScreen function acts as if you had pressed Alt-C from within
  554.      Telix.  It clears the screen of all characters other than the status
  555.      line (if on).  ClearScreen does not accept any parameters.
  556.  
  557.      ■  Example
  558.  
  559.      ClearScreen
  560.  
  561.  
  562.  
  563.      DATE
  564.      ──────────────────────────────────────────────────────────────────────
  565.  
  566.      ■  Summary
  567.  
  568.      Date <String>
  569.  
  570.      ■  Description
  571.  
  572.      The Date function places the current date into <String>.  <String>
  573.      must be a StringXX-type variable.
  574.  
  575.      ■  Example
  576.  
  577.      Date String16
  578.      Telix v3.5x - SIMPLE Programming               Built-in Functions   11
  579.  
  580.  
  581.  
  582.  
  583.  
  584.      DIAL
  585.      ──────────────────────────────────────────────────────────────────────
  586.  
  587.      ■  Summary
  588.  
  589.      dial <String> [From <String>] [MaxOf <Integer>] [RunScript]
  590.  
  591.      ■  Description
  592.  
  593.      The Dial function allows nearly complete access to the Telix dialing
  594.      directory.  Telix can be told to dial several entries, or from a
  595.      specific dialing directory, and can be told whether or not to run a
  596.      linked script.
  597.  
  598.      Dial must be passed at least one parameter, a StringXX variable or
  599.      string constant in quotes containing numbers to dial.  This string may
  600.      contain either a list of entries by number, or a manual number
  601.      preceded with a lowercase "m".
  602.  
  603.      If you wish, you may tell Dial from which directory these numbers are
  604.      to be read, with an optional From directive.  From must be passed a
  605.      StringXX or literal string constant in quotes, containing the name of
  606.      the directory to load.  If you use a From directive, it will be valid
  607.      throughout the rest of the script.  To avoid confusion, it is best to
  608.      either always use From, or never use it.  If From is not used, the
  609.      currently loaded  directory shall be the source.
  610.  
  611.      You may tell Telix to limit the number of dialing attempts to make by
  612.      using an optional MaxOf directive.  MaxOf must be followed by an
  613.      integer number of attempts to make.  MaxOf must come after From if
  614.      From is present.
  615.  
  616.      You may tell Telix to execute the script linked to the dialing
  617.      directory.  The default is not to execute such a script.  By placing
  618.      the optional directive RunScript at the end of the Dial command, Telix
  619.      will execute that linked script, and return control to your SIMPLE
  620.      script upon completion.
  621.  
  622.      ■  Return Value
  623.  
  624.      The Dial function places a return value into the system variable
  625.      ReturnCode as follows:
  626.  
  627.      If there was a connection, ReturnCode shall be the entry number in the
  628.      dialing directory of the system connected to (or 1 for a manual
  629.      number).
  630.  
  631.      If there was no connection established, a zero shall be placed into
  632.      ReturnCode.
  633.  
  634.      If the string passed to dial did not contain a string that dial could
  635.      interpret as a valid list of numbers to dial, -1 will be placed into
  636.      ReturnCode.
  637.      Telix v3.5x - SIMPLE Programming               Built-in Functions   12
  638.  
  639.  
  640.  
  641.  
  642.  
  643.      The use of the ReturnCode is discussed in detail as part of the If
  644.      statement.
  645.  
  646.      ■  Examples
  647.  
  648.      The first example dials entries 1, 5, and 6 from LONGDIST.FON until it
  649.      connects to one of them or the user presses escape.
  650.  
  651.      The second example dials the Telix Support BBS manually, up to 50
  652.      times.
  653.  
  654.      The third example dials entries 1, 5, and 6, after loading TELIX.FON.
  655.      If a connection is made, any script linked to the entry will be
  656.      executed.
  657.  
  658.      Assign String24, "1 5 6"
  659.      Assign String64, "D:\TELIX\FON\LONGDIST.FON"
  660.  
  661.      Dial String24 From String64
  662.  
  663.      Dial "m1-919-481-9399" MaxOf 50
  664.  
  665.      Dial String24 From "TELIX.FON" RunScript
  666.      Telix v3.5x - SIMPLE Programming               Built-in Functions   13
  667.  
  668.  
  669.  
  670.  
  671.  
  672.      DOS
  673.      ──────────────────────────────────────────────────────────────────────
  674.  
  675.      ■  Summary
  676.  
  677.      Dos <String> [Pause]
  678.  
  679.      ■  Description
  680.  
  681.      The Dos function allows you to shell to DOS to execute the program
  682.      specified in <String>.  <String> may be a StringXX variable or a
  683.      literal string in quotes.  If you wish Telix to pause prior to
  684.      returning, simply place the optional directive Pause after the command
  685.      to execute.
  686.  
  687.      ■  Return Value
  688.  
  689.      The Errorlevel that DOS returns after running the command is placed in
  690.      the system variable ReturnCode.  Use of the ReturnCode is discussed
  691.      with the If statement.  Please see your DOS manual for more
  692.      information regarding the DOS Errorlevel.
  693.  
  694.      ■  Examples
  695.  
  696.      Assign String64, "C:\WP51\WP.EXE"
  697.      Dos String64
  698.      Dos "D:\UTIL\QEDIT.EXE" PauseScreen
  699.      Telix v3.5x - SIMPLE Programming               Built-in Functions   14
  700.  
  701.  
  702.  
  703.  
  704.  
  705.      DOWNLOAD
  706.      ──────────────────────────────────────────────────────────────────────
  707.  
  708.      ■  Summary
  709.  
  710.      Download <String> [With Protocol]
  711.  
  712.      ■  Description
  713.  
  714.      The Download function acts just as if you had pressed PgDn and entered
  715.      a protocol and filename.  It will download the file (or files if a
  716.      batch protocol is used) indicated by <String>.  <String> may be a
  717.      StringXX variable or a string constant in quotes.
  718.  
  719.      The Download command uses the protocol specified by the With
  720.      directive.  If no protocol is specified, Telix will prompt for the
  721.      protocol. Protocols allowed following the With directive are:
  722.  
  723.                          Kermit
  724.                          Modem7
  725.                          SeaLink
  726.                          Telink
  727.                          Xmodem
  728.                          1K-Xmodem
  729.                          G-1K-Xmodem
  730.                          Ymodem
  731.                          Ymodem-G
  732.                          Zmodem
  733.  
  734.      External protocols are not available from SIMPLE.
  735.  
  736.      Remember that downloads usually need to be triggered on the remote
  737.      site before you can receive the file.  You will usually need to Send a
  738.      start command prior to using the Download command.  The Send command
  739.      is described elsewhere in this manual.
  740.  
  741.      ■  Examples
  742.  
  743.      Assign String64, "D:\TELIX\DOWN\WORK\TELIX.QWK"
  744.  
  745.      Send "D;Z" Enter
  746.      Send Enter
  747.      Download String64 with Zmodem
  748.  
  749.      Send "D;G" Enter
  750.      Send Enter
  751.      Download "C:\TELIX\DOWN\TLX320-1.ZIP" With Ymodem-G
  752.      Telix v3.5x - SIMPLE Programming               Built-in Functions   15
  753.  
  754.  
  755.  
  756.  
  757.  
  758.      EMULATE
  759.      ──────────────────────────────────────────────────────────────────────
  760.  
  761.      ■  Summary
  762.  
  763.      Emulate <Protocol>
  764.  
  765.      ■  Description
  766.  
  767.      The Emulate function tells Telix to change the terminal emulation it
  768.      is using to that specified by <Protocol>.  Allowable Emulations that
  769.      can be passed to the Emulate command are:
  770.  
  771.                          TTY
  772.                          ANSI-BBS
  773.                          VT52
  774.                          VT102
  775.                          ANSI
  776.                          AVATAR
  777.  
  778.      ■  Examples
  779.  
  780.      Emulate VT102
  781.      Emulate ANSI-BBS
  782.  
  783.      END
  784.      ──────────────────────────────────────────────────────────────────────
  785.  
  786.      ■  Summary
  787.  
  788.      End
  789.  
  790.      ■  Description
  791.  
  792.      The End command denotes the end of a group of code that belongs
  793.      together.  It is typically used to keep a group of code together in
  794.      conjunction with If statements (see If).  Every End command must have
  795.      a preceding Begin command.  Begin and End commands may be nested
  796.      within each other.
  797.  
  798.      It is recommended that indentation be used to help keep track of the
  799.      Begin and End pairs.
  800.  
  801.      ■  Example
  802.  
  803.      if Online then
  804.        Begin
  805.          Send "U" Enter
  806.          Upload "TELIX.REP" with Zmodem
  807.        End
  808.      Telix v3.5x - SIMPLE Programming               Built-in Functions   16
  809.  
  810.  
  811.  
  812.  
  813.  
  814.      ERASEFILE
  815.      ──────────────────────────────────────────────────────────────────────
  816.  
  817.      ■  Summary
  818.  
  819.      EraseFile <String>
  820.  
  821.      ■  Description
  822.  
  823.      The EraseFile function deletes the file specified in <String> from the
  824.      disk.  Be careful using this command as deleted files are usually
  825.      unrecoverable.  <String> may be a StringXX variable or a literal
  826.      string in quotes.
  827.  
  828.      ■  Example
  829.  
  830.      Assign String24, "D:\WINDOWS\TELIX.TTF"
  831.      EraseFile String24
  832.      EraseFile "C:\TELIX\QWIK\TELIX.QWK"
  833.  
  834.      EXITSCRIPT
  835.      ──────────────────────────────────────────────────────────────────────
  836.  
  837.      ■  Summary
  838.  
  839.      ExitScript
  840.  
  841.      ■  Description
  842.  
  843.      The ExitScript function halts execution of the script.  It is exactly
  844.      like pressing Escape while a script is running, and answering "Yes".
  845.  
  846.      ■  Example
  847.  
  848.      ExitScript
  849.  
  850.  
  851.      EXITTELIX
  852.      ──────────────────────────────────────────────────────────────────────
  853.  
  854.      ■  Summary
  855.  
  856.      ExitTelix
  857.  
  858.      ■  Description
  859.  
  860.      The ExitTelix function halts execution of the script, and exits Telix
  861.      altogether.  It is exactly like pressing Alt-X and answering "Yes."
  862.  
  863.      ■  Example
  864.  
  865.      ExitTelix
  866.      Telix v3.5x - SIMPLE Programming               Built-in Functions   17
  867.  
  868.  
  869.  
  870.  
  871.  
  872.      HANGUP
  873.      ──────────────────────────────────────────────────────────────────────
  874.  
  875.      ■  Summary
  876.  
  877.      Hangup
  878.  
  879.      ■  Description
  880.  
  881.      The Hangup function disconnects you from any system you might be
  882.      connected to at the time.  It is exactly like pressing Alt-H from
  883.      within Telix.
  884.  
  885.      ■  Example
  886.  
  887.      Hangup
  888.  
  889.  
  890.      INPUT
  891.      ──────────────────────────────────────────────────────────────────────
  892.  
  893.      ■  Summary
  894.  
  895.      Input <StringXX>, Nx
  896.  
  897.      ■  Description
  898.  
  899.      The Input function gets up Nx characters from the keyboard and places
  900.      them into <StringXX>.  Nx is any integer value from 1 to 80, and
  901.      <StringXX> must be a StringXX-type variable.
  902.  
  903.      No prompting is made by SIMPLE.  If you wish to prompt the user for
  904.      the data, you will want to put the prompt up yourself, using the Show
  905.      command, described later.
  906.  
  907.      An example of the Input routine below allows the user to input up to
  908.      40 characters, placing them into String22:
  909.  
  910.      ■  Example
  911.  
  912.      Input String22, 40
  913.      Telix v3.5x - SIMPLE Programming               Built-in Functions   18
  914.  
  915.  
  916.  
  917.  
  918.  
  919.      MESSAGE
  920.      ──────────────────────────────────────────────────────────────────────
  921.  
  922.      ■  Summary
  923.  
  924.      Message <String>
  925.  
  926.      ■  Description
  927.  
  928.      The Message command places <String> into a centered box on the screen
  929.      for exactly three seconds.  It is very much like what you would see in
  930.      Telix when pressing Alt-E, for example, but it allows you to specify
  931.      the message in the box.  <String> may be a StringXX variable or a
  932.      literal string in quotes.
  933.  
  934.      ■  Example
  935.  
  936.      Message "Disconnecting from the Telix Support BBS"
  937.  
  938.  
  939.      PRINTER
  940.      ──────────────────────────────────────────────────────────────────────
  941.  
  942.      ■  Summary
  943.  
  944.      Printer [On] [Off]
  945.  
  946.      ■  Description
  947.  
  948.      The Printer command toggles the printer mode on and off, just as Ctrl-
  949.      @ does in Telix.  You must specify the state you wish the log to be
  950.      in, On or Off.
  951.  
  952.      ■  Example
  953.  
  954.      Printer On
  955.  
  956.      Printer Off
  957.      Telix v3.5x - SIMPLE Programming               Built-in Functions   19
  958.  
  959.  
  960.  
  961.  
  962.  
  963.      RUNSCRIPT
  964.      ──────────────────────────────────────────────────────────────────────
  965.  
  966.      ■  Summary
  967.  
  968.      RunScript <String>
  969.  
  970.      ■  Description
  971.  
  972.      The RunScript function loads the script specified in <String> and
  973.      executes it.  When this new script terminates, your script will
  974.      continue from this position.  <String> may be either a StringXX
  975.      variable or a literal string in quotes.
  976.  
  977.      ■  Return Value
  978.  
  979.      RunScript places the value returned by the called script into the
  980.      system variable ReturnCode. All SIMPLE scripts will return a zero.
  981.      SALT scripts may return varying values.
  982.  
  983.      ■  Example
  984.  
  985.      RunScript "AXSTOOLS.SLC"
  986.  
  987.  
  988.      SEND
  989.      ──────────────────────────────────────────────────────────────────────
  990.  
  991.      ■  Summary
  992.  
  993.      Send <String> [Enter]
  994.  
  995.      ■  Description
  996.  
  997.      The Send function sends the data contained in <String> out the comm
  998.      port, and also to the screen.  If the keyword Enter follows <String>
  999.      then a carriage return will be sent as well.  <String> may be a
  1000.      StringXX variable or a string constant in quotes.
  1001.  
  1002.      ■  Examples
  1003.  
  1004.      Assign String14, "Telix Support"
  1005.  
  1006.      Send String14
  1007.      Send "Chatting with Sysop" Enter
  1008.      Telix v3.5x - SIMPLE Programming               Built-in Functions   20
  1009.  
  1010.  
  1011.  
  1012.  
  1013.  
  1014.      SHELL
  1015.      ──────────────────────────────────────────────────────────────────────
  1016.  
  1017.      ■  Summary
  1018.  
  1019.      Shell
  1020.  
  1021.      ■  Description
  1022.  
  1023.      The Shell function jumps to MS-DOS and allows you to execute other
  1024.      programs manually.  This is the same as pressing Alt-J within Telix.
  1025.      To return to your script from DOS, simply type "exit" at the DOS
  1026.      prompt.
  1027.  
  1028.      You must return to the directory you started in if things are expected
  1029.      to function properly.  If you "exit" back to Telix while in another
  1030.      directory, the current directory that scripts use will be incorrect
  1031.      and files might not be found where they should be.  Be careful using
  1032.      the Shell command.
  1033.  
  1034.      ■  Example
  1035.  
  1036.      Shell
  1037.  
  1038.  
  1039.      SHOW
  1040.      ──────────────────────────────────────────────────────────────────────
  1041.  
  1042.      ■  Summary
  1043.  
  1044.      Show <String> [Enter]
  1045.  
  1046.      ■  Description
  1047.  
  1048.      The Show function places the data contained in <String> on the screen.
  1049.      If the keyword Enter follows <String> then a carriage return will be
  1050.      displayed as well.  <String> may be a StringXX variable or a string
  1051.      constant in quotes.
  1052.  
  1053.      Show is very similar to Send, but the data is not sent over the comm
  1054.      port.  Be careful not to confuse Show and Send.
  1055.  
  1056.      ■  Examples
  1057.  
  1058.      Assign String14, "Telix Support"
  1059.  
  1060.      Show String14
  1061.      Show "Chatting with Sysop" Enter
  1062.      Telix v3.5x - SIMPLE Programming               Built-in Functions   21
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068.      SOUND
  1069.      ──────────────────────────────────────────────────────────────────────
  1070.  
  1071.      ■  Summary
  1072.  
  1073.      Sound Nx, Ny
  1074.  
  1075.      ■  Description
  1076.  
  1077.      The Sound function causes tone of frequency (pitch) Nx to be played on
  1078.      the PC speaker for Ny tenths of a second.  You may want to experiment
  1079.      with values for Nx to determine acceptable frequencies.
  1080.  
  1081.      Script execution will not continue until the time has elapsed.
  1082.  
  1083.      ■  Examples
  1084.  
  1085.      Sound 200, 30
  1086.  
  1087.      Sound 500, 10
  1088.  
  1089.  
  1090.      TIME
  1091.      ──────────────────────────────────────────────────────────────────────
  1092.  
  1093.      ■  Summary
  1094.  
  1095.      Time <String>
  1096.  
  1097.      ■  Description
  1098.  
  1099.      The Time function places the current time into <String>.  <String>
  1100.      must be a StringXX-type variable.
  1101.  
  1102.      ■  Example
  1103.  
  1104.      Time String16
  1105.      Telix v3.5x - SIMPLE Programming               Built-in Functions   22
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.      UPLOAD
  1112.      ──────────────────────────────────────────────────────────────────────
  1113.  
  1114.      ■  Summary
  1115.  
  1116.      Upload <String> With Protocol
  1117.  
  1118.      ■  Description
  1119.  
  1120.      The Upload function acts just as if you had pressed PgUp and entered a
  1121.      protocol and filename.  It will upload the file (or files if a batch
  1122.      protocol is used) indicated by <String>.  <String> may be a StringXX
  1123.      variable or a string constant in quotes.
  1124.  
  1125.      The Upload command uses the protocol specified on the command line by
  1126.      the With operator.  If a protocol is not specified, Telix will prompt
  1127.      for the protocol.  Protocols allowed following the With directive are:
  1128.  
  1129.                          Kermit
  1130.                          Modem7
  1131.                          SeaLink
  1132.                          Telink
  1133.                          Xmodem
  1134.                          1K-Xmodem
  1135.                          G-1K-Xmodem
  1136.                          Ymodem
  1137.                          Ymodem-G
  1138.                          Zmodem
  1139.  
  1140.      External protocols are not available from SIMPLE.
  1141.  
  1142.      Remember that uploads usually need to be triggered on the remote site
  1143.      before you can send the file.  You will usually need to Send a start
  1144.      command prior to using the Upload command.
  1145.  
  1146.      ■  Examples
  1147.  
  1148.      Assign String64, "D:\TELIX\DOWN\WORK\TELIX.REP"
  1149.  
  1150.      Send "U;Z" Enter
  1151.      Send Enter
  1152.      Upload String64 with Zmodem
  1153.  
  1154.      Send "U;G" Enter
  1155.      Send Enter
  1156.      Upload "C:\TELIX\DOWN\TLX320-1.ZIP" With Ymodem-G
  1157.      Telix v3.5x - SIMPLE Programming               Built-in Functions   23
  1158.  
  1159.  
  1160.  
  1161.  
  1162.  
  1163.      USAGELOG
  1164.      ──────────────────────────────────────────────────────────────────────
  1165.  
  1166.      ■  Summary
  1167.  
  1168.      UsageLog [On] [Off]
  1169.  
  1170.      ■  Description
  1171.  
  1172.      The UsageLog command toggles the Telix usage log on and off, just as
  1173.      Alt-U does in Telix.  You must specify the state you wish the log to
  1174.      be in, On or Off.
  1175.  
  1176.      ■  Example
  1177.  
  1178.      UsageLog On
  1179.  
  1180.      UsageLog Off
  1181.  
  1182.  
  1183.      WAIT
  1184.      ──────────────────────────────────────────────────────────────────────
  1185.  
  1186.      ■  Summary
  1187.  
  1188.      Wait Nx
  1189.  
  1190.      ■  Description
  1191.  
  1192.      The Wait function forces the script to pause for Nx seconds.
  1193.  
  1194.      ■  Example
  1195.  
  1196.      Wait 60
  1197.      Telix v3.5x - SIMPLE Programming                  Program Control   25
  1198.  
  1199.  
  1200.  
  1201.  
  1202.  
  1203.  
  1204.      5.  Program Control
  1205.  
  1206.      SIMPLE scripts would be less than useful if there wasn't a way to
  1207.      cause the lines to execute out of order or in repetitive blocks.
  1208.      There are three commands that can cause a SIMPLE script to take on a
  1209.      much higher degree of functionality, and thus complexity.  We will
  1210.      start with the easier ones, and then move on to the more advanced
  1211.      ones.
  1212.  
  1213.  
  1214.      5.1  The Waitfor Command
  1215.      ──────────────────────────────────────────────────────────────────────
  1216.  
  1217.      Often when automating logons to online systems, you must enter
  1218.      information in response to a certain prompt, but it is not known
  1219.      exactly when that prompt will be ready for your input.  Waitfor
  1220.      simulates exactly what you would do when logging onto a system.  It
  1221.      waits for the prompt to appear, and then does what you tell it.
  1222.  
  1223.      ■  Summary
  1224.  
  1225.      WaitFor <String> [MaxOf Nx] Then <Command>
  1226.  
  1227.      <String> may be a literal string in quotes, or a StringXX variable.
  1228.      Case is not significant, and String must be no more than 40
  1229.      characters.
  1230.  
  1231.      The optional MaxOf directive tells the WaitFor command how long to
  1232.      wait before giving up.  Nx is a number of seconds to wait.  If MaxOf
  1233.      is defined, and Nx seconds elapse without <String> being received,
  1234.      SIMPLE skips <Command> and continues with the next command after that.
  1235.  
  1236.      <Command> is any valid built-in function from Chapter 4, including
  1237.      blocks surrounded by Begin and End.
  1238.  
  1239.      ■  Example
  1240.  
  1241.      Clark Development's PCBoard BBS prompts the user for various inputs,
  1242.      always in the same order.  It will prompt you for your color
  1243.      preference, your first name, your last name, and your password.  You
  1244.      can use the WaitFor command in a short SIMPLE script to automate this
  1245.      process as follows:
  1246.  
  1247.      Assign String1,   "Jeff"
  1248.      Assign String2,   "Woods"
  1249.      Assign String101, "first name"
  1250.      Assign String102, "last name"
  1251.  
  1252.      Waitfor "you want graphics" MaxOf 30 Then Send "Y Q" Enter
  1253.  
  1254.      Waitfor String101 MaxOf 10 Then
  1255.        Send String1 Enter
  1256.      Telix v3.5x - SIMPLE Programming                  Program Control   26
  1257.  
  1258.  
  1259.  
  1260.  
  1261.  
  1262.      Waitfor String102 MaxOf 10 Then Send String2 Enter
  1263.      Waitfor "ssword" MaxOf 10 Then Send BBSPassword Enter
  1264.  
  1265.  
  1266.  
  1267.      5.2  The If Command
  1268.      ──────────────────────────────────────────────────────────────────────
  1269.  
  1270.      The If conditional is one of the most powerful, and thus complex
  1271.      functions of SIMPLE.  It has several options and is relatively
  1272.      freeform, but it must follow certain conventions.
  1273.  
  1274.      Following the explanation of the If statement, our examples will
  1275.      become more complex, as we build on what you have learned so far.
  1276.  
  1277.      The general purpose of an If statement is to test to see if a certain
  1278.      condition is true, and to execute certain commands if so, or
  1279.      optionally, certain commands if not.
  1280.  
  1281.      ■  Summary
  1282.  
  1283.      If [Not] <Condition> Then <Command> [ElseIf <Command>] [Else...]
  1284.  
  1285.      <Condition> is the quality you wish to test for being true or false.
  1286.      Conditions may be comparing strings for equality to each other,
  1287.      checking for the existence of a certain file on the disk, or for
  1288.      checking to see if a certain condition exists, such as if Telix is
  1289.      connected to a system.  You can check for the opposite condition by
  1290.      preceding <Condition> with the optional directive Not.
  1291.  
  1292.      The Then keyword is required for all If statements, and must follow
  1293.      the <Condition>.
  1294.  
  1295.      <Command> is the action that could be performed based on the result of
  1296.      the Condition.  <Command> may be any of the built-in functions of
  1297.      SIMPLE, and can even be a group of instructions marked by Begin and
  1298.      End.
  1299.  
  1300.      Else and ElseIf statements will be explained shortly.
  1301.  
  1302.  
  1303.  
  1304.      There are five predefined conditions that can be used:
  1305.  
  1306.      1.  Online     You may check the state of the carrier detect signal to
  1307.                     determine if you are connected to another system or
  1308.                     not.  The format of the Online conditional is:
  1309.  
  1310.                     If [Not] Online [=Yes] [=No] Then <Command>
  1311.  
  1312.                     "Yes" and "No" are optional and are only included for
  1313.                     clarity.  Examples of the Online conditional are:
  1314.  
  1315.                          If Online Then
  1316.      Telix v3.5x - SIMPLE Programming                  Program Control   27
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.                            Begin
  1323.                              Download "TELIX.QWK" With ZModem
  1324.                              EraseFile "TELIX.REP"
  1325.                            End
  1326.  
  1327.                          If Not Online Then
  1328.                            Dial "m1-919-481-9399" MaxOf 50
  1329.  
  1330.                          If Online=No Then Dial "5"
  1331.  
  1332.  
  1333.      2.  Exist      You may check for the existence of a file on the disk
  1334.                     prior to attempting an action on that file.  The format
  1335.                     of the Exist conditional is:
  1336.  
  1337.                     If [Not] Exist <String> Then <Command>
  1338.  
  1339.                     <String> may be a StringXX variable or a string
  1340.                     constant in quotes.  Examples of the Exist conditional
  1341.                     are:
  1342.  
  1343.                          Assign String1, "D:\TELIX\QWK\TELIX.REP"
  1344.  
  1345.                          If Exist String1 Then
  1346.                            Upload String1 With Zmodem
  1347.  
  1348.                          If Not Exist String1 Then
  1349.                            If Online Then
  1350.                              Begin
  1351.                                Download String1 With Zmodem
  1352.                                EraseFile "ANYFILE"
  1353.                              End
  1354.  
  1355.                     As you can see, our examples are becoming a bit more
  1356.                     complex as more commands are introduced.
  1357.  
  1358.      3.   BBSNumber You may check the value of this system variable to
  1359.                     determine which dialing directory entry number you last
  1360.                     connected to.  The format of the BBSNumber conditional
  1361.                     is:
  1362.  
  1363.                     If [Not] BBSNumber = Nx Then <Command>
  1364.  
  1365.                     <Nx> is any integer number.  For example, if you know
  1366.                     that the Telix Support BBS is entry # 1 in the current
  1367.                     dialing directory, and you wish to find out if we are
  1368.                     currently online with this particular system, you could
  1369.                     nest two If statements together:
  1370.  
  1371.                          If Online Then
  1372.                            If BBSNumber = 1 Then
  1373.                              Begin
  1374.                                EraseFile "TELIX.QWK"
  1375.                                Download "TELIX.QWK" With Zmodem
  1376.      Telix v3.5x - SIMPLE Programming                  Program Control   28
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.                              End
  1383.  
  1384.                     Note that the <Command> executed for "If Online"
  1385.                     encompasses all of the rest of the above example
  1386.                     through the End statement.  This is the reason for the
  1387.                     indentation as above.  It reminds us which lines
  1388.                     comprise the <Command> to execute if <Condition> is
  1389.                     true.
  1390.  
  1391.      4.   ReturnCode     
  1392.  
  1393.                     You may check the results of any of three other SIMPLE
  1394.                     commands with the ReturnCode system variable.  Two of
  1395.                     them we have covered, the third we shall shortly.  The
  1396.                     three commands you can check for success are Dos, Dial,
  1397.                     and RunScript.
  1398.  
  1399.                     The format of the ReturnCode conditional is as follows:
  1400.  
  1401.                     If [Not] ReturnCode = Nx Then <Command>
  1402.  
  1403.                     <Nx> is any integer number.  For example, if you know
  1404.                     that the program Foo.EXE returns a DOS Errorlevel of 1
  1405.                     if today is a Saturday, and an Errorlevel of 0 for
  1406.                     every other day of the week, you might want to try
  1407.                     something like the following, which would call the
  1408.                     Telix BBS to download a mail packet on Saturdays only.
  1409.                     Again, we shall try to integrate what we have learned
  1410.                     thus far into more and more complex examples:
  1411.  
  1412.                          Dos "Foo.EXE"
  1413.                          If ReturnCode = 1 Then
  1414.                            Begin
  1415.                              Dial "m1-919-481-9399" Maxof 50          Runsc
  1416.                          ript
  1417.                              Send "QMAIL4 D;Y"
  1418.                              Download "TELIX.QWK" With Zmodem
  1419.                              Hangup
  1420.                            End
  1421.      5.   TransferStatus
  1422.  
  1423.                     You may check the result of the Upload or Download
  1424.                     commands with the TransferStatus system variable.  The
  1425.                     format of a TransferStatus conditional is as follows:
  1426.  
  1427.                     If [Not] TransferStatus = Nx Then <Command>
  1428.  
  1429.                     Nx is any integer number.  The following example will
  1430.                     try to send a mail packet to the Telix BBS and if not
  1431.                     successful, will try again.  The example assumes that
  1432.                     we are already logged on and ready to upload.
  1433.  
  1434.                          Send "TELIX.REP" With Zmodem
  1435.      Telix v3.5x - SIMPLE Programming                  Program Control   29
  1436.  
  1437.  
  1438.  
  1439.  
  1440.  
  1441.                          If TransferStatus = 0 Then
  1442.                            Send "TELIX.REP" With Zmodem
  1443.  
  1444.  
  1445.  
  1446.      An optional Else or ElseIf command may be appended to any If statement
  1447.      to further control the flow of the program.  ElseIf and Else
  1448.      statements may be nested within one another, and infinitely deep.
  1449.  
  1450.      ElseIf statements indicate another If condition is to be checked in
  1451.      the case of the first If being false.  Else statements indicate the
  1452.      end of an If chain.
  1453.  
  1454.      The following is perfectly valid, and quite common:
  1455.  
  1456.                          If Online Then
  1457.                            Begin
  1458.                              Send "U;Z" Enter
  1459.                              Upload "Telix.REP" with Zmodem
  1460.                              If TransferStatus = 0 Then
  1461.                                Download "Telix.QWK" with Xmodem
  1462.                              ElseIf
  1463.                                Upload "Telix.REP" With Zmodem
  1464.                              Else
  1465.                                Hangup
  1466.                            End
  1467.                          Else
  1468.                            Dial "11"
  1469.  
  1470.  
  1471.  
  1472.      Note the nesting and indentation of each individual command beneath
  1473.      the If that it is a part of.  Clear, concise indentation can go a long
  1474.      way to making your scripts easier to read and write.
  1475.      Telix v3.5x - SIMPLE Programming                  Program Control   30
  1476.  
  1477.  
  1478.  
  1479.  
  1480.  
  1481.      5.3  The Whenever Loop
  1482.      ──────────────────────────────────────────────────────────────────────
  1483.  
  1484.      The Whenever loop is the most powerful, and thus most complex function
  1485.      of SIMPLE.  It has several options and is relatively freeform, but it
  1486.      must follow certain conventions.
  1487.  
  1488.      The purpose of a Whenever loop is best explained in terms of WaitFor.
  1489.      Please be sure you understand Waitfor before continuing here.
  1490.  
  1491.      One of the inherent problems of WaitFor is that the order the prompts
  1492.      come in must be fixed.  One particular bulletin board can randomly
  1493.      prompt your for your birthday as verification of who you really are.
  1494.      Such a prompt renders the WaitFor command fairly useless.
  1495.  
  1496.      Whenever is the answer to this problem.  You may set up a group of up
  1497.      to sixteen different strings and can define the proper actions SIMPLE
  1498.      should take whenever that particular prompt comes in.  The order of
  1499.      the prompts will not matter.  If your prompt comes in, then the
  1500.      defined action will occur.  The general format of a Whenever Loop is
  1501.      defined below.
  1502.  
  1503.      ■  Summary
  1504.  
  1505.      WhenLoop
  1506.          Whenever <String> Then <Command>
  1507.          Whenever <String> Then <Command>
  1508.          Whenever <String> Then <Command>
  1509.          ....
  1510.      EndWhen
  1511.  
  1512.      A Whenever Loop begins with the keyword WhenLoop.
  1513.  
  1514.      Immediately following WhenLoop must follow a series of up to sixteen
  1515.      Whenever directives.  A whenever directive defines the <String> to
  1516.      watch for, and the <Command> to execute when the <String> is received.
  1517.      The keyword Then must appear between the two, exactly as above.
  1518.  
  1519.      <String> may be a StringXX variable or a string constant in quotes.
  1520.      Case is not significant, and <String> may be no longer than 40
  1521.      characters.
  1522.  
  1523.      Whenever <String> is received, <Command> will be executed.  The power
  1524.      of the Whenever loop lies in the fact that absolutely any SIMPLE
  1525.      construct may be used here as the <Command> (other than another
  1526.      Whenever loop).  Waitfor, If, or any built-in function from chapter 4
  1527.      may be used.
  1528.  
  1529.      The keyword EndWhen must follow the last Whenever directive.
  1530.  
  1531.      The keyword QuitWhen is used to exit from a given WhenLoop at the
  1532.      proper time.
  1533.      Telix v3.5x - SIMPLE Programming                  Program Control   31
  1534.  
  1535.  
  1536.  
  1537.  
  1538.  
  1539.      Using the example of a BBS which can randomly prompt for your date of
  1540.      birth during the login, lets write a script to log on to that system,
  1541.      enter the mail door, download a mail packet, and log off.
  1542.  
  1543.      ■  Example
  1544.  
  1545.      WhenLoop
  1546.        Whenever "language t"   Then Send "2"         Enter
  1547.        Whenever "first name"   Then Send "Jeff"      Enter
  1548.        Whenever "last name"    Then Send "Woods"     Enter
  1549.        Whenever "ssword"       Then Send BBSPassword Enter
  1550.        Whenever "birthday"     Then Send "03/25/66"  Enter
  1551.        Whenever "new mail"     Then Send "N Q"       Enter
  1552.        Whenever "rd Command"   Then Send "MAILDOOR"  Enter
  1553.        Whenever "mail Command" Then
  1554.          Begin
  1555.            Send "D;Y" Enter
  1556.            Waitfor "ready to Send Telix.QWK" MaxOf 300 Then
  1557.              Download "TELIX.QWK" With Zmodem
  1558.            If TransferStatus = 0 Then
  1559.              Begin
  1560.                Message "Download Not Successful!"
  1561.                Sound 200, 2
  1562.              End
  1563.            Else
  1564.              Begin
  1565.                Wait(20)
  1566.                Send "G;Y" Enter
  1567.                Hangup
  1568.                QuitWhen
  1569.              End
  1570.          End
  1571.      EndWhen
  1572.  
  1573.      This entire script would log you onto the BBS, and would answer the
  1574.      random birthday prompt if it appeared.
  1575.  
  1576.      The last Whenever directive specifies to the script that it is to do
  1577.      everything within the outermost Begin/End.  Note that the final
  1578.      whenever is in response to a prompt that indicates we are in the mail
  1579.      door.  If we are in the mail door, we send a command to start the
  1580.      download of a mail packet.  When the packet is ready, we actually
  1581.      attempt download.  Upon checking the result of the transfer, we either
  1582.      log off and exit the WhenLoop (we did what we wanted), or we make a
  1583.      beep and go back to the whenloop, which will trigger again on the mail
  1584.      Command prompt, and try to download again.
  1585.  
  1586.      Study the example above carefully, as it is very typical of a complete
  1587.      SIMPLE script.  Be careful when using WhenLoops as the above script
  1588.      can try over and over to download a packet.  If there is a problem
  1589.      downloading due to the BBS, you could run up quite a bill.  Advanced
  1590.      automation scripts should probably be in SALT, which allows greater
  1591.      control.
  1592.      Telix v3.5x - SIMPLE Programming                            Index   33
  1593.  
  1594.  
  1595.  
  1596.  
  1597.  
  1598.      6.  Index
  1599.  
  1600.      Alarm................................................................7
  1601.      Assign...............................................................7
  1602.      BBSNumber........................................................6, 27
  1603.      BBSPassword..........................................................6
  1604.      Begin................................................................8
  1605.      CaptureLog...........................................................9
  1606.      Carrier detect......................................................26
  1607.      ChangeDir............................................................9
  1608.      Changing your password...............................................6
  1609.      ClearScreen.........................................................10
  1610.      Compiling a script...................................................2
  1611.      Date................................................................10
  1612.      Dereferencing........................................................5
  1613.      Dial................................................................11
  1614.      Dos.................................................................13
  1615.      Download............................................................14
  1616.      Else................................................................29
  1617.      ElseIf..............................................................29
  1618.      Emulate.............................................................15
  1619.      End.................................................................15
  1620.      EndWhen.............................................................30
  1621.      EraseFile...........................................................16
  1622.      Exist...............................................................27
  1623.      ExitScript..........................................................16
  1624.      ExitTelix...........................................................16
  1625.      Hangup..............................................................17
  1626.      If..................................................................26
  1627.      Input...............................................................17
  1628.      Linked script.......................................................11
  1629.      Message.............................................................18
  1630.      Online..............................................................26
  1631.      Printer.............................................................18
  1632.      QuitWhen............................................................30
  1633.      ReturnCode...............................................6, 11, 13, 28
  1634.      RunScript...........................................................19
  1635.      SALT source..........................................................1
  1636.      Send................................................................19
  1637.      Shell...............................................................20
  1638.      Show................................................................20
  1639.      Sound...............................................................21
  1640.      Strings..............................................................5
  1641.      System variables.....................................................5
  1642.      Time................................................................21
  1643.      TransferStatus...................................................6, 28
  1644.      Upload..............................................................22
  1645.      UsageLog............................................................23
  1646.      Variables............................................................5
  1647.      Wait................................................................23
  1648.      WaitFor.............................................................25
  1649.      Whenever............................................................30
  1650.      WhenLoop............................................................30
  1651.