home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rximc175.zip / rexx.summary < prev    next >
Text File  |  2002-08-06  |  13KB  |  302 lines

  1. The REXX Summary
  2.  
  3. Summary of the summary
  4.  
  5.  * Section 1: Differences from TRL [1]
  6.  * Section 2: Summary of expression syntax
  7.  * Section 3: Summary of instructions
  8.  * Section 4: Summary of builtin functions
  9.  
  10. [1] The Rexx Language, a practical approach to programming
  11.     M. F. Cowlishaw
  12.     Englewood Cliffs 1985
  13.  
  14. 1 Differences from TRL
  15.  
  16. The following are all nonstandard features of REXX-imc
  17.  
  18.  * Rejection of labels ending with dot (in case of confusion between
  19.    function.(args) and stem.(tail))
  20.  * Compound variable accesses of the form "stem.'string constant'" and
  21.    stem.(expression)
  22.  * Acceptance of any non-zero number for logical truth, rather than just 1
  23.  * "SAYN expression" to output lines without carriage return
  24.  * "SELECT expression" to switch on a value
  25.  * "END SELECT"
  26.  * "PARSE VALUE" with multiple strings separated by commas
  27.  * "PROCEDURE HIDE"
  28.  * The following functions: b2d d2b chdir getcwd getenv putenv system userid
  29.    rxfuncadd rxfuncdrop rxfuncquery
  30.    plus these I/O functions: open close fdopen popen pclose fileno ftell
  31.  * error messages 80-210, -1 and -3.
  32.  
  33. 2 Summary of expression syntax
  34.  
  35. Strings:          "String constants" 'enclosed in quotes'
  36. Hex strings:      '616263 64'x
  37. Numbers:          123.4e-56
  38. Constant symbols: .abc 1d4 7!
  39. Simple symbols:   foo bar xyz3
  40. Stems:            array.
  41. Compound symbols: c.3 element.bar.45
  42. Operators:        arithmetic: + - * / ** (to-power) % (div) // (mod)
  43.                   string:     [abuttal] [space] || (concatenation)
  44.                   logical:    \ (not) & (and) | (or) && (xor)
  45.                   comparison: = > < <> <= >= \> \< \=
  46.                               == >> << <<= >>= \>> \<< \== (strong comparison)
  47. Function calls:   fn(1,2,3)    bar(,5)  'DATE'()
  48.  
  49. 3 Summary of instructions
  50.  
  51. /* this is a comment */
  52.  
  53. expression                     - execute a host command
  54.  
  55. symbol=value                   - assignment
  56.  
  57. ADDRESS [VALUE] [environment]  - change the current environment
  58. ADDRESS environment command    - execute a command in an environment
  59.  
  60. CALL name [arg][,[arg],...]]   - call a function or subroutine
  61. CALL ON condition [NAME symbol]- turn on condition handling
  62. CALL OFF condition             - turn off condition handling
  63.  
  64.     condition = ERROR | FAILURE | NOTREADY | HALT
  65.  
  66. DO [ symbol=start   [TO  finish]  ]     [WHILE expression_w]
  67.    [                [BY  step  ]  ]
  68.    [                [FOR count ]  ]     [UNTIL expression_u]
  69.  
  70.    [ expression_c                 ]     [FOREVER           ]
  71.  
  72.                                - block or repetitive block instruction
  73.  
  74. DROP symbol [symbol...]        - de-assignment
  75.  
  76. END [symbol]                   - end block or repetitive block instruction
  77.  
  78. EXIT [expression]              - exit program or external function
  79.  
  80. IF expression [;] THEN [;] statement [ ; ELSE [;] statement]
  81.                                - conditional instruction
  82.  
  83. INTERPRET expression           - dynamically execute a string
  84.  
  85. ITERATE [symbol]               - continue repetitive block
  86.  
  87. LEAVE [symbol]                 - leave repetitive block
  88.  
  89. NOP                            - do nothing
  90.  
  91. NUMERIC DIGITS n               - set parameters for numeric formatting
  92. NUMERIC FUZZ n
  93. NUMERIC FORM   SCIENTIFIC
  94.              | ENGINEERING
  95.              | "string constant"
  96.              | [VALUE] expression
  97.  
  98. OPTIONS expression             - Control system-dependent things
  99.  
  100. [PARSE [UPPER]] ARG template   
  101. [PARSE [UPPER]] PULL [template]
  102. PARSE [UPPER] LINEIN [template]
  103. PARSE [UPPER] SOURCE template
  104. PARSE [UPPER] VERSION template
  105. PARSE [UPPER] NUMERIC template
  106. PARSE [UPPER] VAR symbol template
  107. PARSE [UPPER] VALUE expression WITH template
  108.  
  109.     template        -> [firstPosition] assignments [assignments]
  110.     assignments     -> [nextPosition] varlist [stopPosition]
  111.     varlist         -> varname ' ' [varlist]
  112.     varname         ->   "non-constant symbol"
  113.                        | '.'
  114.     firstPosition   -> position
  115.     nextPosition    -> position [nextPosition]
  116.     stopPosition    -> position
  117.     position        ->   searchPosition
  118.                        | absPosition
  119.                        | relPosition
  120.                        | '(' "expression" ')'
  121.     searchPosition  -> "string constant"
  122.     absPosition     ->   "integer"
  123.                        | '=' numexpr
  124.     relPosition     ->   '+' numexpr
  125.                        | '-' numexpr
  126.     numexpr         ->   "integer"
  127.                        | '(' "integer expression" ')'
  128.  
  129. PROCEDURE                      - hide the caller's symbols
  130. PROCEDURE EXPOSE var1 [var2...]
  131. PROCEDURE HIDE var1 [var2...]
  132.  
  133. PUSH  expression               - stack a value in LIFO order
  134. QUEUE expression               - stack a value in FIFO order
  135.  
  136. RETURN [value]                 - return from a function or subroutine
  137.  
  138. SAY [expression]               - echo data
  139. SAYN expression                - echo data without newline
  140.  
  141. SELECT [expression]
  142.    WHEN expression THEN statements
  143.    WHEN expression THEN statements
  144.    ...
  145.    [OTHERWISE statements]
  146. END [SELECT]                   - switch on a list of conditions
  147.  
  148. SIGNAL [VALUE] name            - jump to a label
  149. SIGNAL ON condition [NAME symbol] - turn on condition handling
  150. SIGNAL OFF condition              - turn off condition handling
  151.  
  152.     condition = ERROR | FAILURE | NOTREADY | HALT | SYNTAX | NOVALUE
  153.  
  154. TRACE [symbol]                 - control program tracing. Values are:
  155. TRACE "string"                   A (all clauses) C (commands) E (error)
  156. TRACE VALUE expression           F (failure) I (intermediate values)
  157.                                  L (labels) N (normal, =F) O (off) 
  158.                                  R (results)
  159.  
  160.  
  161. 4 Summary of builtin functions
  162.  
  163. Standard functions
  164.  
  165. ABBREV(information,info[,length])  - check for valid abbreviations
  166. ABS(number)                        - return the absolute value
  167. ADDRESS()                          - return the current environment
  168. ARG([n][,opt])                     - return or test an argument
  169. BITAND(string1,string2[,pad])
  170. BITOR (string1,string2[,pad])      - combine two strings with bit operations
  171. BITXOR(string1,string2[,pad])
  172. B2D(binary)
  173. B2X(binary)
  174. D2B(decimal)
  175. C2X(string)
  176. C2D(string[,n])
  177. D2C(decimal[,n])                   - convert between data formats
  178. D2X(decimal[,n])
  179. X2B(hex)
  180. X2C(hex)
  181. X2D(hex)
  182. CENTER(s,n[,pad])                  - centre a string in a field
  183. CENTRE(s,n[,pad])
  184. COMPARE(s1,s2[,pad])               - compare two strings
  185. CONDITION([option])                - return information about trapped condition
  186.                                      Option can be (default I):
  187.                                    C (condition name) D (description)
  188.                                    I (instruction)    S (status)
  189.                                    
  190. COPIES(s,n)                        - replicate a string
  191. DATATYPE(string[,type])            - test datatype. Type can be:
  192.                                    A (alphanumeric) B (bits) L (lowercase)
  193.                                    M (mixed case) N (number) S (symbol chars)
  194.                                    U (upper case) W (whole number) X (hex)
  195.  
  196. DATE([format])                     - get date. Format can be:
  197.                                    B (base date - days since 1/1/1 AD)
  198.                                    C (days in century) D (days in year)
  199.                                    E (European) J (Julian) M (month name)
  200.                                    N (normal: dd Mon yyyy) O (ordered)
  201.                                    S (sorted) U (USA) W (day of week)
  202. DATE([format],date[,format])       - translate the given date from the latter
  203.                                      format to the former
  204.                                    
  205. DELSTR(string,n[,length])          - delete substring
  206. DELWORD(string,n[,length])         - delete words
  207. DIGITS()                           - NUMERIC DIGITS setting
  208. ERRORTEXT(i)                       - Rexx error message
  209. FORM()                             - NUMERIC FORM setting
  210.  
  211. FORMAT(number [,[before] [,[after] [,[expp] [,expt]]]] )
  212.                                    - format a number as specified
  213. FUZZ()                             - NUMERIC FUZZ setting
  214. INSERT(new,target[,[n][,[length][,pad]]])  - insert new string into target
  215. JUSTIFY(s,n[,pad])                 - justify text to given width
  216. LASTPOS(needle,haystack[,start])   - find last occurrence of a string
  217. LEFT(string,num[,pad])             - return an initial substring
  218. LENGTH(string)                     - find the length of a string
  219. LINESIZE()                         - find the terminal width
  220. MAX(number[,number...])            - find the maximum of a set
  221. MIN(number[,number...])            - find the minimum of a set
  222. OVERLAY(new,target[,[n][,[length][,pad]]])  - overlay new string on to target
  223. POS(needle,haystack[,start])       - find the first occurance of a string
  224. QUEUED()                           - return the number of items on the stack
  225. RANDOM([min][,[max][,seed]])       - return a random number
  226. REVERSE(string)                    - find the reverse of a string
  227. RIGHT(string,num[,pad])            - return a final substring
  228. RXFUNCADD(rexxname,module,sysname) - load an external function
  229. RXFUNCDROP(function)               - drop an external function
  230. RXFUNCQUERY(function)              - query whether a function is loaded
  231. SOURCELINE([i])                    - return a line of the source program
  232. SPACE(s[,[n][,pad]])               - evenly space words in a sentence
  233. STRIP(string[,[opt][,char]])       - remove leading/trailing spaces
  234. SUBSTR(string,n[,length[,pad]])    - return a substring
  235. SUBWORD(string,n[,k])              - return a substring of words
  236. SYMBOL(name)                       - test to see if a symbol is defined
  237. TIME([format])                     - get the time. Format can be:
  238.                                    C (civil time) N (normal) L (long)
  239.                                    H (hours since midnight)
  240.                                    M (minutes since midnight)
  241.                                    S (seconds since midnight) 
  242.                                    O (offset from GMT) E (elapsed time)
  243.                                    R (elapsed time then reset)
  244. TIME([format],time[,format])       - translate time from the latter format
  245.                                      to the former.
  246.                                    
  247. TRACE([setting])                   - get and/or set trace mode (see trace
  248.                                      instruction)
  249.                                      
  250. TRANSLATE(string[,[tableo][,[tablei][,pad]]])
  251.                                    - translate characters using given tables
  252. TRUNC(number[,n])                  - truncate floating point number
  253. VALUE(s[,[newvalue][,selector]])   - get or set value of a symbol
  254.  
  255. VERIFY(string,reference[,[option][,start]])
  256.                                    - verify string for valid characters
  257. WORD(string,n)                     - return a word from a string
  258. WORDINDEX(string,n)                - return the position of a word in a string
  259. WORDLENGTH(string,n)               - return the length of a word in a string
  260. WORDPOS(phrase,string[,start])     - find a phrase in a string 
  261. WORDS(string)                      - return the number of words in a string
  262. XRANGE([a[,b]])                    - return a range of characters
  263.  
  264. I/O functions (some of which are UNIX-specific)
  265.  
  266. CHARIN([stream] [,[position] [,count]])  - read characters
  267. CHAROUT([stream] [,[string] [,position] ]- write characters
  268. CHARS([stream])                          - number of characters available
  269. CLOSE(stream)                            - close a stream
  270. FDOPEN(fd [,[mode] [,stream]])           - open an fd number
  271. FILENO(stream)                           - find an fd number
  272. FTELL(stream)                            - return the current file pointer
  273. LINEIN([stream] [,[line] [,count]])      - read a line
  274. LINEOUT([stream] [,[string] [,line]])    - write a line
  275. LINES([stream])                          - determine whether lines may be read
  276. OPEN(file [,[mode] [,stream]])           - open a file
  277. PCLOSE(stream)                           - close a pipe
  278. POPEN(command [,[mode] [,stream]])       - open a pipe to a shell command
  279. STREAM(stream [,[option] [,command]])    - miscellaneous stream operations
  280.  
  281. UNIX-specific functions
  282.  
  283. CHDIR(directory)                   - change to new directory
  284. GETCWD()                           - return current working directory
  285. GETENV(name)                       - get an environment variable
  286. PUTENV(string)                     - set an environment variable
  287. SYSTEM(s)                          - return the output of a shell command
  288. USERID()                           - return the process owner's login name
  289.  
  290. Mathematical functions (implemented as separate package)
  291.  
  292. ACOS(x)      the arc-cosine of x in radians (0<=acs(x)<=pi)
  293. ASIN(x)      the arc-sine of x in radians (-pi/2<=asn(x)<=pi/2)
  294. ATAN(x)      the arc-tangent of x in radians (-pi/2<=atn(x)<=pi/2)
  295. COS(x)       the cosine of x radians
  296. EXP(x)       the exponential of x (2.718281... to the power x)
  297. LN(x)        the natural logarithm of x (x>0)
  298. SIN(x)       the sine of x radians
  299. SQRT(x)      the square root of x (x>=0) [arbitrary precision possible]
  300. TAN(x)       the tangent of x radians (x <> pi/2)
  301. TOPOWER(x,y) x to the power y
  302.