Jump to content

REXX Tips & Tricks:General hints for REXX

From EDM2
Revision as of 18:12, 4 November 2012 by Martini (talk | contribs) (Created page with "This section contains general hints for REXX under OS/2. Another good source for REXX related information is the Web pages of Quercus System--in particular, the pages How do I ....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This section contains general hints for REXX under OS/2.

Another good source for REXX related information is the Web pages of Quercus System--in particular, the pages How do I ... and Common REXX Pitfalls (see Internet - Web Pages)

You should also take a look at the REXX FAQ maintained by Dave Martin (see Internet - Web Pages).

REXX and Y2K

The latest FixPaks for OS/2 Warp 3 (FP35 and above) and Warp 4 (FP6 and above) contain extensions for REXX to make it "Y2K Tolerant".

From a recent FixPak's Readme:


  4.1 QUERYING FILE DATES FOR FILES AFTER DEC 31, 1999 IN REXX

     Existing REXX functions return file dates with a two digit year
     only. While these functions are Year 2000 tolerant (i.e. the
     results will be correct for files dated after Dec 31, 1999)
     they require some additional logic in existing programs to
     handle the returned date correctly when they are compared with
     other file dates.

     Since the output format of the exisiting functions could not
     be changed for compatibility reasons, new options have been
     added to the REXX interpreter to return file dates with the
     year formatted with 4 digits. Two functions have been
     extended to support the new format. The syntax to retrieve the
     file date in 4 digit format is as follows:

     /********************************************/
     /* Use STREAM QUERY TIMESTAMP to query file */
     /* date in 4 digit format                   */
     /********************************************/

     Say Stream("C:\CONFIG.SYS", "C", "QUERY TIMESTAMP")

     /***********************************************/
     /* Use option "L" with SysFileTree to return a */
     /* list of files with long date format         */
     /***********************************************/

     Call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs"
     Call SysLoadFuncs
     Call SysFileTree "C:\*.*", "Files", "L"
     Do i = 1 To Files.0
        Say Files.i
     End /* do */

Reserved Words

"REXX has no reserved words. Words are only reserved in context. Hence:


 if=1

 if if then
   then=2;
 else
   else=7

 do forever=3 to 7 until end;
   end=1;
 end

parse var x with var with left right value

are all valid instructions. A function is recognised solely by the presence of a '(' appearing immediately after it, not by the spelling of its name.

This is where Rexx has a big advantage over things like Visual BASIC. (I was typing a BASIC program the other day, and the first three variable names I tried were all keywords...)"

Source: Ian Collier