home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxfaq.zip / rexxfaq.txt < prev   
Text File  |  1994-08-12  |  32KB  |  794 lines

  1.                                                                  
  2.                             Frequently Asked Questions About REXX
  3.                                                                  
  4.                                    Last Revised:  August 12, 1994
  5.                                                                  
  6.                                                      Eric Giguere
  7.                                              giguere@watcom.on.ca
  8.  
  9.  
  10. ----------------------------------------------------------------
  11. Copyright Information
  12.  
  13.      This document is Copyright 1993, 1994 by Eric GiguΦre.
  14.      Permission is granted to reproduce and distribute all or
  15.      part of this document for non-commercial purposes only.  All
  16.      other uses must first be cleared with the author.  The
  17.      author may be contacted on the Internet at the address
  18.      giguere@watcom.on.ca or on paper by writing to Watcom
  19.      International, 415 Phillip Street, Waterloo, Ontario,
  20.      Canada, N2L 3X2.  Please note, however, that this document
  21.      is not published or endorsed by Watcom.
  22.      
  23. ----------------------------------------------------------------
  24. Introduction
  25.  
  26.      This document is intended to serve as a useful reference for
  27.      REXX-related information.  It aims for breadth as opposed to
  28.      depth, and references to other material are given where
  29.      appropriate.  Suggestions and updates should be sent to the
  30.      author in an attempt to keep this document relevant and up-
  31.      to-date.
  32.  
  33.      Readers will notice the prevalence of OS/2-related materials
  34.      in this document.  Most of the REXX-related activity at this
  35.      time is occurring on the OS/2 platform.  This document is
  36.      not intended to be OS/2-specific.  The author is quite happy
  37.      to include information on other platforms if you pass it on
  38.      to him.
  39.  
  40.      More information on REXX can also be had from the REXX Language
  41.      Association.  See below for details.
  42.      
  43. ----------------------------------------------------------------
  44. A. What Is REXX?
  45.  
  46.      REXX is a programming language designed by Michael Cowlishaw
  47.      of IBM UK Laboratories.  In his own words:  "REXX is a
  48.      procedural language that allows programs and algorithms to
  49.      be written in a clear and structured way."
  50.      REXX doesn't look that different from any other procedural
  51.      language.  Here's a simple REXX program:
  52.      
  53.           /* Count some numbers */
  54.           
  55.           say "Counting..."
  56.           do i = 1 to 10
  57.               say "Number" i
  58.           end
  59.      
  60.      What makes REXX different from most other languages is that
  61.      it is also designed to be used as a macro language by
  62.      arbitrary application programs.  The idea is that
  63.      application developers don't have to design their own macro
  64.      languages and interpreters.  Instead they use REXX as the
  65.      macro language and support the REXX programming interface.
  66.      If a REXX macro comes across an expression or function call
  67.      that it cannot resolve, it can ask the application to handle
  68.      it instead.  The application only has to support the
  69.      features that are specific to it, freeing the developer from
  70.      handling the mundane (and time-consuming) task of writing a
  71.      language interpreter.  And if all applications use REXX as
  72.      their macro language, the user only has to learn one
  73.      language instead of a dozen.
  74.      
  75. ----------------------------------------------------------------
  76. B. REXX and the Internet
  77.  
  78.      Networks connect computers in various ways for the exchange
  79.      of data.  The terminology is a bit confusing to the new
  80.      user.  Here are the definitions this document uses:
  81.  
  82.        Usenet: Not really a network, just the set of machines
  83.        that exchange network news.  Network news is really an
  84.        extended form of electronic mail that groups messages
  85.        from individuals into newsgroups that users can read
  86.        using special newsreaders.
  87.  
  88.        Internet: The worldwide network based on TCP/IP
  89.        protocols.  Besides being able to receive mail and
  90.        newsgroups, these machines can use programs like ftp and
  91.        telnet to communicate with other machines in real time.
  92.        Most Internet machines are Unix-based.
  93.  
  94.        BITNET: The worldwide network that connects many IBM
  95.        mainframes.  BITNET users can also transfer files using
  96.        methods that are incompatible with those of the Internet.
  97.      
  98.      Newsgroups
  99.  
  100.      The Usenet group comp.lang.rexx exists for discussion of
  101.      REXX in all its variations.  Anything posted to this
  102.      newsgroup also gets sent to the REXXLIST mailing list (see
  103.      below) and vice-versa.
  104.  
  105.      Other newsgroups of interest are machine-specific.
  106.      Recommended groups are comp.os.os2.programmer.misc and
  107.      comp.sys.amiga.programmer.
  108.      
  109.      FTP Sites of Interest
  110.  
  111.      FTP is a file transmission protocol used on the Internet to
  112.      transfer files between machines.  The transfers are done in
  113.      real time and usually require that the user have an account
  114.      on both machines.  However, many machines on the Internet
  115.      support what is known as anonymous FTP, which allows users
  116.      on other machines access to a limited set of files without
  117.      requiring an account.  Some of the more interesting sites
  118.      that offer this service are:
  119.  
  120.         rexx.uwaterloo.ca        General repository for REXX-related
  121.                                  information, including free REXX
  122.                                  interpreters for Unix and DOS.  An
  123.                                  XEDIT clone for Unix and OS/2 may
  124.                                  also be found here.  Look under
  125.                                  /pub/rexx.
  126.  
  127.         ftp.pvv.unit.no          The official home of Regina, one of
  128.                                  the free Unix interpreters.  Archives
  129.                                  of the messages in comp.lang.rexx and
  130.                                  RexxLA messages are also maintained
  131.                                  here.  Check under /pub/rexx.
  132.  
  133.         ftp-os2.cdrom.com        General OS/2 archives.  Look under
  134.         ftp.luth.se              /pub/os2.
  135.                                       
  136.         wuarchive.wustl.edu      General Amiga archive.  Look under
  137.                                  /pub/aminet.
  138.      
  139.      Mailing Lists
  140.  
  141.      Mailing lists are similar to newsgroups but use normal
  142.      electronic mail to deliver the messages.  The following
  143.      mailing lists are mostly BITNET-based but are accessible
  144.      from the Internet as well:
  145.      
  146.        List name     BITNET      Internet           Discusses
  147.                       Node        Address
  148.        REXXLIST      UCF1VM    ucf1vm.cc.ucf.edu    REXX in general
  149.         AREXX-L      UCF1VM    ucf1vm.cc.ucf.edu    Amiga REXX
  150.         PC-REXX      UCF1VM    ucf1vm.cc.ucf.edu    Personal REXX
  151.        REXXCOMP      UCF1VM    ucf1vm.cc.ucf.edu    IBM's REXX compiler
  152.        TSO-REXX      UCF1VM    ucf1vm.cc.ucf.edu    TSO REXX
  153.         VM-REXX      UCF1VM    ucf1vm.cc.ucf.edu    VM/SP REXX
  154.         UREXX-L      (none)    liverpool.ac.ak      Unix REXX
  155.      
  156.      To subscribe to any of these lists, send a one-line message
  157.      to the address LISTSERV@node, where node is the BITNET node
  158.      or Internet address for the list you wish to join.  In the
  159.      body of your message should be the line
  160.                SUBSCRIBE list-name your--full-name
  161.      as in
  162.                  SUBSCRIBE UREXX-L Eric Giguere
  163.      You will then be subscribed to the list and messages will
  164.      start arriving in your mailbox.  To send a message to the
  165.      list, simply mail it to listname@node, as in UREXX-
  166.      L@liverpool.ac.uk.  Note the distinction between the
  167.      LISTSERV address and the listname address.  You can receive
  168.      help by sending a HELP message to the LISTSERV address.
  169.      Note that some of these mailing lists may be available on
  170.      Usenet in the form of newsgroups with names starting with
  171.      "bit.listserv".  Ask your system administrator if you're not
  172.      sure.
  173.  
  174.      Thanks to Scott Ophof for providing this summary.
  175.      
  176.      Gopher Service
  177.  
  178.      Gopher clients may find REXX-related information at the site
  179.      gopher.pvv.unit.no (Europe) and index.almaden.ibm.com (N. America).
  180.      
  181. ----------------------------------------------------------------
  182. C. Free REXX Products
  183.  
  184.      
  185.      Interpreters
  186.  
  187.      There are at least three REXX interpreters available for
  188.      free on the Internet.  The first two are Unix based and are
  189.      well-supported by their authors.  The third is an MS-DOS
  190.      interpreter.
  191.  
  192.      Regina is Anders Christensen's REXX interpreter for various
  193.      flavours of Unix and VMS.  It is fairly complete and Anders
  194.      even has an API for developers.  It also apparently can be
  195.      ported to OS/2.  Anders can be reached at
  196.      anders@pvv.unit.no.  Regina's official home is
  197.      ftp.pvv.unit.no.
  198.  
  199.      REXX/imc is Ian Collier's REXX interpreter for SunOS, though
  200.      it has also been ported to other Unix systems.  Ian can be
  201.      reached at imc@prg.ox.ac.uk.
  202.  
  203.      BREXX is Bill Vlachoudis' REXX interpreter for MS-DOS.  The
  204.      interpreter is not complete but is quite small.  Bill can be
  205.      reached at bill@donoussa.physics.auth.gr.
  206.  
  207.      All three interpreters are available for anonymous FTP on
  208.      rexx.uwaterloo.ca in the /pub/freerexx directory, each
  209.      interpreter in its own subdirectory.  Regina and REXX/imc
  210.      are in source form, BREXX is only available as binary.
  211.      
  212.      REXX-Aware Text Editors
  213.  
  214.      Also on rexx.uwaterloo.ca in the /pub/editors directory is
  215.      the text editor THE by Mark Hessling
  216.      (mark@snark.itc.gu.edu.au).  THE is a full-featured
  217.      XEDIT/KEDIT clone (by XEDIT here we mean the IBM mainframe
  218.      text editor, not the X Windows editor xedit) with REXX
  219.      support.  THE is available in versions for OS/2 and Unix.
  220.      THE's official home is on ftp.gu.edu.au in /src/THE.
  221.      
  222. ----------------------------------------------------------------
  223. D. Commercial REXX Products
  224.  
  225.      Interpreters
  226.  
  227.      REXX interpreters are available commercially for a wide
  228.      variety of systems and come standard on some operating
  229.      platforms such as the Amiga, OS/2 and the IBM AS/400 and
  230.      mainframes (VM, TSO, VSE). The following vendors sell
  231.      REXX interpreters:
  232.      
  233.           The Workstation Group     [Various UNIX platforms, also VMS]
  234.           6300 River Road
  235.           Rosemont, IL  60018
  236.           (800) 228-0255 (US only)
  237.           sales@wrkgrp.com
  238.      
  239.           Quercus Systems          [DOS, Windows, Windows NT, OS/2]
  240.           P.O. Box 2157
  241.           Saratoga, CA  95070
  242.           (408) 867-7399
  243.           (800) 440-5944 (US & Canada)
  244.           75300.2450@compuserve.com
  245.      
  246.           Simware                  [Novell Netware]
  247.           2 Gurdwara Road
  248.           Ottawa, Ontario
  249.           Canada  K2E 1A2
  250.           (613) 727-1779
  251.  
  252.      IBM also sells REXX interpreters for AIX and Netware.
  253.  
  254.      
  255.      Compilers
  256.  
  257.      Although REXX is usually thought of as an interpreted
  258.      language, it can also be compiled.  The following vendors
  259.      all sell REXX compilers:
  260.      
  261.           Dineen Edwards Group          [Amiga]
  262.           19785 West 12 Mile Road, Suite 305
  263.           Southfield, MI  48076-2553
  264.           (313) 352-4288
  265.      
  266.           IBM                      [VSE, MVS/TSO and VM/CMS]
  267.           Contact your local representative
  268.      
  269.           Systems Center           [VM/CMS]
  270.           1800 Alexander Bell Drive
  271.           Reston, VA  22091
  272.      
  273.  
  274.      Visual Development Environments
  275.  
  276.      There are three REXX-based visual development environments
  277.      available for OS/2:
  278.      
  279.           VX-REXX        Watcom International
  280.                          415 Phillip Street
  281.                          Waterloo, Ontario
  282.                          Canada  N2L 3X2
  283.                          Phone: (519) 886-3700
  284.                          Fax: (519) 747-4971
  285.      
  286.           VisPro/REXX    HockWare
  287.                          315 N. Academy St., Suite 100
  288.                          Cary, NC 27513
  289.                          Phone: (919) 380-0616
  290.                          Fax: (919) 380-0757
  291.  
  292.           GpfRexx        Gpf Systems
  293.                          10 Falls Road
  294.                          Moodus, Conn.  06469
  295.                          Phone: (203) 873-3300
  296.                          Fax: (203) 873-3302
  297.      
  298.  
  299.      REXX-Aware Text Editors
  300.  
  301.      Clones of the popular XEDIT editor are available for Unix
  302.      from the Workstation Group (see address above) and for DOS
  303.      and OS/2 from Mansfield Software.  Tritus sells an ISPF/PDF
  304.      text editor with REXX support for OS/2.  One Up sells SourceLink,
  305.      an integrated development environment for OS/2 with REXX macro
  306.      capabilities.  Command Technology sells the SPF/PC editor.
  307.      
  308.           Mansfield Software
  309.           P.O. Box 532
  310.           Storrs, CT  06268
  311.           Phone: (203) 429-8402
  312.           Fax: (203) 487-1185
  313.  
  314.           Tritus
  315.           3300 Bee Caves Road, Suite 650
  316.           Austin, Texas  78746
  317.           Phone: (512) 794-5800
  318.           Fax: (512) 7940-3833
  319.  
  320.           One Up
  321.           1603 LBJ Freeway, Suite 200
  322.           Dallas, Texas  75243
  323.           Phone: (800) 678-0187
  324.  
  325.           Command Technology
  326.           1040 Marina Village Parkway
  327.           Alameda, CA  94501
  328.           Phone: (800) 336-3320
  329.      
  330.      The OS/2 Enhanced Editor (EPM.EXE), which is bundled with
  331.      OS/2, also has REXX support.  Use its online help and search
  332.      for the 'rx' command.
  333.  
  334.  
  335.      REXX Extensions
  336.  
  337.      A number of vendors sell extensions to REXX:
  338.  
  339.      -- Quercus Systems (address above) sells REXXLIB (a collection
  340.         of over 150 REXX extension functions), REXXCOMM (a function
  341.         package for accessing serial ports from REXX) and REXXTERM
  342.         (a full-featured asynchronous communications program).
  343.  
  344.      -- SofTouch Systems sells the GammaTech REXX SuperSet/2, a
  345.         collection of over 300 REXX extension functions for OS/2.
  346.  
  347.      -- dSoft Development sells the dbfREXX function library that
  348.         lets you read and write dBASE files from OS/2 REXX.
  349.  
  350.  
  351.      SofTouch Systems
  352.      1300 S. Meridian, Suite 600
  353.      Oklahoma City, Okla.  73108-1751
  354.      Phone: (405) 947-8080
  355.      Fax: (405) 632-6537
  356.  
  357.      dSoft Development
  358.      4710 Innsbruk Drive
  359.      Houston, Texas  77066
  360.      Phone: (405) 360-3045
  361.      Fax: (713) 537-0318
  362.      
  363. ----------------------------------------------------------------
  364. E. REXX and ANSI
  365.  
  366.      The American National Standards Institute (ANSI) sets
  367.      national standards for various things in the United States,
  368.      including programming languages.  The X3J18 REXX Standards
  369.      Committee is currently defining a formal standard for the
  370.      REXX language, using Mike Cowlishaw's book as its base
  371.      document.  The Committee meets 3 or 4 times a year and holds
  372.      ongoing discussions throughout the year by electronic mail.
  373.      Members of X3J18 are mostly REXX implementors, but anyone
  374.      can participate.  The Committee intends to release a draft
  375.      standard next year.  More information can be had from the
  376.      vice-chair, Neil Milsted at nfnm@wrkgrp.com.
  377.      Note that public ANSI documents relating to X3J18 can be had
  378.      using the LISTSERV service at PSUVM on BITNET or by Gopher
  379.      to gopher.pvv.unit.no on the Internet.
  380.      
  381. ----------------------------------------------------------------
  382. F. The REXX Language Association
  383.  
  384.      The REXX Language Association is an independent organization
  385.      dedicated to promoting the use of the REXX programming
  386.      language.  Activities of the RexxLA include:
  387.  
  388.      -- Maintaining an electronic mail server where members share
  389.         information.
  390.  
  391.      -- Distributing a quarterly newsletter.
  392.  
  393.      -- Providing electronic resources for access to language
  394.         expertise, hints and tips, example programs, product sources,
  395.         and other valuable information.
  396.  
  397.      -- Developing resource guides, both printed and electronic,
  398.         for publications, products, training and language experts.
  399.  
  400.      -- Developing educational, guest speaker, and publicity programs
  401.         to promote the use of REXX.
  402.  
  403.      -- Participating in the work of standards bodies.
  404.  
  405.      -- Promoting integration of REXX into all operating systems and as
  406.         the common scripting language for a wide array of software.
  407.  
  408.      -- Cooperating with the REXX Symposium in providing an annual
  409.         conference forum.
  410.  
  411.      Join today and start reaping the benefits available from an
  412.      international consortium of individuals, corporations, vendors,
  413.      authors and experts.
  414.  
  415.      For more information, contact the REXX Language Association by
  416.      mail or fax:
  417.  
  418.          RexxLA Membership
  419.          6300 North River Road, Suite 501
  420.          Rosemont, Illinois  60018
  421.          Fax: (708) 696-2277
  422.  
  423.      Or by electronic mail at rexxla@wrkgrp.com.
  424.  
  425.  
  426. ----------------------------------------------------------------
  427. G. The REXX Symposium
  428.  
  429.      The REXX Symposium is an annual conference devoted to REXX,
  430.      attended both by users and vendors, held at the beginning
  431.      of May.  It is sponsored by the Stanford Linear Accelerator,
  432.      with the cooperation of the RexxLA.  The 1995 conference
  433.      is still being planned.
  434.  
  435.  
  436. ----------------------------------------------------------------
  437. H. REXX Bibliography
  438.  
  439.      Mike Cowlishaw and Linda Green have kindly provided the
  440.      following partial bibliography of REXX books.
  441.      
  442.           The REXX Language -- M.F. Cowlishaw
  443.                English:       ISBN 0-13-780735-X  Prentice-Hall, 1985
  444.                          ISBN 0-13-780651-5  2nd edition, 1990
  445.                German:   ISBN 3-446-15195-8  Carl Hanser Verlag, 1988
  446.                          ISBN 0-13-780784-8  P-H International, 1988
  447.                Japanese: ISBN 4-7649-0136-6  Kindai-kagaku-sha, 1988
  448.      
  449.           The REXX Reference Summary Handbook -- Dick Goran
  450.               ISBN 0-9639854-1-8, CFS Nevada Inc., 1994
  451.  
  452.           Modern Programming Using REXX -- Robert P. O'Hara and
  453.                David R. Gomberg
  454.                English:  ISBN 0-13-597311-2  Prentice-Hall, 1985
  455.                          ISBN 0-13-579329-5  2nd edition, 1988
  456.      
  457.           REXX in the TSO Environment -- Gabriel F. Gargiulo
  458.                ISBN 0-89435-354-3, QED Information Systems Inc.
  459.                320 pages, 1990
  460.      
  461.           Using OS/2 REXX -- Gabriel F. Gargiulo
  462.               ISBN 0-894-35449-3, QED Publishing Group
  463.  
  464.           Practical Usage of REXX -- Anthony S. Rudd
  465.                ISBN 0-13-682790-X, Ellis Horwood (Simon & Schuster), 1990
  466.      
  467.           Using ARexx on the Amiga -- Chris Zamara and Nick Sullivan
  468.                ISBN 1-55755-114-6, Abacus Books, 1991
  469.      
  470.           The REXX Handbook -- Edited by Gabe Goldberg and Phil Smith III
  471.                ISBN 0-07-023682-8, McGraw-Hill, 1991
  472.      
  473.           Programming in REXX -- Charles Daney
  474.                ISBN 0-07-015305-1, McGraw-Hill, 1992
  475.      
  476.           Command Language Cookbook -- Hallett German
  477.                ISBN 0-442-00801-5, Van Nostrand Reinhold, 1992
  478.  
  479.           OS/2 2.1 REXX Handbook -- Hallett German
  480.                ISBN 0-442-01734-0, Van Nostrand Reinhold, 1994
  481.  
  482.           OS/2 REXX: From Bark to Byte -- Inter. Technical Supp. Org. (IBM)
  483.                IBM Document Number GG24-4199-00, 1993
  484.  
  485.           REXX: Advanced Techniques for Programmers -- Peter Kiesel
  486.                ISBN 0-07-034600-3, McGraw Hill, 1992
  487.  
  488.           REXX Tools and Techniques -- Barry Nirmal
  489.                ISBN 0-89435-417-5, QED Publishing Group, 1993
  490.  
  491.           The ARexx Cookbook -- Merrill Callaway
  492.                ISBN 0-96-327730-8, Whitestone, 1992
  493.  
  494.           Writing OS/2 REXX Programs -- Ronny Richardson
  495.                ISBN 0-07-052372, McGraw Hill, 1992
  496.  
  497.           Writing VX-REXX Programs -- Ronny Richardson
  498.                ISBN 0-07-9111911-5, McGraw Hill, 1994
  499.      
  500. =====================================================================
  501. I. Common REXX Coding Errors
  502.  
  503.     The following list of common REXX coding errors is derived from a list
  504.     included in the online documentation for Watcom VX-REXX.
  505.     
  506.     -----------------------------------------------------------------
  507.     1. Blank space where it does not belong
  508.  
  509.     In REXX expressions, blank space is interpreted as an implicit
  510.     concatenation operator -- the terms are concatenated with a blank
  511.     in between.  As a result, REXX will interpret many mistyped statements
  512.     as an expression involving the blank concatenation operator.
  513.  
  514.     For example, inserting a blank after a function name in a function call
  515.     changes the meaning of the expression from:
  516.  
  517.         text_upper = translate( text )
  518.  
  519.     to:
  520.  
  521.         text_upper = "TRANSLATE" || " " || text
  522.  
  523.     Blank space also plays a special role in the PARSE instruction.  Compare
  524.     the following:
  525.  
  526.         parse arg a b c
  527.         parse arg a, b, c
  528.  
  529.     The first line parses the first argument passed to the routine into three
  530.     parts, while the second line sets the three variables to the value of
  531.     the first three arguments passed to the routine.
  532.     
  533.     -----------------------------------------------------------------
  534.     2. Function calls versus the CALL statement
  535.  
  536.     When you call a routine that returns a result, you must enclose the
  537.     parameters in parentheses:
  538.  
  539.         text = VRGet( "EF_1", "Value" )
  540.  
  541.     Always assign the value of a function to a variable, or use
  542.     the CALL statement as described below.
  543.  
  544.     Otherwise REXX will pass the return value to the default
  545.     host environment, leading to strange and possibly damaging behaviour
  546.     on some systems.
  547.  
  548.     If you are calling a routine that does not return a value, or you
  549.     wish to ignore the return value, you should use the CALL instruction:
  550.  
  551.         call VRSet "EF_1", "BackColor", "Blue"
  552.  
  553.     Note that there is no comma between the name of the routine and the
  554.     first parameter.  Note also that parentheses are not used when using
  555.     the CALL instruction.
  556.     
  557.     -----------------------------------------------------------------
  558.     3. Line continuation
  559.  
  560.     The comma is used in REXX to split clauses across two or more lines.
  561.     For example:
  562.  
  563.         call foo a, b, c
  564.  
  565.     can also be written as:
  566.  
  567.         call foo a, ,
  568.                  b, ,
  569.                  c
  570.  
  571.     It's easy to forget the second comma when breaking a line in the
  572.     middle of a function parameter list.
  573.     
  574.     -----------------------------------------------------------------
  575.     4. Omitted arguments
  576.  
  577.     REXX allows arguments to be omitted.  Be careful not to omit
  578.     arguments by accident, such as including an unnecessary comma:
  579.  
  580.         call foo , a, b, c
  581.     
  582.     -----------------------------------------------------------------
  583.     5. Undefined variables
  584.  
  585.     It is not a syntax error to use undefined variables in REXX.
  586.     Undefined variables are defined to have their own name translated
  587.     to uppercase as their value.  As a result it is often difficult to
  588.     find programming errors that are a result of using undefined variables.
  589.  
  590.     Some tips:
  591.  
  592.     *   Add a SIGNAL ON NOVALUE statement to the main section of your
  593.         programs.  This will cause the system to issue a syntax error
  594.         if you use an undefined variable.
  595.     *   Be careful to include the period when referring to stems.
  596.         The variables "A" and "A." are unrelated.
  597.     *   Misspelled commands will often be interpreted as undefined variables.
  598.         The line:
  599.             sy 'hello'
  600.         (which should be "say 'hello'") will be interpreted as:
  601.             "SY" || " " || 'hello'
  602.         and will be send to the default command host for execution.
  603.     
  604.     -----------------------------------------------------------------
  605.     6. Using expressions in the tail of a compound symbol
  606.  
  607.     The tail of a compound symbol can only be a simple variable, as in:
  608.  
  609.         ok = A.I
  610.  
  611.     Literals are not allowed.  For example, the following is interpreted as a concatenation between "A." and 
  612.     "name":
  613.  
  614.         bad = A."name"
  615.  
  616.     Expressions are also not allowed.  You must first assign the value of the expression to a symbol and then 
  617.     use that symbol:
  618.  
  619.         J = I - 1
  620.         ok = A.J
  621.  
  622.  
  623. =====================================================================
  624. G. Frequently Asked Questions
  625.  
  626.     -----------------------------------------------------------
  627.     1. Is REXX better than <some other language>?
  628.  
  629.     Short answer:  Yes.  No.  Maybe.  Does it matter?
  630.  
  631.     Long answer:  This question wastes a lot of bandwidth in
  632.     comp.lang.rexx and other newsgroups.  Every language has its
  633.     good points and its bad points.  Some people love REXX, some
  634.     people hate it.  Use a language that suits your needs.
  635.  
  636.     -----------------------------------------------------------
  637.     2. Why does my OS/2 REXX program run more quickly the second time?
  638.  
  639.     When you run a REXX CMD file for the first time, a tokenized
  640.     version will be stored on disk using the OS/2 extended file
  641.     attributes.  (You can see how big the tokenized version is
  642.     by using the /N option on the DIR command.)  If a tokenized
  643.     version exists AND the file has not been modified, CMD.EXE
  644.     will use the tokenized version instead of parsing the
  645.     source.
  646.  
  647.     Note that there is a 64K limit on the size of an extended
  648.     attribute entry, so very large REXX programs do not benefit
  649.     from this automatic tokenization.
  650.          
  651.     -----------------------------------------------------------
  652.     3. How can I return multiple values from a function?
  653.  
  654.     REXX does not provide any support for returning more than a
  655.     single value from a function.  If you wish to return multiple values
  656.     , you must devise an alternate scheme.  A simple solution is to
  657.     concatenate the values together into a single string and on return
  658.     from the function use the PARSE instruction or the various string
  659.     functions to split the string back into its elements.  Don't forget
  660.     that you can use non-printable characters (such as '00'x) to
  661.     separate the data -- REXX will correctly handle such strings.
  662.     There may also be other alternatives available to you if you are
  663.     using an external function library that lets you store data in
  664.     separate memory pools or in disk files.
  665.     
  666.     -----------------------------------------------------------
  667.     4. Why does linein, lineout, charin or charout fail?
  668.  
  669.     Most versions of REXX (ARexx is an exception) use implicit file
  670.     opening.  That is, each time you reference a file in a LINEIN,
  671.     LINEOUT, CHARIN or CHAROUT function, REXX will open the file for
  672.     reading or writing if the file is not already open.  However, some
  673.     operating systems like DOS and OS/2 impose limits on the number of
  674.     files that can be open simultaneously, usually around 20 or so.  After
  675.     the limit has been reached, any further attempts to open another file
  676.     will fail.  That is why it is always good practice to close a file
  677.     when you're done with it.  In OS/2 this is done using the STREAM
  678.     function, as follows:
  679.  
  680.         call stream "c:\foo.out", "command", "close"
  681.     
  682.     The STREAM function can also be used to open files, query their sizes
  683.     and seek into the file.  Consult your REXX documentation for
  684.     specific instructions for your interpreter.
  685.     
  686.     -----------------------------------------------------------
  687.     5. How do I iterate over all the tails in a stem variable?
  688.  
  689.     One of the features REXX lacks is a function to return a list of
  690.     defined tails.  There are external libraries that provide functions
  691.     to do so, but if that is not an option then the only solution is to
  692.     maintain your own list of tails in a string and use the PARSE
  693.     instruction or the WORDS function to traverse the list.
  694.     
  695.     -----------------------------------------------------------
  696.     6. How do I REXX-enable my application?
  697.  
  698.     REXX-enabling an application means being able to run REXX macros
  699.     within an application.  This information is very system-specific,
  700.     so the best place to start is with the documentation provided with the
  701.     REXX interpreter.
  702.  
  703.     For OS/2, there are several sources of information.  The most basic
  704.     information is found in the OS/2 Toolkit, which includes the
  705.     REXXSAA.H header file and the REXX Reference online document.  The
  706.     REXX Report (see above) includes a couple of articles on the subject.
  707.     Sample source code comes with the OS/2 Toolkit and is also available
  708.     on rexx.uwaterloo.ca in the directory /pub/os2/vxrexx as VX-REXX
  709.     Tech Notes #1 and #7 (vxtech01.zip, vxtech07.zip -- neither tech
  710.     note requires that you own VX-REXX). OS/2 technical conferences such
  711.     as ColoradOS/2 or the IBM Technical Interchanges often includes
  712.     sessions on this topic. For ARexx, a book was available from
  713.     Commodore, but with the latter's demise it is unclear whether the
  714.     book is still available.
  715.     
  716.     -----------------------------------------------------------
  717.     7. How do I do inter-process communication in REXX?
  718.  
  719.     Again, this is system-specific.  The ARexx interpreter is built on
  720.     a messaging model, making it very simple to do inter-process
  721.     communication, but the OS/2 REXX interpreter has no such features,
  722.     though in some cases queues can be used to achieve the desired effect.
  723.     
  724.     -----------------------------------------------------------
  725.     8. How do I use global variables in my REXX programs?
  726.  
  727.     The scope of variables is controlled by the PROCEDURE instruction.
  728.     If a routine is declared with the PROCEDURE instruction, only
  729.     those variables exposed using the EXPOSE instruction are available to the
  730.     routine.  If no PROCEDURE instruction is used, all of the caller's
  731.     variables are available to the callee. Here is a simple example:
  732.     
  733.         a = 10
  734.         b = 20
  735.         call first
  736.         call second
  737.         call third
  738.         exit
  739.         
  740.         first:
  741.             say "first -- a is" a "b is" b
  742.             return
  743.         
  744.         second: procedure
  745.             say "second -- a is" a "b is" b
  746.             return
  747.         
  748.         third: procedure expose a
  749.             say "third -- a is" a "b is" b
  750.             b = 30
  751.             call first
  752.             return
  753.     
  754.     Running this program yields the following output: 
  755.     
  756.         first -- a is 10 b is 20
  757.         second -- a is A b is B
  758.         third -- a is 10 b is B
  759.         first -- a is 10 b is 30
  760.     
  761.     Use the PROCEDURE instruction to keep variables local to a procedure,
  762.     using EXPOSE to explicitly expose any "global" variables.  The
  763.     only catch is that you have to make sure you expose the variables
  764.     inside every procedure. One way to define and use global variables
  765.     is to use a stem called "Globals." and define all your procedures
  766.     like this:
  767.     
  768.         Foo: procedure expose Globals.
  769.     
  770.     Then at the top of you program initialize the Globals stem and
  771.     assign appropriate values to your global variables:
  772.     
  773.         Globals. = ''
  774.         Globals.!NeedToSave = 0
  775.         Globals.!TmpDir = "D:\TMP"
  776.     
  777.     The tail names in this example are all prefixed with '!', though you
  778.     could also use an underscore ('_'). This is just a convention
  779.     used to avoid this kind of problem:
  780.     
  781.         Globals.TmpDir = "D:\TMP"
  782.         call Foo
  783.         say Globals.TmpDir
  784.         exit
  785.     
  786.         Foo: procedure expose Globals.
  787.             tmpdir = "foo"
  788.             Globals.TmpDir = tmpdir
  789.             return
  790.         
  791.     It's a subtle bug that has to do with how REXX interprets stem tails.
  792.     
  793.     
  794.