home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 592b.lha / TermII / English / Documentation / SCRIPTS.doc < prev    next >
Text File  |  1991-12-22  |  5KB  |  175 lines

  1. June 21st 1991
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.                                     Term II
  12.  
  13.                                   version 1.1
  14.  
  15.                          (c) 1990,1991 - Eric GONTIER
  16.  
  17.                                   SCRIPTS.doc
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.         INTRODUCTION :
  30.  
  31.             All the commands described in COMMANDS.doc can be used from
  32.             ARexx to build scripts. You need to set the current port to
  33.             address from ARexx with address TERM, and then you can send
  34.             your commands from your ARexx program. Example :
  35.  
  36.                     /* Example, automatic uploading of a file     */
  37.                     /* using Xmodem 1K CRC                        */
  38.  
  39.                     address TERM
  40.  
  41.                     xpr_open '"xprxmodem.library"'
  42.                     xpr_init '"A0,C1,K1"'
  43.                     xpr_send '"dh0:my_dir/my_file"'
  44.  
  45.             Some commands have been added especially for ARexx :
  46.             rexx_memory_on,  rexx_memory_off,  rexx_delay rexx_wait and
  47.             rexx
  48.  
  49.                     rexx_wait timeout1 timeout2
  50.  
  51.             This command will ask Term to wait for characters. A timeout1
  52.             in seconds is allowed before aborting the read if nothing is
  53.             received. Otherwise, Term will read the characters as they
  54.             came, until a timeout2 (in seconds) delay occured without
  55.             receiving any other characters.
  56.  
  57. ** NOTE : I know this is not very handy. A better solution would be a
  58. command like the one for XCMD, which allows to wait for a fixed number of
  59. chars, or to abort for a given time out. However, I did not have enough
  60. time to write such a commands for this version, but it should came in
  61. future release. So... **
  62.  
  63.             Example :
  64.  
  65.  
  66.                     serial_send '"ATDT3600\n"'  /* connect to transpac */
  67.  
  68.                             /* Allow a 30s delay without receiving     */
  69.                             /* anything. Otherwise, stop read as soon  */
  70.                             /* as 2s occured since last char received  */
  71.                     rexx_wait 30 2
  72.  
  73.             This allows to wait for receiving, and to react quickly when
  74.             all the characters have been read.
  75.  
  76.             The ARexx script need a way to get all the characters read by
  77.             Term. The idea is to put Term in a "memory mode". In this mode,
  78.             Term will memorize the last 80 characters it had received, and
  79.             so an ARexx script can get them in the ARexx variable MEMORY.
  80.             The command rexx_memory_on will turn on the memory mode (as a
  81.             side effect, it also clears the memory buffer), and variable
  82.             MEMORY will be updated when the command rexx_delay or rexx_wait
  83.             retirned from Term
  84.  
  85.             The rexx command can be used to start an ARexx program from
  86.             Term II (but the Rexx server must already be running. This is
  87.             often made by the startup-sequence, at boot time). For example:
  88.  
  89.                     rexx "quit.rexx"
  90.  
  91.             will run the script quit.rexx which is in the current
  92.             directory.
  93.  
  94.             ARexx has some powerful commands for parsing, which can be used
  95.             to test values found in the MEMORY variable.
  96.  
  97.             Example :
  98.  
  99.                      rexx_memory_on
  100.                      serial_send '"ATDT3600\n"'
  101.                      rexx_wait 30 2
  102.  
  103.                             /* Here, MEMORY has the last 80         */
  104.                             /* characters received                  */
  105.  
  106.                      Parsing MEMORY to find one the following messages :
  107.  
  108.                      if CONNECT1200
  109.                             connection succeeded, the script can go on
  110.  
  111.                      if BUSY
  112.                             It's busy ! We can wait 10s, and start again
  113.  
  114.                      if NO CARRIER
  115.                             It was a wrong number, or the BBS is down
  116.  
  117.  
  118.  
  119.  
  120.  
  121.         EXAMPLES :
  122.  
  123.             Included with Term II are very simple ARexx scripts, which can
  124.             be started from the CLI with the rx command, like :
  125.  
  126.                 rx test_delay
  127.  
  128.             They can also be started from Term II, see the next paragraph.
  129.  
  130.  
  131.             The examples :
  132.  
  133.                 test_delay.rexx
  134.                     test the rexx_delay command
  135.  
  136.                 test_wait.rexx
  137.                     test the rexx_wait command
  138.  
  139.                 download.rexx
  140.                     Auto-downloading from Calvacom
  141.  
  142.             I am sure some complex scripts could be written, even if the
  143.             way to get the characters received by Term II in an ARexx are
  144.             not very powerful. However, I will work to improve this.
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.         STARTING AN AREXX SCRIPT FROM TERM II
  154.  
  155.             You can start an ARexx program from Term II. For this, you have
  156.             to use the rexx command, which needs the name of a rexx program
  157.             as argument. For example :
  158.  
  159.                 - From Term II, select the "Command..." option in the
  160.                 Project menu, or hit <Amiga-Left><M>. This will request you
  161.                 for a command to type.
  162.  
  163.                 - In the string gadget of the requester, you can type the
  164.                 command :
  165.  
  166.                 rexx "download.rexx amiga/amiga/fontes/genfont.lzh ram:test"
  167.  
  168.                 or :
  169.  
  170.                 rexx "test_delay.rexx"
  171.  
  172.                 to start one of the ARexx examples (the rexx scripts must
  173.                 be in the same directory than Term)
  174.  
  175.