home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 14 / 14.iso / s / s003 / 16.ddi / REXXPUBS / OS2_BOOK_REXX.INF (.txt)
Encoding:
OS/2 Help File  |  1992-03-30  |  195.5 KB  |  7,073 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. The OS/2 Procedures Language 2/REXX ΓòÉΓòÉΓòÉ
  3.  
  4. The OS/2* Procedures Language 2/REXX (referred to as REXX for the rest of this 
  5. information) is designated as the Systems Application Architecture* Procedures 
  6. Language for the Office Vision family of products and the OS/2 operating 
  7. system.  It was designed to make programming easier to write and debug. 
  8. High-quality programming can now be achieved using common English words in a 
  9. natural syntax flow that both beginning and experienced programmers can 
  10. understand. 
  11.  
  12. REXX uses a few powerful, general-purpose programming functions and common 
  13. arithmetical abilities, as well as OS/2 commands, within a simple framework. 
  14. Existing batch files can be converted to REXX procedures, with more power and 
  15. function. 
  16.  
  17. REXX files only operate in OS/2 sessions, must have a file name extension of 
  18. .CMD, and must start with a comment line (/*....*/).  As in batch files, it is 
  19. not necessary to type the .CMD extension to start a REXX procedure. 
  20.  
  21. This Information: 
  22.  
  23. This online REXX information is designed to acquaint you with the REXX 
  24. language, show you some of its features and capabilities, and give you a  basic 
  25. understanding of how it works.  The sections from "Getting Started.." to 
  26. "PMREXX" are written as an overview, stressing general concept information, 
  27. while the sections on "Instructions" and "Functions" include specific 
  28. information about all of the instructions and functions that are part of REXX. 
  29. For more complete and detailed information about REXX, see the OS/2 Procedures 
  30. Language 2/REXX Reference or User's Guide. 
  31.  
  32.  
  33. ΓòÉΓòÉΓòÉ 2. Getting Started in REXX ΓòÉΓòÉΓòÉ
  34.  
  35. A REXX procedure is a program that consists of a series of tasks in one common 
  36. processing file or batch file. 
  37.  
  38. Many languages can be used to write programs. BASIC, which is widely used in 
  39. home computing, has very few rules, but it requires writing many lines of code 
  40. for an intricate program.  Languages such as PL/1, COBOL, C, APL, and PASCAL 
  41. have more rules, but allow you to write more functions in fewer lines. 
  42.  
  43. REXX combines the simplicity of a programming language such as BASIC with 
  44. features that exist in more powerful languages such as writing fewer lines.  It 
  45. is easier to learn, because it uses familiar words and concepts.  REXX allows 
  46. you to do simple tasks, yet has the ability to handle complex tasks. 
  47.  
  48. To get started in REXX, you need: 
  49.  
  50. o A Personal Computer with OS/2 Version 2.0 installed.  REXX works only in OS/2 
  51.   sessions. 
  52. o Knowledge about using a text editor. 
  53.  
  54. Many of us learn by looking at examples, so examples of REXX procedures are 
  55. provided in this presentation. First look at the procedure, then study the 
  56. explanation of the examples to see what the procedure contains.  If you like, 
  57. try the procedure to see how it works. 
  58.  
  59.  
  60. ΓòÉΓòÉΓòÉ 2.1. Writing a REXX Procedure ΓòÉΓòÉΓòÉ
  61.  
  62. We shall write the following REXX procedure using a text editor. To write a 
  63. REXX procedure named HELLO.CMD while using the text editor follow these 
  64. instructions: 
  65.  
  66.  1. Create a text file named HELLO.CMD. 
  67.  2. Type the procedure HELLO.CMD, as follows: 
  68.  
  69.         /* An introduction to REXX */
  70.         SAY "Hello! I am REXX"
  71.         SAY "What is your name?"
  72.         PULL who
  73.          IF who = ""
  74.           THEN
  75.           SAY "Hello Stranger"
  76.          ELSE
  77.           SAY "Hello" who
  78.         EXIT
  79.  
  80.  3. Save the file and exit from the text editor. 
  81.  
  82. Now you are ready to run the REXX procedure you have written.  Type the name of 
  83. the procedure at the OS/2 command prompt and press Enter. 
  84.  
  85. hello
  86.  
  87. When the procedure pauses, you can either type your name or press Enter to see 
  88. the other response. 
  89.  
  90. A brief description of each part of HELLO.CMD follows: 
  91.  
  92. /* An introduction to REXX */  A comment explains what the procedure is about. 
  93. A comment starts with a /* and ends with a */.  All REXX procedures must start 
  94. with a comment on line one and column one of the file.  The comment tells the 
  95. command processor that the procedure being run is a REXX procedure and 
  96. distinguishes it from simple batch files. 
  97.  
  98. SAY "Hello! I am REXX." SAY "What is your name?"  These instructions cause the 
  99. words between the quotation marks to be displayed on your screen. 
  100.  
  101. PULL who  The PULL instruction reads the response entered from the keyboard and 
  102. puts it into the system's memory.  Who is the name of the place in memory where 
  103. the user's response is put.  Any name can be used with the PULL instruction. 
  104.  
  105. IF who = " "  The IF instruction tests a condition.  The test in this example 
  106. determines if who is empty.  It is empty if the user types a space and presses 
  107. Enter or just presses Enter. 
  108.  
  109. THEN  Specifies that the instruction that follows is to be run, if the tested 
  110. condition is true. 
  111.  
  112. SAY "Hello Stranger"  Displays Hello Stranger on the screen. 
  113.  
  114. ELSE  Specifies that the instruction that follows is to be run if the tested 
  115. condition is not true. 
  116.  
  117. SAY "Hello" who  Displays Hello on the screen, followed by whatever is in who. 
  118.  
  119. EXIT  This instruction causes the procedure to stop. 
  120.  
  121. Here is what would happen if a person named Bill tried the HELLO program: 
  122.  
  123. [C:\]hello
  124. Hello! I am REXX.
  125. What is your name?
  126.  
  127. Bill
  128.  
  129. Hello BILL
  130.  
  131. [C:\]
  132. If Bill does not type his name, but types a blank space, this happens: 
  133.  
  134. [C:\]hello
  135. Hello! I am REXX.
  136. What is your name?
  137.  
  138. Hello Stranger
  139.  
  140. [C:\]
  141.  
  142.  
  143. ΓòÉΓòÉΓòÉ 3. Using Fundamental REXX Elements ΓòÉΓòÉΓòÉ
  144.  
  145. This section gives you a chance to try some of the elements used in writing 
  146. REXX procedures.  Do not worry about making mistakes because you will be guided 
  147. through the steps. 
  148.  
  149. Note:   When writing a REXX procedure, it is best to use one line for each 
  150.         element. If you want an element to span more than one line, you must 
  151.         put a comma (,) at the end of the line to indicate that the element 
  152.         continues on the next line.  If you want to put more than one element 
  153.         on a line, you must use a semicolon (;) to separate the elements. 
  154.  
  155. A REXX procedure can contain any or all of the following elements: 
  156.  
  157. o Comments 
  158. o Strings 
  159. o Instructions 
  160. o OS/2 Commands 
  161. o Assignments 
  162. o Labels 
  163. o Internal Functions. 
  164.  
  165.  
  166. ΓòÉΓòÉΓòÉ 3.1. Comments ΓòÉΓòÉΓòÉ
  167.  
  168. All REXX procedures must begin with a comment starting in column one of line 
  169. one.  The comment tells the command interpreter it is about to read and run a 
  170. REXX procedure. The symbols for a comment are: 
  171.  
  172. /*          To mark the start of a comment 
  173.  
  174. */          To mark the end of a comment. 
  175.  
  176. When the interpreter finds a /*, it stops interpreting; when it encounters a 
  177. */, it begins interpreting again with the information following the symbol. 
  178. The comment can be a few words, no words, or several lines, as in the following 
  179. examples: 
  180.  
  181. /* This is a comment. */
  182.  
  183. or, 
  184.  
  185. SAY "'Be Prepared!'" /* This comment is on the same line
  186. as the instruction and continues on to the next line */
  187.  
  188. You can use only /* */ to start a REXX procedure, but it is better to put a 
  189. brief description of the procedure between the comment symbols. 
  190.  
  191. The comment can indicate the purpose of the procedure, the kind of input it can 
  192. handle, and the kind of output it produces. Comments help you understand the 
  193. procedure when you read it later, perhaps to add to it, improve it, or use it 
  194. elsewhere in the same procedure or another procedure. 
  195.  
  196. When you write procedures, remember that others may need to use or modify them. 
  197. It is a good idea to add comments to the instructions so that anyone can 
  198. understand each step.  If you do not use a procedure often, it is helpful to 
  199. have reminders to aid your memory. In general, explain your procedure well 
  200. enough so that others can understand it. 
  201.  
  202.  
  203. ΓòÉΓòÉΓòÉ 3.2. Strings ΓòÉΓòÉΓòÉ
  204.  
  205. A string is any group of characters inside single or double quotation marks. 
  206. Either type of quotation marks can be used, but the beginning and the ending 
  207. mark must match.  The interpreter stops interpreting when it sees a quotation 
  208. mark and the characters that follow remain as they were typed, with uppercase 
  209. and lowercase letters.  The interpreter resumes interpreting when it sees a 
  210. matching quotation mark.  For example: 
  211.  
  212. 'The Greatest Show on Earth'
  213. "The President leads his country"
  214.  
  215. are both strings. 
  216.  
  217. To use an apostrophe (single quotation mark) or double quotation marks within a 
  218. string, use the other quotation mark around the whole string.  For example: 
  219.  
  220. "Don't count your chickens before they hatch."
  221.  
  222. or 
  223.  
  224. 'Do not count your "chickens" before they hatch.'
  225.  
  226. You also can use a pair of quotation marks (the same as those used to mark the 
  227. string) as follows: 
  228.  
  229. SAY "Mary said  ""He's here."""
  230.  
  231. This is interpreted by REXX as: 
  232.  
  233. Mary said  "He's here."
  234.  
  235.  
  236. ΓòÉΓòÉΓòÉ 3.3. Instructions ΓòÉΓòÉΓòÉ
  237.  
  238. An instruction tells the system to do something.  Instructions can contain one 
  239. or more assignments, labels, or commands and they usually start on a new line. 
  240. The following are explanations of some of the more common instructions. 
  241.  
  242. SAY Instruction - The format for the SAY instruction is: 
  243.  
  244. SAY expression
  245.  
  246. The expression can be something you want displayed on the screen or something 
  247. to be computed, such as an equation: 
  248.  
  249. SAY 5 + 6 "= eleven"
  250.  
  251. This displays 
  252.  
  253. 11 = eleven
  254.  
  255. With the SAY instruction, anything not in quotation marks is changed to 
  256. uppercase or is processed.  If you want something to appear exactly as it is 
  257. typed, enclose it in quotation marks. 
  258.  
  259. PULL and PARSE PULL Instructions - 
  260.  
  261. In a procedure, the usual sequence of instructions is to use SAY to ask a 
  262. question and PULL to receive the answer.  The response typed by the user is put 
  263. into system memory.  The following procedure does not work correctly if the 
  264. PULL instruction comes before the SAY instruction. 
  265.  
  266. Question:  What do you think happens when the following procedure, NAME.CMD, is 
  267. run? 
  268.  
  269. /* Using the PULL Instruction */
  270. SAY "Enter your name"
  271. PULL name          /* Puts response
  272. from user into memory */
  273. SAY "Hello" name
  274. EXIT
  275.  
  276. Answer:  NAME.CMD puts a name in memory and then displays that name anywhere in 
  277. the file that the word name appears without the protection of single or double 
  278. quotation marks. 
  279.  
  280. If you tried the NAME procedure, you probably noticed that your name was 
  281. changed to uppercase.  To keep the characters as you type them, use the PARSE 
  282. PULL instruction.  Here is an example called CHITCHAT.CMD that uses the PARSE 
  283. PULL instruction: 
  284.  
  285. /* Using the PARSE PULL Instruction */
  286. SAY "Hello! Are you still there?"
  287. SAY "I forgot your name.  What is it?"
  288. PARSE PULL name
  289. SAY name "Are you going to Richard's seminar?"
  290. PULL answer
  291. IF answer = "YES"
  292.  THEN
  293.  SAY "Good.  See you there!"
  294. IF answer = "NO"
  295.  THEN
  296.  SAY "Sorry,  We will miss your input."
  297. EXIT
  298. The PARSE PULL instruction reads everything from the keyboard exactly as it is 
  299. typed, in uppercase or lowercase.  In this procedure, the name is displayed 
  300. just as you type it.  However, answer is changed to uppercase characters 
  301. because the PULL instruction was used.  This ensures that if yes, Yes, or YES 
  302. is typed, the same action is taken. 
  303.  
  304. EXIT Instruction 
  305.  
  306. The EXIT instruction tells the procedure to end.  The EXIT instruction should 
  307. be used in a procedure that contains subroutines.  Although the EXIT 
  308. instruction is optional in some procedures, it is good programming practice to 
  309. use it at the end of every procedure. 
  310.  
  311.  
  312. ΓòÉΓòÉΓòÉ 3.4. OS/2 Commands ΓòÉΓòÉΓòÉ
  313.  
  314. A command is a word, phrase, or abbreviation that tells the system to do 
  315. something.  In REXX, anything that is not a REXX instruction, assignment, or 
  316. label is considered a command.  For example, you can use OS/2 commands such as 
  317. COPY, BACKUP, PRINT, TYPE, and so on in your procedures. 
  318.  
  319. Here is an example of using the OS/2 command, TYPE, in a REXX procedure: 
  320.  
  321. /* Issuing commands in REXX */
  322. TYPE hello.cmd
  323. EXIT
  324.  
  325. This means that REXX will cause TYPE to be run. 
  326.  
  327.  
  328. ΓòÉΓòÉΓòÉ 3.5. Assignments ΓòÉΓòÉΓòÉ
  329.  
  330. An assignment tells the system that a string should be put in a special place 
  331. in system memory.  In the example: 
  332.  
  333. Work = "Building 021"
  334.  
  335. the string Building 021 is stored as the value Work in system memory.  Because 
  336. Work can have different values (be reassigned to mean different things) in 
  337. different parts of the procedure, it is called a Variable. 
  338.  
  339.  
  340. ΓòÉΓòÉΓòÉ 3.6. Labels ΓòÉΓòÉΓòÉ
  341.  
  342. A label is any word that is followed by a colon (with no space between the word 
  343. and the colon) and is not in quotation marks.  For example: 
  344.  
  345. MYNAME:
  346.  
  347. A label marks the start of a subroutine.  The following example shows one use 
  348. of a label (called error) within a procedure: 
  349.  
  350.   .
  351.   .
  352.   .
  353. IF problem  = 'yes' then SIGNAL error
  354.   .
  355.   .
  356.   .
  357. error:
  358.    SAY 'Problem in your data'
  359.    EXIT
  360.  
  361.  
  362. ΓòÉΓòÉΓòÉ 4. Working with Variables and Arithmetic ΓòÉΓòÉΓòÉ
  363.  
  364. In this section, you will see how to use variables and arithmetic and how to 
  365. add comments throughout a procedure to describe how it works. Some of the 
  366. topics in this section include the following: 
  367.  
  368. Variable                      A piece of data given a unique name 
  369.  
  370. Value                         Contents of a variable 
  371.  
  372. Operators                     Symbols used for arithmetic functions 
  373.  
  374. Addition                      + operator 
  375.  
  376. Subtraction                   - operator 
  377.  
  378. Multiplication                * operator 
  379.  
  380. Division                      /, //, % operators 
  381.  
  382.  
  383. ΓòÉΓòÉΓòÉ 4.1. Variables ΓòÉΓòÉΓòÉ
  384.  
  385. A variable is a piece of data with a varying value. Within a procedure, each 
  386. variable is known by a unique name and is always referred to by that name. 
  387.  
  388. When you choose a name for a variable, the first character must be one of: 
  389.  
  390. A B C...Z ! ? _
  391.  
  392. Lowercase letters are also allowed as a first letter.  The interpreter changes 
  393. them to uppercase. 
  394.  
  395. The rest of the characters can be any of the preceding characters and also 0 
  396. through 9. 
  397.  
  398.  
  399. ΓòÉΓòÉΓòÉ 4.2. Value ΓòÉΓòÉΓòÉ
  400.  
  401. The value of a variable can change, but the name cannot.  When you name a 
  402. variable (give it a value), it is an assignment.  For example, any statement of 
  403. the form, 
  404.  
  405. symbol = expression
  406.  
  407. is an assignment statement.  You are telling the interpreter to compute what 
  408. the expression is and put the result into a variable called a symbol.  It is 
  409. the same as saying, "Let symbol be made equal to the result of expression" or 
  410. every time symbol appears in the text of a SAY string unprotected by single or 
  411. double quotation marks, display expression in its place.  The relationship 
  412. between a variable and a value is like that between a post-office box and its 
  413. contents; The box number does not change, but the contents of the box may be 
  414. changed at any time.  Another example of an assignment is: 
  415.  
  416. num1 = 10
  417.  
  418. The num1 assignment has the same meaning as the word symbol in the previous 
  419. example, and the value 10 has the same meaning as the word expression. 
  420.  
  421. One way to give the variable num1 a new value is by adding to the old value in 
  422. the assignment: 
  423.  
  424. num1 = num1 + 3
  425.  
  426. The value of num1 has now been changed from 10 to 13. 
  427.  
  428. A special concept in REXX is that any variable that is not assigned a value 
  429. assumes the uppercase version of the variable as its initial value.  For 
  430. example, if you write in a procedure, 
  431.  
  432. list = 2 20 40
  433. SAY list
  434.  
  435. you see this on your screen: 
  436.  
  437. 2 20 40
  438.  
  439. As you can see, list receives the values it is assigned.  But if you do not 
  440. assign any value to list and only write, 
  441.  
  442. SAY list
  443.  
  444. you see this on your screen: 
  445.  
  446. LIST
  447.  
  448. Here is a simple procedure called VARIABLE.CMD that assigns values to 
  449. variables: 
  450.  
  451. /* Assigning a value to a variable */
  452. a = 'abc'
  453. SAY a
  454. b = 'def'
  455. SAY a b
  456. EXIT
  457.  
  458. When you run the VARIABLE procedure, it looks like this on your screen: 
  459.  
  460. [C:\]VARIABLE
  461. abc
  462. abc def
  463.  
  464. [C:\]
  465.  
  466. Assigning values is easy, but you have to make sure a variable is not used 
  467. unintentionally, as in this example named MEETING.CMD: 
  468.  
  469. /* Unintentional interpretation of a variable */
  470. the='no'
  471. SAY Here is the person I want to meet
  472. EXIT
  473.  
  474. When the procedure is run, it looks like this: 
  475.  
  476. [C:\]MEETING
  477. HERE IS no PERSON I WANT TO MEET
  478.  
  479. [C:\]
  480.  
  481. To avoid unintentionally substituting a variable for the word, put the sentence 
  482. in quotation marks as shown in this example of MEETING.CMD, which assigns a 
  483. variable correctly: 
  484.  
  485. /* Correct interpretation of a variable the*/
  486. the= 'no'
  487. SAY "Here is the person I want to meet"
  488. EXIT
  489.  
  490.  
  491. ΓòÉΓòÉΓòÉ 4.3. Working with Arithmetic ΓòÉΓòÉΓòÉ
  492.  
  493. Your REXX procedures may need to include arithmetic operations of addition, 
  494. subtraction, multiplication, and division.  For example, you may want to assign 
  495. a numeric value to two variables and then add the variables. 
  496.  
  497. Arithmetic operations are performed the usual way.  You can use whole numbers 
  498. and decimal fractions.  A whole number is an integer, or any number that is a 
  499. natural number, either positive, negative, or zero, that does not contain a 
  500. decimal part (for example, 1, 25, or 50).  A decimal fraction contains a 
  501. decimal point (for example, 1.45 or 0.6). 
  502.  
  503. Before you see how these four operations are handled in a procedure, here is an 
  504. explanation of what the operations look like and the symbols used.  These are 
  505. just a few of the arithmetic operations used in REXX. 
  506.  
  507. Note:   The examples contain a blank space between numbers and operators so 
  508.         that you can see the equations better, but the blank is optional. 
  509.  
  510. Operators - The symbols used for arithmetic (+ , -, *, /) are called operators 
  511. because they operate on the adjacent terms.  In the following example, the 
  512. operators act on the numbers (terms) 4 and 2: 
  513.  
  514. SAY 4 + 2             /* says "6" */
  515. SAY 4 * 2             /* says "8" */
  516. SAY 4 / 2             /* says "2" */
  517.  
  518. Addition - The operator for addition is the plus sign (+).  An instruction to 
  519. add two numbers is: 
  520.  
  521. SAY 4 + 2
  522.  
  523. The answer you see on your screen is 6. 
  524.  
  525. Subtraction - The operator for subtraction is the minus sign (-).  An 
  526. instruction to subtract two numbers is: 
  527.  
  528. SAY 8 - 3
  529.  
  530. The answer on your screen is 5. 
  531.  
  532. Multiplication - The operator for multiplication is the asterisk (*).  An 
  533. instruction to multiply two numbers is: 
  534.  
  535. SAY 2 * 2
  536.  
  537. The answer on your screen is 4. 
  538.  
  539. Division - For division, there are several operators you can use, depending on 
  540. whether or not you want the answer expressed as a whole number.  For example, 
  541. for a simple division, the symbol is one slash (/). An instruction to divide 
  542. is: 
  543.  
  544. SAY 7 / 2
  545.  
  546. The answer on your screen is 3.5. 
  547.  
  548. To divide and return just a remainder, the operator is two slashes (//).  To 
  549. divide, and return only the whole number portion of an answer and no remainder, 
  550. the operator is the percent sign (%). 
  551.  
  552. For examples showing you how to perform four arithmetic operations on 
  553. variables, select the Examples pushbutton. 
  554.  
  555. Evaluating Expressions - Expressions are normally evaluated from left to right. 
  556. An equation helps to illustrate this point.  Until now, you have seen equations 
  557. with only one operator and two terms, such as 4 + 2.  Suppose you had this 
  558. equation: 
  559.  
  560. 9 - 5 + 4 =
  561.  
  562. The 9 - 5 would be computed first.  The answer, 4, would be added to 4 for a 
  563. final value: 8. 
  564.  
  565. Some operations are given priority over others.  In general, the rules of 
  566. algebra apply to equations.  In this equation, the division is handled before 
  567. the addition: 
  568.  
  569. 10 + 8 / 2 =
  570.  
  571. The value is 14. 
  572.  
  573. If you use parentheses in an equation, the interpreter evaluates what is in the 
  574. parentheses first.  For example: 
  575.  
  576. (10 + 8) / 2 =
  577.  
  578. The value is 9. 
  579.  
  580.  
  581. ΓòÉΓòÉΓòÉ 4.4. Writing a REXX Arithmetic Procedure ΓòÉΓòÉΓòÉ
  582.  
  583. The following is an exercise that will serve as a review of some of the rules 
  584. used in the previous examples.  You are to write a procedure that adds two 
  585. numbers.  Name the procedure ADD.CMD. 
  586.  
  587. Here is a list of what you need to do in this procedure: 
  588.  
  589.  1. Identify and describe the REXX procedure. 
  590.  2. Tell the user to type numbers. 
  591.  3. Read the numbers typed and put them into system memory. 
  592.  4. Add two numbers and display the answer on the screen. 
  593.  5. Tell the interpreter to leave the procedure. 
  594.  
  595. There are many ways to write procedures to accomplish the same task.  To make 
  596. it easier in this procedure, the user is asked for each number separately, then 
  597. the numbers are added.  The following is the thought process you might use to 
  598. write the procedure for ADD.CMD. 
  599.  
  600.  1. First, what identifies a REXX procedure?  If you thought of a comment, you 
  601.     were right. 
  602.  2. Next, you need to tell the user to enter a number.  The SAY instruction 
  603.     prints a message on your screen. 
  604.  3. If the number is entered, it needs to be put into computer memory.  The 
  605.     PULL instruction collects a response and puts it in memory. 
  606.  4. An instruction requesting a second number can look just like the first 
  607.     instruction; the second number also needs to be put in memory. 
  608.  5. The next instruction is similar to one in the MATH procedure.  In one 
  609.     statement, it can tell the interpreter to add the two values in memory and 
  610.     display the sum on your screen.  This can be one instruction.  The 
  611.     instruction contains a string and the addition operation. 
  612.  6. Finally, the EXIT instruction is used to end the procedure. 
  613.  7. If you want to test this program, type the procedure listed here and file 
  614.     it. 
  615.  
  616.         /* This procedure adds two numbers */
  617.         SAY "Enter the first number."
  618.         PULL num1
  619.         SAY "Enter the second number."
  620.         PULL num2
  621.         SAY "The sum of the two numbers is" num1 + num2
  622.         EXIT
  623.  
  624. To test ADD.CMD, type ADD at the OS/2 command prompt and try some numbers. Here 
  625. is what the procedure should look like when it is run, and your numbers are 3 
  626. and 12. 
  627.  
  628. [C:\]ADD
  629. Enter the first number.
  630.  
  631. 3
  632.  
  633. Enter the second number.
  634.  
  635. 12
  636.  
  637. The sum of the two numbers is 15
  638.  
  639. [C:\]
  640.  
  641.  
  642. ΓòÉΓòÉΓòÉ 5. REXX Features ΓòÉΓòÉΓòÉ
  643.  
  644. Some features of REXX that you can use to write more intricate procedures will 
  645. be discussed in this section.  You will see how to have a procedure make 
  646. decisions by testing a value with the IF instruction.  You will also see how to 
  647. compare values and determine if an expression is true or false. A brief 
  648. description of the terms covered in this section follows below: 
  649.  
  650. IF                            Used with THEN.  Checks if the expression is 
  651.                               true.  Makes a decision about a single 
  652.                               instruction. 
  653.  
  654. THEN                          Identifies the instruction to be run if the 
  655.                               expression is true. 
  656.  
  657. ELSE                          Identifies the instruction to be run if the 
  658.                               expression is false. 
  659.  
  660. SELECT                        Tells the interpreter to select one of a number 
  661.                               of instructions. 
  662.  
  663. WHEN                          Used with SELECT.  Identifies an expression to be 
  664.                               tested. 
  665.  
  666. OTHERWISE                     Used with SELECT.  Indicates the instruction to 
  667.                               be run if expressions tested are false. 
  668.  
  669. DO-END                        Indicates that a group of instructions should be 
  670.                               run. 
  671.  
  672. NOP                           Indicates that nothing is to happen for one 
  673.                               expression. 
  674.  
  675. Comparisons  > <  =           Indicates greater than, less than, equal to. 
  676.  
  677. NOT Operator  ╨║ or \          Changes the value of a term from true to false, 
  678.                               or from false to true. 
  679.  
  680. AND Operator  &               Gives the value of true if both terms are true. 
  681.  
  682. OR Operator  |                Gives the value of true unless both terms are 
  683.                               false. 
  684.  
  685.  
  686. ΓòÉΓòÉΓòÉ 5.1. Making Decisions(IF  THEN) ΓòÉΓòÉΓòÉ
  687.  
  688. In the procedures discussed in earlier sections, instructions were run 
  689. sequentially.  In this section, you will see how you can control the order in 
  690. which instructions are run.  Depending upon the user's interaction with your 
  691. procedure, you may choose not to run some of your lines of code. 
  692.  
  693. Two instructions that let you make decisions in your procedures are the IF and 
  694. SELECT instructions.  The IF instruction is similar to the OS/2 IF command-it 
  695. lets you control whether the next instruction is run or skipped.  The SELECT 
  696. instruction lets you choose one instruction to run from a group of 
  697. instructions. 
  698.  
  699. The IF instruction is used with a THEN instruction to make a decision. The 
  700. interpreter runs the instruction if the expression is true; for example: 
  701.  
  702. IF answer = "YES"
  703.  THEN
  704.  SAY "OK!"
  705. In the previous example, the SAY instruction is run only if answer has the 
  706. value of YES. 
  707.  
  708. Grouping Instructions Using DO and END 
  709.  
  710. To tell the interpreter to run a list of instructions after the THEN 
  711. instruction, use: 
  712.  
  713. DO
  714.    Instruction1
  715.    Instruction2
  716.    Instruction3
  717. END
  718.  
  719. The DO instruction and its END instruction tell the interpreter to treat any 
  720. instructions between them as a single instruction. 
  721.  
  722.  
  723. ΓòÉΓòÉΓòÉ 5.2. The ELSE Instruction ΓòÉΓòÉΓòÉ
  724.  
  725. ELSE identifies the instruction to be run if the expression is false.  To tell 
  726. the interpreter to select from one of two possible instructions, use: 
  727.  
  728. IF expression
  729.  THEN instruction1
  730. ELSE instruction2
  731.  
  732. You could include the IF-THEN-ELSE format in a procedure like this: 
  733.  
  734. IF answer = 'YES'
  735.  THEN SAY 'OK!'
  736. ELSE SAY 'why not?'
  737. Try the next example, GOING.CMD, to see how choosing between two instructions 
  738. works. 
  739.  
  740. /* Using IF-THEN-ELSE */
  741. SAY "Are you going to the meeting?"
  742. PULL answer
  743. IF answer = "YES"
  744.  THEN
  745.  SAY "I'll look for you."
  746. ELSE
  747.  SAY "I'll take notes for you."
  748. EXIT
  749.  
  750. When this procedure is run, this is what you will see on your screen: 
  751.  
  752. [C:\]GOING
  753. Are you going to the meeting?
  754.  
  755. yes
  756.  
  757. I'll look for you.
  758.  
  759. [C:\]
  760.  
  761.  
  762. ΓòÉΓòÉΓòÉ 5.3. SELECT, END, WHEN, OTHERWISE, and NOP Instructions ΓòÉΓòÉΓòÉ
  763.  
  764. SELECT tells the interpreter to select one of a number of instructions.  It is 
  765. used only with WHEN, THEN, END, and sometimes, OTHERWISE.  The END instruction 
  766. marks the end of every SELECT group.  The SELECT instruction looks like this: 
  767.  
  768. SELECT
  769.    WHEN expression1
  770.       THEN instruction1
  771.    WHEN expression2
  772.       THEN instruction2
  773.    WHEN expression3
  774.       THEN instruction3
  775. ...
  776. OTHERWISE
  777.    instruction
  778.    instruction
  779.    instruction
  780. END
  781.  
  782. Note:   An IF-THEN instruction cannot be used with a SELECT instruction unless 
  783.         it follows a WHEN or OTHERWISE instruction.  You can read this format 
  784.         as follows: 
  785.  
  786. o If expression1 is true, instruction1 is run.  After this, processing 
  787.   continues with the instruction following the END.  The END instruction 
  788.   signals the end of the SELECT instruction. 
  789. o If expression1 is false, expression2 is tested.  Then, if expression2 is 
  790.   true, instruction2 is run and processing continues with the instruction 
  791.   following the END. 
  792. o If, and only if, all of the specified expressions are false, then processing 
  793.   continues with the instruction following OTHERWISE. 
  794.  
  795. This diagram shows the SELECT instruction: 
  796.  
  797. A DO-END instruction could be included inside a SELECT instruction as follows: 
  798.  
  799. SELECT
  800.    WHEN expression1 THEN
  801.       DO
  802.         instruction1
  803.         instruction2
  804.         instruction3
  805.      END
  806. .
  807. .
  808. .
  809.  
  810. You can use the SELECT instruction when you are looking at one variable that 
  811. can have several different values associated with it.  With each different 
  812. value, you can set a different condition. 
  813.  
  814. For example, suppose you wanted a reminder of weekday activities.  For the 
  815. variable day, you can have a value of Monday through Friday.  Depending on the 
  816. day of the week (the value of the variable), you can list a different activity 
  817. (instruction).  You could use a procedure such as the following, SELECT.CMD, 
  818. which chooses from several instructions. 
  819.  
  820. Note:   A THEN or ELSE instruction must be followed by an instruction. 
  821.  
  822. /* Selecting weekday activities */
  823. SAY 'What day is it today?'
  824. Pull day
  825. SELECT
  826.    WHEN day = 'MONDAY'
  827.       THEN
  828.       SAY 'Model A board meeting'
  829.    WHEN day = 'TUESDAY'
  830.       THEN
  831.       SAY "My Team Meeting"
  832.    WHEN day = 'WEDNESDAY'
  833.       THEN NOP                 /* Nothing happens here */
  834.    WHEN day = 'THURSDAY'
  835.       THEN
  836.       SAY "My Seminar"
  837.    WHEN day = 'FRIDAY'
  838.       THEN
  839.       SAY "My Book Review"
  840. OTHERWISE
  841.    SAY  "It is the weekend, anything can happen!"
  842. END
  843. EXIT
  844.  
  845. NOP Instruction: If you want nothing to happen for one expression, use the NOP 
  846. (No Operation) instruction, as shown in the previous example for Wednesday. 
  847.  
  848.  
  849. ΓòÉΓòÉΓòÉ 5.4. True and False Operators ΓòÉΓòÉΓòÉ
  850.  
  851. Determining if an expression is true or false is useful in your procedures.  If 
  852. an expression is true, the computed result is 1.  If an expression is false, 
  853. the computed result is 0.  The following shows some ways to check for true or 
  854. false operators. 
  855.  
  856. Comparisons - Some operators you can use for comparisons are: 
  857.  
  858. >             Greater than 
  859.  
  860. <             Less than 
  861.  
  862. =             Equal to 
  863.  
  864. Comparisons can be made with numbers or can be character-to-character.  Some 
  865. numeric comparisons are: 
  866.  
  867. The value of 5 > 3 is 1       This result is true. 
  868.  
  869. The value of 2.0 = 002 is 1   This result is true. 
  870.  
  871. The value of 332 < 299 is 0   This result is false. 
  872.  
  873. If the terms being compared are not numbers, the interpreter compares 
  874. characters.  For example, the two words (strings) airmail and airplane when 
  875. compared character for character have the first three letters the same.  Since 
  876. m < p, airmail < airplane. 
  877.  
  878. Equal - An equal sign (=) can have two meanings in REXX, depending on its 
  879. position.  For example, 
  880.  
  881. amount = 5              /* This is an assignment */
  882.  
  883. gives the variable amount, the value of 5. If an equal sign is in a statement 
  884. other than as an assignment, it means the statement is a comparison.  For 
  885. example, 
  886.  
  887. SAY amount = 5           /* This is a comparison  */
  888.  
  889. compares the value of amount with 5.  If they are the same, a 1 is displayed, 
  890. otherwise, a 0 is displayed. 
  891.  
  892. For more examples of using comparisons, select the Examples pushbutton. 
  893.  
  894.  
  895. ΓòÉΓòÉΓòÉ 5.5. The Logical Operators, NOT, AND, OR ΓòÉΓòÉΓòÉ
  896.  
  897. Logical operators can return only the values of 1 or 0.  The NOT operator (╨║ or 
  898. \) in front of a term reverses its value either from true to false or from 
  899. false to true. 
  900.  
  901. SAY  \ 0         /* gives '1'         */
  902. SAY  \ 1         /* gives '0'         */
  903. SAY  \ (4 = 4)   /* gives '0'         */
  904. SAY  \ 2         /* gives  a  syntax error      */
  905.  
  906. The AND operator (&) between two terms gives a value of true only if both terms 
  907. are true. 
  908.  
  909.  
  910. SAY ( 3 = 3 ) & ( 5 = 5 )   /* gives '1'                     */
  911. SAY ( 3 = 4 ) & ( 5 = 5 )   /* gives '0'                     */
  912. SAY ( 3 = 3 ) & ( 4 = 5 )   /* gives '0'                     */
  913. SAY ( 3 = 4 ) & ( 4 = 5 )   /* gives '0'                     */
  914.  
  915. The OR operator ( | ) between two terms gives a value of true unless both terms 
  916. are false. 
  917.  
  918. Note:   Depending upon your Personal System keyboard and the code page you are 
  919.         using, you may not have the solid vertical bar to select. For this 
  920.         reason, REXX also recognizes the use of the split vertical bar as a 
  921.         logical OR symbol.  Some keyboards may have both characters.  If so, 
  922.         they are not interchangeable; only the character that is equal to the 
  923.         ASCII value of 124 works as the logical OR.  This type of mismatch can 
  924.         also cause the character on your screen to be different from the 
  925.         character on your keyboard. 
  926.  
  927. SAY ( 3 = 3 ) | ( 5 = 5 )   /* gives '1'                     */
  928. SAY ( 3 = 4 ) | ( 5 = 5 )   /* gives '1'                     */
  929. SAY ( 3 = 3 ) | ( 4 = 5 )   /* gives '1'                     */
  930. SAY ( 3 = 4 ) | ( 4 = 5 )   /* gives '0'                     */
  931.  
  932. For more examples of using the logical operators, select the Examples 
  933. pushbutton. 
  934.  
  935.  
  936. ΓòÉΓòÉΓòÉ 6. Automating Repetitive Tasks - Using Loops ΓòÉΓòÉΓòÉ
  937.  
  938. If you want to repeat several instructions in a procedure, you can use a loop. 
  939. Loops often are used in programming because they condense many lines of 
  940. instructions into a group that can be run more than once.  Loops make your 
  941. procedures more concise, and with a loop, you can continue asking a user for 
  942. input until the correct answer is given. 
  943.  
  944. With loops, you can keep adding or subtracting numbers until you want to stop. 
  945. You can define how many times you want a procedure to handle an operation.  You 
  946. will see how to use simple loops to repeat instructions in a procedure. 
  947.  
  948. The two types of loops you may find useful are repetitive loops and conditional 
  949. loops.  Loops begin with a DO instruction and end with the END instruction. 
  950. The following is a list of topics in this section: 
  951.  
  952. DO num loop                   Repeats the loop a fixed number of times. 
  953.  
  954. DO i=1 to 10 loop             Numbers each pass through the loop.  Sets a 
  955.                               starting and ending value for the variable. 
  956.  
  957. DO WHILE                      Tests for true or false at the top of the loop. 
  958.                               Repeats the loop if true.  If false, continues 
  959.                               processing after END. 
  960.  
  961. Do UNTIL                      Tests for true or false at the bottom of the 
  962.                               loop. Repeats the loop if false.  If true, 
  963.                               continues processing after END. 
  964.  
  965. LEAVE                         Causes the interpreter to exit a loop. 
  966.  
  967. DO FOREVER                    Repeats instructions until the user says to quit. 
  968.  
  969. Getting out of loops          Requires that you press the Ctrl+Break keys. 
  970.  
  971. Parsing words                 Assigns a different variable to each word in a 
  972.                               group. 
  973.  
  974.  
  975. ΓòÉΓòÉΓòÉ 6.1. Repetitive Loops ΓòÉΓòÉΓòÉ
  976.  
  977. Simple repetitive loops can be run a number of times.  You can specify the 
  978. number of repetitions for the loop, or you can use a variable that has a 
  979. changing value. 
  980.  
  981. The following shows how to repeat a loop a fixed number of times. 
  982.  
  983. DO num
  984.    instruction1
  985.    instruction2
  986.    instruction3
  987.    ...
  988. END
  989.  
  990. The num is a whole number, which is the number of times the loop is to be run. 
  991.  
  992. Here is LOOP.CMD, an example of a simple repetitive loop. 
  993.  
  994. /* A simple loop */
  995. DO 5
  996.    SAY 'Thank-you'
  997. END
  998. EXIT
  999.  
  1000. When you run the LOOP.CMD, you see this on your screen: 
  1001.  
  1002. [C:\]loop
  1003. Thank-you
  1004. Thank-you
  1005. Thank-you
  1006. Thank-you
  1007. Thank-you
  1008.  
  1009. [C:\]
  1010.  
  1011. Another type of DO instruction is: 
  1012.  
  1013. DO XYZ = 1 to 10
  1014.  
  1015. This type of DO instruction numbers each pass through the loop so you can use 
  1016. it as a variable.  The value of XYZ changes (by 1) each time you pass through 
  1017. the loop.  The 1 (or some number) gives the value you want the variable to have 
  1018. the first time through the loop.  The 10 (or some number) gives the value you 
  1019. want the variable to have the last time through the loop. 
  1020.  
  1021. NEWLOOP.CMD is an example of another loop: 
  1022.  
  1023. /* Another loop */
  1024. sum = 0
  1025. DO XYZ = 1 to 7
  1026.    SAY 'Enter value' XYZ
  1027.    PULL value
  1028.    sum = sum + value
  1029. END
  1030. SAY 'The total is' sum
  1031. EXIT
  1032.  
  1033. Here are the results of the NEWLOOP.CMD procedure: 
  1034.  
  1035. [C:\]newloop
  1036. Enter value 1
  1037.  
  1038. 2
  1039.  
  1040. Enter value 2
  1041.  
  1042. 4
  1043.  
  1044. Enter value 3
  1045.  
  1046. 6
  1047.  
  1048. Enter value 4
  1049.  
  1050. 8
  1051.  
  1052. Enter value 5
  1053.  
  1054. 10
  1055.  
  1056. Enter value 6
  1057.  
  1058. 12
  1059.  
  1060. Enter value 7
  1061.  
  1062. 14
  1063.  
  1064. The total is 56
  1065.  
  1066. [C:\]
  1067.  
  1068. When a loop ends, the procedure continues with the instruction following the 
  1069. end of the loop, which is identified by END. 
  1070.  
  1071.  
  1072. ΓòÉΓòÉΓòÉ 6.2. Conditional Loops ΓòÉΓòÉΓòÉ
  1073.  
  1074. Conditional loops are run when a true or false condition is met.  We will now 
  1075. look at some instructions used for conditional loops: 
  1076.  
  1077. DO WHILE and DO UNTIL: The DO WHILE and DO UNTIL instructions are run while or 
  1078. until some condition is met.  A DO WHILE loop is: 
  1079.  
  1080. DO WHILE expression
  1081.    instruction1
  1082.    instruction2
  1083.    instruction3
  1084. END
  1085.  
  1086. The DO WHILE instruction tests for a true or false condition at the top of the 
  1087. loop; that is, before processing the instructions that follow. If the 
  1088. expression is true, the instructions are performed.  If the expression is 
  1089. false, the loop ends and moves to the instruction following END. 
  1090.  
  1091. The following diagram shows the DO WHILE instruction: 
  1092.  
  1093. To see a procedure using a DO WHILE loop, select the Examples pushbutton. 
  1094.  
  1095. DO UNTIL: A DO UNTIL instruction differs from the DO WHILE because it processes 
  1096. the body of instructions first, then evaluates the expression.  If the 
  1097. expression is false, the instructions are repeated (a loop).  If the expression 
  1098. is true, the procedure ends or moves to the next step outside the loop. 
  1099.  
  1100. The DO UNTIL instruction tests at the bottom of the loop; therefore, the 
  1101. instructions within the DO loop are run at least once. 
  1102.  
  1103. An example of a DO UNTIL loop follows: 
  1104.  
  1105. DO UNTIL expression
  1106.    instruction1
  1107.    instruction2
  1108.    instruction3
  1109.  
  1110. END
  1111.  
  1112. The following diagram shows the DO UNTIL instruction: 
  1113.  
  1114. To see a procedure that uses a DO UNTIL loop, select the Examples pushbutton. 
  1115.  
  1116. LEAVE: You may want to end a loop before the ending conditions are met. You can 
  1117. accomplish this with the LEAVE instruction.  This instruction ends the loop and 
  1118. continues processing with the instruction following END. The following 
  1119. procedure, LEAVE.CMD, causes the interpreter to end the loop. 
  1120.  
  1121. /* Using the LEAVE instruction in a loop */
  1122. SAY 'enter the amount of money available'
  1123. PULL salary
  1124. spent = 0        /* Sets spent to a value of 0 */
  1125. DO UNTIL spent > salary
  1126.    SAY 'Type in cost of item or END to quit'
  1127.    PULL cost
  1128.       IF cost = 'END'
  1129.       THEN
  1130.       LEAVE
  1131.    spent = spent + cost
  1132. END
  1133. SAY 'Empty pockets.'
  1134. EXIT
  1135.  
  1136. DO FOREVER: There may be situations when you do not know how many times to 
  1137. repeat a loop.  For example, you may want the user to type specific numeric 
  1138. data (numbers to add together), and have the loop perform the calculation until 
  1139. the user says to stop.  For such a procedure, you can use the DO FOREVER 
  1140. instruction with the LEAVE instruction. 
  1141.  
  1142. The following shows the simple use of a DO FOREVER ending when the user stops. 
  1143.  
  1144. /* Using a DO FOREVER loop to add numbers */
  1145. sum = 0
  1146. DO FOREVER
  1147.    SAY 'Enter number or END to quit'
  1148.    PULL value
  1149.    IF value = 'END'
  1150.       THEN
  1151.       LEAVE  /* procedure quits when the user enters "end" */
  1152.    sum = sum + value
  1153. END
  1154. SAY 'The sum is ' sum
  1155. EXIT
  1156.  
  1157.  
  1158. ΓòÉΓòÉΓòÉ 6.3. Getting Out of Loops ΓòÉΓòÉΓòÉ
  1159.  
  1160. To stop most REXX procedures, press the Ctrl+Break keys. REXX recognizes 
  1161. Ctrl+Break after finishing the current instruction. Occasionaly, if you try a 
  1162. procedure such as the one that follows, you need to press Ctrl+Break and then 
  1163. Enter to get out of the loop. 
  1164.  
  1165. /* Guess the secret password !  */
  1166. DO UNTIL answer = "Sesame"
  1167.    SAY "Please enter the password . . ."
  1168.    PULL answer
  1169. END
  1170. EXIT
  1171.  
  1172. If you are still unable to end the procedure, press the Alt+Esc keys to end the 
  1173. OS/2 session and stop the procedure. 
  1174.  
  1175.  
  1176. ΓòÉΓòÉΓòÉ 6.4. Parsing Words ΓòÉΓòÉΓòÉ
  1177.  
  1178. The PULL instruction collects a response and puts it into system memory as a 
  1179. variable.  PULL also can be used to put each word from a group of words into a 
  1180. different variable.  In REXX, this is called parsing.  The variable names used 
  1181. in the next example are:  first, second, third, and rest. 
  1182.  
  1183. SAY 'Please enter three or more words'
  1184. PULL first second third rest
  1185.  
  1186. Suppose you enter this as your response: 
  1187.  
  1188. garbage in garbage out
  1189.  
  1190. When you press the Enter key, the procedure continues.  However, the variables 
  1191. are assigned as follows: 
  1192.  
  1193. The variable first is given the value GARBAGE. 
  1194. The variable second is given the value IN. 
  1195. The variable third is given the value GARBAGE. 
  1196. The variable rest is given the value OUT. 
  1197.  
  1198. In general, each variable receives a word, without blanks, and the last 
  1199. variable receives the rest of the input, if any, with blanks. If there are more 
  1200. variables than words, the extra variables are assigned the null, or empty, 
  1201. value. 
  1202.  
  1203.  
  1204. ΓòÉΓòÉΓòÉ 7. Advanced REXX Functions ΓòÉΓòÉΓòÉ
  1205.  
  1206. As you become more skilled at programming, you may want to create procedures 
  1207. that do more and run more efficiently.  Sometimes this means adding a special 
  1208. function to a procedure or calling a subroutine. 
  1209.  
  1210. In this section, we shall see how these functions can help to build a better 
  1211. foundation in REXX. 
  1212.  
  1213. Functions                         Perform a computation and return a result. 
  1214.  
  1215. DATATYPE( )                       An internal function that verifies that the 
  1216.                                   data is a specific type. 
  1217.  
  1218. SUBSTR( )                         An internal function that selects part of a 
  1219.                                   string. 
  1220.  
  1221. CALL                              Causes the procedure to look for a subroutine 
  1222.                                   label and begin running the instructions 
  1223.                                   following the label. 
  1224.  
  1225. REXX.CMD File Commands            Treat commands as expressions. 
  1226.  
  1227. Error Messages                    Tell you if the command runs correctly. If 
  1228.                                   the procedure runs correctly, no message is 
  1229.                                   displayed. 
  1230.  
  1231.  
  1232. ΓòÉΓòÉΓòÉ 7.1. Functions ΓòÉΓòÉΓòÉ
  1233.  
  1234. In REXX, a function call can be written anywhere in an expression.  The 
  1235. function performs the requested computation and returns a result.  REXX then 
  1236. uses the result in the expression in place of the function call. 
  1237.  
  1238. Think of a function as:  You are trying to find someone's telephone number. 
  1239. You call the telephone operator and ask for the number.  After receiving the 
  1240. number, you call the person.  The steps you have completed in locating and 
  1241. calling the person could be labeled a function. 
  1242.  
  1243. Generally, if the interpreter finds this in an expression, 
  1244.  
  1245. name(expression)
  1246.  
  1247. it assumes that name is the name of a function being called.  There is no space 
  1248. between the end of the name and the left parenthesis.  If you leave out the 
  1249. right parenthesis, it is an error. 
  1250.  
  1251. The expressions inside the parentheses are the arguments. An argument can 
  1252. itself be an expression; the interpreter computes the value of this argument 
  1253. before passing it to the function.  If a function requires more than one 
  1254. argument, use commas to separate each argument. 
  1255.  
  1256. Built-in Functions - Rexx has more than 50 built-in functions.  A dictionary of 
  1257. built-in functions is in the Procedures Language 2/REXX Reference. 
  1258.  
  1259. MAX is a built-in function that you can use to obtain the greatest number of a 
  1260. set of numbers: 
  1261.  
  1262. MAX(number, number, ...)
  1263.  
  1264. For example: 
  1265.  
  1266.    MAX(2,4,8,6) = 8
  1267.    MAX(2,4+5,6) = 9
  1268.  
  1269. Note that in the second example, the 4+5 is an expression. A function call, 
  1270. like any other expression, usually is contained in a clause as part of an 
  1271. assignment or instruction. 
  1272.  
  1273.  
  1274. ΓòÉΓòÉΓòÉ 7.2. DATATYPE( ) ΓòÉΓòÉΓòÉ
  1275.  
  1276. When attempting to perform arithmetic on data entered from the keyboard, you 
  1277. can use the DATATYPE( ) function to check that the data is valid. 
  1278.  
  1279. This function has several forms.  The simplest form returns the word, NUM, if 
  1280. the expression inside the parentheses ( ) is accepted by the interpreter as a 
  1281. number that can be used in the arithmetic operation. Otherwise, it returns the 
  1282. word, CHAR. For example: 
  1283.  
  1284. The value of DATATYPE(56) is NUM
  1285. The value of DATATYPE(6.2) is NUM
  1286. The value of DATATYPE('$5.50') is CHAR
  1287. In the following procedure, DATATYPE.CMD, the internal REXX function, DATATYPE( 
  1288. ), is used and the user is asked to keep typing a valid number until a correct 
  1289. one is typed. 
  1290.  
  1291. /* Using the DATATYPE( ) Function */
  1292. DO UNTIL datatype(howmuch) = 'NUM'
  1293.  SAY 'Enter a number'
  1294.  PULL howmuch
  1295.   IF datatype (howmuch) = 'CHAR'
  1296.    THEN
  1297.    SAY 'That was not a number.  Try again!'
  1298. END
  1299. SAY 'The number you entered was' howmuch
  1300. EXIT
  1301.  
  1302. If you want the user to type only whole numbers, you could use another form of 
  1303. the DATATYPE( ) function: 
  1304.  
  1305. DATATYPE (number, whole)
  1306.  
  1307. The arguments for this form are: 
  1308.  
  1309. o number -  refers to the data to be tested. 
  1310. o whole -  refers to the type of data to be tested.  In this example, the data 
  1311.   must be a whole number. 
  1312.  
  1313. This form returns a 1 if number is a whole number, or a 0 otherwise. 
  1314.  
  1315.  
  1316. ΓòÉΓòÉΓòÉ 7.3. SUBSTR( ) ΓòÉΓòÉΓòÉ
  1317.  
  1318. The value of any REXX variable can be a string of characters.  To select a part 
  1319. of a string, you can use the SUBSTR( ) function.  SUBSTR is an abbreviation for 
  1320. substring. The first three arguments are: 
  1321.  
  1322. o The string from which a part is taken. 
  1323. o The position of the first character that is to be contained in the result 
  1324.   (characters are numbered 1,2,3...in the string). 
  1325. o The length of the result. 
  1326. For example: 
  1327.  
  1328. S = 'reveal'
  1329. SAY substr(S,2,3) /* Says 'eve'. Beginning with the second  */
  1330.                   /*  character, takes three characters.    */
  1331. SAY substr(S,3,4) /* Says 'veal'. Beginning with the third  */
  1332.                   /*  character, takes four characters.     */
  1333.  
  1334.  
  1335. ΓòÉΓòÉΓòÉ 7.4. CALL ΓòÉΓòÉΓòÉ
  1336.  
  1337. The CALL instruction causes the interpreter to search your procedure until a 
  1338. label is found that marks the start of the subroutine. Remember, a label (word) 
  1339. is a symbol followed by a colon (:).  Processing continues from there until the 
  1340. interpreter finds a RETURN or an EXIT instruction. 
  1341.  
  1342. A subroutine can be called from more than one place in a procedure. When the 
  1343. subroutine is finished, the interpreter always returns to the instruction 
  1344. following the CALL instruction from which it came. 
  1345.  
  1346. Often each CALL instruction supplies data (called arguments or expressions) 
  1347. that the subroutine is to use.  In the subroutine, you can find out what data 
  1348. has been supplied by using the ARG instruction. 
  1349.  
  1350. The CALL instruction is written in the following form: 
  1351.  
  1352. CALL name  Argument1, Argument2 ...
  1353.  
  1354. For the name, the interpreter looks for the corresponding label (name) in your 
  1355. procedure.  If no label is found, the interpreter looks for a built-in function 
  1356. or a .CMD file with that name. 
  1357.  
  1358. The arguments are expressions.  You can have up to 20 arguments in a CALL 
  1359. instruction.  An example of a procedure that calls a subroutine follows.  Note 
  1360. that the EXIT instruction causes a return to the operating system. The EXIT 
  1361. instruction stops the main procedure from continuing into the subroutine. 
  1362.  
  1363. In the following example, REXX.CMD, the procedure calls a subroutine from a 
  1364. main procedure. 
  1365.  
  1366. /* Calling a subroutine from a procedure */
  1367. DO 3
  1368.   CALL triple 'R'
  1369.   CALL triple 'E'
  1370.   CALL triple 'X'
  1371.   CALL triple 'X'
  1372.   SAY
  1373. END
  1374. SAY 'R...!'
  1375. SAY 'E...!'
  1376. SAY 'X...!'
  1377. SAY 'X...!'
  1378. SAY ' '
  1379. SAY 'REXX!'
  1380. EXIT          /* This ends the main procedure. */
  1381. /*                                                     */
  1382. /* Subroutine starts here to repeat REXX three times.  */
  1383. /* The first argument is displayed on screen three     */
  1384. /* times, with punctuation.                            */
  1385. /*                                                     */
  1386. TRIPLE:
  1387. SAY ARG(1)"    "ARG(1)"   "ARG(1)"!"
  1388. RETURN           /* This ends the subroutine.          */
  1389.  
  1390. When REXX.CMD is run on your system, the following is displayed: 
  1391.  
  1392. [C:\]REXX
  1393. R   R   R!
  1394. E   E   E!
  1395. X   X   X!
  1396. X   X   X!
  1397.  
  1398. R   R   R!
  1399. E   E   E!
  1400. X   X   X!
  1401. X   X   X!
  1402.  
  1403. R   R   R!
  1404. E   E   E!
  1405. X   X   X!
  1406. X   X   X!
  1407.  
  1408. R...!
  1409. E...!
  1410. X...!
  1411. X...!
  1412.  
  1413. REXX!
  1414.  
  1415. [C:\]
  1416.  
  1417.  
  1418. ΓòÉΓòÉΓòÉ 7.5. REXX.CMD File Commands ΓòÉΓòÉΓòÉ
  1419.  
  1420. In a REXX procedure, anything not recognized as an instruction, assignment, or 
  1421. label is considered a command.  The statement recognized as a command is 
  1422. treated as an expression.  The expression is evaluated first, then the result 
  1423. is passed to the operating system. 
  1424.  
  1425. The following example, COPYLIST.CMD, shows how a command is treated as an 
  1426. expression.  Note how the special character (*) is put in quotation marks. 
  1427. COPYLIST.CMD copies files from drive A to drive B. 
  1428.  
  1429. /* Issuing a command from a procedure.  This example copies  */
  1430. /* all files that have an extension of.LST from              */
  1431. /* drive A to drive B.                                       */
  1432. SAY
  1433. COPY "a:*.lst b:"           /* This statement is treated as  */
  1434.                             /* an expression.                */
  1435.                             /* The result is passed to OS/2. */
  1436. EXIT
  1437.  
  1438. Note:   In the preceding example, the whole OS/2 command except for COPY is in 
  1439.         quotation marks for the following reasons: 
  1440.  
  1441. o If the colon (:) were not in quotation marks, the REXXSAA interpreter would 
  1442.   treat a: and b: as labels. 
  1443. o If the asterisk (*) were not in quotation marks, the REXXSAA interpreter 
  1444.   would attempt to multiply the value of a: by .LST. 
  1445. o It is also acceptable to include the entire OS/2 command in quotation marks 
  1446.   so that "COPY a:*.LST b:" is displayed. 
  1447.  
  1448.  
  1449. ΓòÉΓòÉΓòÉ 7.6. Error Messages ΓòÉΓòÉΓòÉ
  1450.  
  1451. There are two basic reasons errors occur when REXX is processing a procedure. 
  1452.  
  1453. One reason is because of the way the procedure is written; for example, 
  1454. unmatched quotation marks or commas in the wrong place.  Maybe an IF 
  1455. instruction was entered without a matching THEN. When such an error occurs, a 
  1456. REXX error message is issued. 
  1457.  
  1458. A second reason for an error to occur is because of an OS/2 command that the 
  1459. REXX procedure has issued.  For example, a COPY command can fail because the 
  1460. user's disk is full or a file cannot be found.  In this case, a regular OS/2 
  1461. error message is issued.  When you write commands in your procedures, consider 
  1462. what might happen if the command fails to run correctly. 
  1463.  
  1464. When a command is issued from a REXX procedure, the command interpreter gets a 
  1465. return code and stores it in the REXX special variable, RC (return code).  When 
  1466. you write a procedure, you can test for these variables to see what happens 
  1467. when the command is issued. 
  1468.  
  1469. Here is how you discover a failure.  When commands finish running, they always 
  1470. provide a return code.  A return code of 0 nearly always means that all is 
  1471. well.  Any other number usually means that something is wrong. If the command 
  1472. worked normally (the return code was 0), you see the command prompt: 
  1473.  
  1474. [C:\]
  1475.  
  1476. and you return to the screen you ran your program from in Presentation Manager, 
  1477. or in the PMREXX application you see printed under the last line of the 
  1478. procedure, 
  1479.  
  1480. The REXX procedure has ended.
  1481.  
  1482. In the following example, ADD.CMD, there is an error in line 6; the plus sign 
  1483. (+) has been typed incorrectly as an ampersand (&). 
  1484.  
  1485. /* This procedure adds two numbers */
  1486. SAY "Enter the first number."
  1487. PULL num1
  1488. SAY "Enter the second number."
  1489. PULL num2
  1490. SAY "The sum of the two numbers is" num1 & num2
  1491. EXIT
  1492.  
  1493. When the above procedure, ADD.CMD, is run, the following error message is 
  1494. displayed. 
  1495.  
  1496.     6+++ SAY "The sum of the two numbers is" num1 & num2
  1497. REX0034: Error 34 running C:\REXX\ADD.CMD,line 6:logical value not 0 or 1
  1498.  
  1499. To get help on the error message, type: 
  1500.  
  1501. HELP REX0034
  1502.  
  1503. When help is requested, an error message such as the following is displayed: 
  1504.  
  1505. REX0034 ***Logical Value not 0 or 1***
  1506.  
  1507. Explanation: The expression in an IF, WHEN, DO WHILE, or DO UNTIL
  1508.              phrase must result in a '0' or a '1', as must any
  1509.              term operated on by a logical operator.
  1510.  
  1511. Any command that is valid at the command prompt is valid in a REXX procedure. 
  1512. The command interpreter treats the command statement the same way as any other 
  1513. expression, substituting the values of variables, and so on.  (The rules are 
  1514. the same as for commands entered at the command prompt.) 
  1515.  
  1516. Return Codes: When the command interpreter has issued a command and the 
  1517. operating system has finished running it, the command interpreter gets the 
  1518. return code and stores it in the REXX special variable RC (return code).  In 
  1519. your procedure, you should test this variable to see what happens when the 
  1520. command is run. 
  1521.  
  1522. The following example shows a few lines from a procedure where the return code 
  1523. is tested: 
  1524.  
  1525. /* Testing the Return Code in a Procedure. */
  1526. 'COPY a:*.lst b:'
  1527. IF rc = 0   /* RC contains the return code from the COPY command */
  1528. THEN
  1529.  SAY 'All *lst files copied'
  1530. ELSE
  1531.  SAY 'Error occurred copying files'
  1532.  
  1533.  
  1534. ΓòÉΓòÉΓòÉ 8. PMREXX and REXXTRY ΓòÉΓòÉΓòÉ
  1535.  
  1536. PMREXX is a windowed Presentation Manager* application that enables you to 
  1537. browse the output of your REXX procedures.  REXXTRY is a command that lets you 
  1538. interactively run one or more REXX instructions. 
  1539.  
  1540. By using PMREXX, you add the following features to REXX: 
  1541.  
  1542. o A window for the display of the output of a REXX procedure, such as: 
  1543.  
  1544.    - The SAY instruction output 
  1545.    - The STDOUT and STDERR outputs from secondary processes started from a REXX 
  1546.      procedures file 
  1547.    - The REXX TRACE output (not to be confused with OS/2 tracing). 
  1548.  
  1549. o An input window for: 
  1550.  
  1551.    - The PULL instruction in all of its forms 
  1552.    - The STDIN data for secondary processes started from a REXX procedures 
  1553.      file. 
  1554.  
  1555. o A browsing, scrolling, and clipboard capability for REXX output. 
  1556. o A selection of fonts for the output window. 
  1557. o A simple environment for experimenting with REXX instructions through the use 
  1558.   of the REXXTRY.CMD program.  REXXTRY interactively interprets REXX 
  1559.   instructions and can be started by typing REXXTRY or PMREXX REXXTRY at an 
  1560.   OS/2 command prompt 
  1561.  
  1562.  
  1563. ΓòÉΓòÉΓòÉ 8.1. Starting the PMREXX Program ΓòÉΓòÉΓòÉ
  1564.  
  1565. You can start the PMREXX program and a REXX procedure from an OS/2 command 
  1566. prompt.  You do this by typing PMREXX and a target procedure name that 
  1567. generates an output or input function, as follows: 
  1568.  
  1569. PMREXX  filename.CMD arguments
  1570.  
  1571. where the arguments and .CMD extension are optional. 
  1572.  
  1573. Here is a REXX program named SAMPLE.CMD that calls for system environment 
  1574. variables to be displayed when the various arguments are indicated. 
  1575.  
  1576. /**/
  1577. '@ECHO OFF'
  1578. env = 'OS2ENVIRONMENT'
  1579. Parse Arg all
  1580. Do i=1 to words(all)
  1581.    word = translate(word(all,i))
  1582.    Say
  1583.    If value(word,,env)=''
  1584.      Then Say '"'word'" is not in the environment!.'
  1585.      Else Say word'="'value(word,,env)'".'
  1586. End
  1587.  
  1588. To display the current PATH and DPATH statements in the CONFIG.SYS file in a 
  1589. PMREXX window, type the following: 
  1590.  
  1591. PMREXX Sample PATH DPATH
  1592.  
  1593. Note:   You can move or size the PMREXX.EXE window or select menu-bar choices, 
  1594.         the same way that you do with other windows. 
  1595.  
  1596. Once the output of the REXX procedure is displayed in PMREXX, you can select 
  1597. the menu-bar choices to take advantage of the following PMREXX browsing 
  1598. features: 
  1599.  
  1600. Menu-Bar Choice             Description 
  1601.  
  1602. File                        Save, Save As, and Exit the process 
  1603.  
  1604. Edit                        Copy, Paste to the input, Clear the output, and 
  1605.                             Select All lines 
  1606.  
  1607. Options                     Restart the process, Interactive Trace, and Set 
  1608.                             font 
  1609.  
  1610. Actions                     Halt procedure, Trace next clause, Redo the last 
  1611.                             clause, and Set Trace off 
  1612.  
  1613. Help                        Help index, General help, Keys help, and Using 
  1614.                             help. 
  1615.  
  1616.  
  1617. ΓòÉΓòÉΓòÉ 8.2. The PMREXX Trace Function ΓòÉΓòÉΓòÉ
  1618.  
  1619. The trace function in PMREXX turns on interactive tracing for the currently 
  1620. operating REXX procedure.  This is done by adding the /T parameter to the 
  1621. PMREXX command before typing the file name at an OS/2 command prompt. 
  1622.  
  1623. TRACE lets you see just how REXX evaluates expressions while the program is 
  1624. actually running. To start the trace function from the command prompt, type the 
  1625. command as follows: 
  1626.  
  1627. PMREXX /T filename arguments
  1628.  
  1629.  
  1630. ΓòÉΓòÉΓòÉ 8.3. The REXXTRY Program ΓòÉΓòÉΓòÉ
  1631.  
  1632. REXXTRY is a REXX program.  As with other REXX programs, REXXTRY can be run in 
  1633. an OS/2 full-screen or window session, or with PMREXX. 
  1634.  
  1635. You can use REXXTRY to run different REXX instructions and observe the results. 
  1636. REXXTRY is also useful when you want to perform a REXX operation only once, 
  1637. since it is easier than creating, running, and erasing a .CMD file. 
  1638.  
  1639. Here are some examples of how to use the REXXTRY command: 
  1640.  
  1641. REXXTRY say 1+2
  1642.  
  1643. The operation is performed and 3 is displayed. 
  1644.  
  1645. REXXTRY say 2+3; say 3+4
  1646.  
  1647. 5 and 7 are displayed. 
  1648.  
  1649.  
  1650. ΓòÉΓòÉΓòÉ 9. REXX Utility Functions (RexxUtil) ΓòÉΓòÉΓòÉ
  1651.  
  1652. RexxUtil is a Dynamic Link Library (DLL) which provides the OS/2* REXX 
  1653. programmer with many versatile functions.  Primarily, these functions deal with 
  1654. the following: 
  1655.  
  1656. o OS/2 system commands. 
  1657.  
  1658. o User or text screen input/output (I/O). 
  1659.  
  1660. o OS/2 INI file I/O. 
  1661.  
  1662. RexxUtil requires that you are already running under OS/2 2.0 with OS/2 
  1663. Procedures Language 2/REXX installed. 
  1664.  
  1665. To be able to use a RexxUtil function in a REXX program, you must first add the 
  1666. function using the built-in function RxFuncAdd. 
  1667.  
  1668. Example: 
  1669.  
  1670. call RxFuncAdd 'SysCls', 'RexxUtil', 'SysCls'
  1671.  
  1672. The above example would add the SysCls function so that it can be used. 
  1673.  
  1674. The RexxUtil function, SysLoadFuncs, will automatically load all RexxUtil 
  1675. functions.  To do this from within a program, add the following instructions: 
  1676.  
  1677. call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  1678. call SysLoadFuncs
  1679.  
  1680. Once the RexxUtil functions are loaded by SysLoadFuncs they are usable by all 
  1681. OS/2 sessions. 
  1682.  
  1683. The RexxUtil functions are listed when you select the + sign beside this topic 
  1684. in the Contents. 
  1685.  
  1686.  
  1687. ΓòÉΓòÉΓòÉ 9.1. RxMessageBox ΓòÉΓòÉΓòÉ
  1688.  
  1689. Function: RxMessageBox 
  1690.  
  1691. Syntax:   action = RxMessageBox(text, [title], [button], [icon]) 
  1692.  
  1693.    text      The text of the message that appears in the message box. 
  1694.  
  1695.    title     The title of the message box.  The default title is "Error". 
  1696.  
  1697.    The style of buttons used with the message box.  The allowed styles are: 
  1698.  
  1699.       OK                    A single OK button. 
  1700.  
  1701.       OKCANCEL              An OK button and a Cancel button. 
  1702.  
  1703.       CANCEL                A single Cancel button. 
  1704.  
  1705.       ENTER                 A single Enter button. 
  1706.  
  1707.       ENTERCANCEL           An Enter button and a Cancel button. 
  1708.  
  1709.       RETRYCANCEL           A Retry button and a Cancel button. 
  1710.  
  1711.       ABORTRETRYCANCEL      An Abort button, a Retry button and a Cancel 
  1712.                             button. 
  1713.  
  1714.       YESNO                 A Yes button and a No button. 
  1715.  
  1716.       YESNOCANCEL           A Yes button, a No button and a Cancel button. 
  1717.  
  1718.              The default button style is OK. 
  1719.  
  1720.    icon      The style of icon displayed in the message box.  The allowed 
  1721.              styles are: 
  1722.  
  1723.       NONE                No icon is displayed. 
  1724.  
  1725.       HAND                The hand icon is displayed. 
  1726.  
  1727.       QUESTION            A question mark icon is displayed. 
  1728.  
  1729.       EXCLAMATION         An exclamation mark icon is displayed. 
  1730.  
  1731.       ASTERISK            An asterisk icon is displayed. 
  1732.  
  1733.       INFORMATION         The information icon is displayed. 
  1734.  
  1735.       QUERY               The query icon is displayed. 
  1736.  
  1737.       WARNING             The warning icon is displayed. 
  1738.  
  1739.       ERROR               The error icon is displayed. 
  1740.  
  1741.    action    The button that was selected on the message box. Possible values 
  1742.              are: 
  1743.  
  1744.       1         OK key 
  1745.  
  1746.       2         Cancel key 
  1747.  
  1748.       3         Abort key 
  1749.  
  1750.       4         Retry key 
  1751.  
  1752.       5         Ignore key 
  1753.  
  1754.       6         Yes key 
  1755.  
  1756.       7         No key 
  1757.  
  1758.       8         Enter 
  1759.  
  1760. Purpose:  Display a message box from a REXX program running in an OS/2 session 
  1761.           (that is, running in PMREXX or called from a Presentation Manager* 
  1762.           application). 
  1763.  
  1764. Examples:
  1765.  
  1766.                                        /* Give option to quit        */
  1767.   if RxMessageBox("Shall we continue",, "YesNo", "Query") = 7
  1768.     Then Exit                          /* quit option given, exit    */
  1769.  
  1770.  
  1771. ΓòÉΓòÉΓòÉ 9.2. SysCls ΓòÉΓòÉΓòÉ
  1772.  
  1773. Function: SysCls 
  1774.  
  1775. Syntax:   call SysCls 
  1776.  
  1777. Purpose:  Clears the screen quickly. 
  1778.  
  1779.  
  1780. ΓòÉΓòÉΓòÉ 9.3. SysCurPos ΓòÉΓòÉΓòÉ
  1781.  
  1782. Function: SysCurPos 
  1783.  
  1784. Syntax:   pos = SysCurPos(row, col) 
  1785.  
  1786.    pos       The position of the cursor upon the calling of SysCurPos in the 
  1787.              form 'row col'. 
  1788.  
  1789.    row       The row on the screen to move to. 
  1790.  
  1791.    col       The column on the screen to move to. 
  1792.  
  1793.              Note:   Position (0,0) is at the upper left.  You may call 
  1794.              SysCurPos without parameters to check the current cursor position 
  1795.              without changing it. 
  1796.  
  1797. Purpose:  Move the cursor to the specified row and column and/or query the 
  1798.           current/previous cursor position. 
  1799.  
  1800.                     Example:
  1801.  
  1802.                      /* Code */
  1803.                      call SysCls
  1804.                      parse value SysCurPos() with row col
  1805.                      say 'Cursor position is 'row', 'col
  1806.  
  1807.                      /* Output */
  1808.                      Cursor position is 0, 0
  1809.  
  1810.  
  1811. ΓòÉΓòÉΓòÉ 9.4. SysCurState ΓòÉΓòÉΓòÉ
  1812.  
  1813. Function: SysCurState 
  1814.  
  1815. Syntax:   SysCurState state 
  1816.  
  1817.    state     The desired state which to set the cursor.  Should be one of the 
  1818.              following: 
  1819.  
  1820.       'ON'      Display the cursor. 
  1821.  
  1822.       'OFF'     Hide the cursor. 
  1823.  
  1824. Purpose:  Use this function to hide or display the cursor. 
  1825.  
  1826.  
  1827. ΓòÉΓòÉΓòÉ 9.5. SysDriveInfo ΓòÉΓòÉΓòÉ
  1828.  
  1829. Function: SysDriveInfo 
  1830.  
  1831. Syntax:   info = SysDriveInfo(drive) 
  1832.  
  1833.    info      Drive information returned in the following form: 'drive:  free 
  1834.              total label' If the drive is not accessible, then info will equal 
  1835.              ''. 
  1836.  
  1837.    drive     The drive of interest,  'C:'. 
  1838.  
  1839. Purpose:  Gives drive information. 
  1840.  
  1841.                     Example:
  1842.                      /* Code */
  1843.                      say 'Disk='SysDriveInfo('C:')
  1844.  
  1845.                      /* Output */
  1846.                      Disk=C: 33392640 83687424 TRIGGER_C
  1847.  
  1848. In the above Output example, the items have the following meaning: 
  1849.  
  1850. o The first item is the drive being queried. 
  1851. o The first number is the number of bytes that are free. 
  1852. o The second number is the number of bytes that are used. 
  1853. o The final item is the drive label. 
  1854.  
  1855.  
  1856. ΓòÉΓòÉΓòÉ 9.6. SysDriveMap ΓòÉΓòÉΓòÉ
  1857.  
  1858. Function: SysDriveMap 
  1859.  
  1860. Syntax:   map = SysDriveMap([drive], [opt]) 
  1861.  
  1862.    map       A string containing all accessible drives. 
  1863.  
  1864.    drive     Drive letter with which to start the drive map. The default is C. 
  1865.  
  1866.    opt       The drivemap report option.  May be any one of the following: 
  1867.  
  1868.       'USED'         Reports drives which are accessible or in use.  This is 
  1869.                      the default. This includes all local and remote drives. 
  1870.  
  1871.       'FREE'         Reports drives which are free or not in use. 
  1872.  
  1873.       'LOCAL'        Reports only those drives which are local drives. 
  1874.  
  1875.       'REMOTE'       Reports only those drives which are remote drives such as 
  1876.                      redirected LAN resources, IFS attached drives, and so on. 
  1877.  
  1878.       'DETACHED'     Reports drives which are detached LAN resources. 
  1879.  
  1880. Purpose:  Reports all accessible drives in the form 'C: D: E:...' 
  1881.  
  1882.                     Example:
  1883.                      /* Code */
  1884.                      say 'Used drives include:'
  1885.                      say SysDriveMap('C:', 'USED')
  1886.  
  1887.                      /* Output */
  1888.                      Used drives include:
  1889.                      C: D: E: F: W:
  1890.  
  1891.  
  1892. ΓòÉΓòÉΓòÉ 9.7. SysDropFuncs ΓòÉΓòÉΓòÉ
  1893.  
  1894. Function: SysDropFuncs 
  1895.  
  1896. Syntax:   call SysDropFuncs 
  1897.  
  1898. Purpose:  Use this function to drop all the loaded RexxUtil functions.  Once 
  1899.           this function is processed by a REXX program, the RexxUtil functions 
  1900.           are not accessible in any OS/2 sessions. 
  1901.  
  1902.  
  1903. ΓòÉΓòÉΓòÉ 9.8. SysFileDelete ΓòÉΓòÉΓòÉ
  1904.  
  1905. Function: SysFileDelete 
  1906.  
  1907. Syntax:   rc = SysFileDelete(file) 
  1908.  
  1909. Purpose:  Deletes the specified file.  Does not support wildcards. 
  1910.  
  1911. RC:       Return Codes 
  1912.  
  1913.    0         File deleted successfully. 
  1914.  
  1915.    2         Error.  File not found. 
  1916.  
  1917.    3         Error.  Path not found. 
  1918.  
  1919.    5         Error.  Access denied. 
  1920.  
  1921.    26        Error.  Not DOS disk. 
  1922.  
  1923.    32        Error.  Sharing violation. 
  1924.  
  1925.    36        Error.  Sharing buffer exceeded. 
  1926.  
  1927.    87        Error.  Invalid parameter 
  1928.  
  1929.    206       Error.  Filename exceeds range error 
  1930.  
  1931.  
  1932. ΓòÉΓòÉΓòÉ 9.9. SysFileTree ΓòÉΓòÉΓòÉ
  1933.  
  1934. Function: SysFileTree 
  1935.  
  1936. Syntax:   rc = SysFileTree(filespec, stem, [options], [tattrib], [nattrib]) 
  1937.  
  1938.    filespec  The filespec to search for. 
  1939.  
  1940.    stem      The name of the stem variable to place the results. 
  1941.  
  1942.              Note:   stem.0 contains the number of files and/or directories 
  1943.              found. 
  1944.  
  1945.    options   Any logical combination of the following: 
  1946.  
  1947.       F         Search for files only. 
  1948.  
  1949.       D         Search for directories only. 
  1950.  
  1951.       B         Search for both files and directories. (default) 
  1952.  
  1953.       S         Scan subdirectories recursively. (non-default). 
  1954.  
  1955.       T         Return time and date fields in the form: 
  1956.  
  1957.                                 YY/MM/DD/HH/MM
  1958.  
  1959.       O         Only report fully qualified file names.  The default is to 
  1960.                 report date, time, size, attributes and fully qualified file 
  1961.                 name for each file found. 
  1962.  
  1963.    tattrib   The target attribute mask used when searching for filespec 
  1964.              matches. Only filespecs which match the mask will be reported. 
  1965.              The default mask is '*****' which means the Archive, Directory, 
  1966.              Hidden, Read-Only, and System bits may be either set or clear. 
  1967.              The attributes in the mask are positional dependant and in the 
  1968.              alphabetical order 'ADHRS'. 
  1969.  
  1970.       Mask Options (Target Mask) 
  1971.  
  1972.          *         The specified attribute may be either set or clear. 
  1973.  
  1974.          +         The specified attribute must be set. 
  1975.  
  1976.          -         The specified attribute must be clear. 
  1977.  
  1978.          Examples: (Target Mask) 
  1979.  
  1980.             '***+*'   Find all files which have set Read-Only bits. 
  1981.  
  1982.             '+**+*'   Find all files which have set Read-Only and Archive bits. 
  1983.  
  1984.             '*++**'   Find all hidden subdirectories. 
  1985.  
  1986.             '---+-'   Find all files which have only the Read-Only bit set. 
  1987.  
  1988.    nattrib   The new attribute mask which will be used to set the attributes of 
  1989.              each filespec found to match the target mask.  The default mask is 
  1990.              '*****' which means the Archive, Directory, Hidden, Read-Only, and 
  1991.              System bits will not be changed.  The attributes in the mask are 
  1992.              positional dependant and in the alphabetical order 'ADHRS'. 
  1993.  
  1994.       Mask Options (New Atrribute Mask) 
  1995.  
  1996.          *         The specified attribute will not be changed. 
  1997.  
  1998.          +         The specified attribute will be set. 
  1999.  
  2000.          -         The specified attribute will be cleared. 
  2001.  
  2002.          Examples: (New Attribute Mask) 
  2003.  
  2004.             '***+*'   Set the Read-Only bit on all files. 
  2005.  
  2006.             '-**+*'   Set the Read-Only and clear the Archive bits of each 
  2007.                       file. 
  2008.  
  2009.             '+*+++'   Set all attributes on all files, excluding directory 
  2010.                       attribute. 
  2011.  
  2012.             '-----'   Clear all attribute on all files. 
  2013.  
  2014.                       Note:   You cannot set the directory bit on non-directory 
  2015.                       filespecs.  The attribute field which is displayed in the 
  2016.                       stem variable is that of the current attribute setting 
  2017.                       after any changes have been applied. 
  2018.  
  2019. Purpose:  Finds all files which are equal to the specified filespec, and places 
  2020.           their descriptions (date time size attr filespec) in a stem variable. 
  2021.  
  2022. RC:       Return Codes 
  2023.  
  2024.    0         Successful. 
  2025.  
  2026.    2         Error.  Not enough memory. 
  2027.  
  2028.                      Examples:
  2029.  
  2030.                       /****<< Syntax Examples.>>***********************/
  2031.  
  2032.                       /* Find all subdirectories on C: */
  2033.                        call SysFileTree 'c:\*.*', 'file', 'SD'
  2034.  
  2035.                       /* Find all Read-Only files */
  2036.                        call SysFileTree 'c:\*.*', 'file', 'S', '***+*'
  2037.  
  2038.                       /* Clear Archive and Read-Only bits of files which have them set */
  2039.                        call SysFileTree 'c:\*.*', 'file', 'S', '+**+*', '-**-*'
  2040.  
  2041.  
  2042.                       /****<< Sample Code and Output Example.>>********/
  2043.  
  2044.                       /* Code */
  2045.                        call SysFileTree 'c:\os2*.', 'file', 'B'
  2046.                        do i=1 to file.0
  2047.                          say file.i
  2048.                        end
  2049.  
  2050.                      /* Actual Output */
  2051.                     12:15:89  12:00a        4096  A-HRS  C:\OS2LDR
  2052.                     12:15:89  12:00a       29477  A-HRS  C:\OS2KRNL
  2053.                      5:24:89   4:59p           0  -D---  C:\OS2
  2054.  
  2055.  
  2056. ΓòÉΓòÉΓòÉ 9.10. SysFileSearch ΓòÉΓòÉΓòÉ
  2057.  
  2058. Function: SysFileSearch 
  2059.  
  2060. Syntax:   call SysFileSearch target, file, stem, [options] 
  2061.  
  2062.    target    The string to search for. 
  2063.  
  2064.    file      The file to search. 
  2065.  
  2066.    stem      The name of the stem variable to place the results. 
  2067.  
  2068.              Note:   stem.0 contains the number of lines found. 
  2069.  
  2070.    options   Any logical combination of the following: 
  2071.  
  2072.       C         Case sensitive search. 
  2073.  
  2074.       N         Give line numbers when reporting hits. 
  2075.  
  2076.                 Note:   Default is case insensitive without line numbers. 
  2077.  
  2078. Purpose:  Finds all lines in specified file which contain a specified target 
  2079.           string, and places said lines in a stem variable. 
  2080.  
  2081. RC:       Return Codes 
  2082.  
  2083.    0         Successful. 
  2084.  
  2085.    2         Error.  Not enough memory. 
  2086.  
  2087.    3         Error.  Error opening file. 
  2088.  
  2089.                     Examples:
  2090.  
  2091.                      /* Find DEVICE statements in CONFIG.SYS */
  2092.                      call SysFileSearch 'DEVICE', 'C:\CONFIG.SYS', 'file.'
  2093.                      do i=1 to file.0
  2094.                       say file.i
  2095.                      end
  2096.  
  2097.                      /* Output */
  2098.                      DEVICE=C:\OS2\DOS.SYS
  2099.                      DEVICE=C:\OS2\PMDD.SYS
  2100.                      DEVICE=C:\OS2\COM02.SYS
  2101.                      SET VIDEO_DEVICES=VIO_IBM8514A
  2102.                      SET VIO_IBM8514A=DEVICE(BVHVGA,BVH8514A)
  2103.                      DEVICE=C:\OS2\POINTDD.SYS
  2104.                      DEVICE=C:\OS2\MSPS202.SYS
  2105.                      DEVICE=C:\OS2\MOUSE.SYS TYPE=MSPS2$
  2106.  
  2107.  
  2108.                      /* Find DEVICE statements in CONFIG.SYS (along with */
  2109.                      /* line nums) */
  2110.                      call SysFileSearch 'DEVICE', 'C:\CONFIG.SYS', 'file.', 'N'
  2111.                      do i=1 to file.0
  2112.                       say file.i
  2113.                      end
  2114.  
  2115.                      /* Output */
  2116.                      20 DEVICE=C:\OS2\DOS.SYS
  2117.                      21 DEVICE=C:\OS2\PMDD.SYS
  2118.                      22 DEVICE=C:\OS2\COM02.SYS
  2119.                      33 SET VIDEO_DEVICES=VIO_IBM8514A
  2120.                      34 SET VIO_IBM8514A=DEVICE(BVHVGA,BVH8514A)
  2121.                      40 DEVICE=C:\OS2\POINTDD.SYS
  2122.                      41 DEVICE=C:\OS2\MSPS202.SYS
  2123.                      42 DEVICE=C:\OS2\MOUSE.SYS TYPE=MSPS2$
  2124.  
  2125.  
  2126. ΓòÉΓòÉΓòÉ 9.11. SysGetKey ΓòÉΓòÉΓòÉ
  2127.  
  2128. Function: SysGetKey 
  2129.  
  2130. Syntax:   key = SysGetKey([opt]) 
  2131.  
  2132.    key       The key which was pressed. 
  2133.  
  2134.    opt        Any one of the following: 
  2135.  
  2136.       'ECHO'    Echo the typed character  (Default) 
  2137.  
  2138.       'NOECHO'  Do not echo the typed character 
  2139.  
  2140. Purpose:  Gets the next key from the keyboard buffer, or waits for one if none 
  2141.           exist.  Works like the C function getch().  Unlike the regular REXX 
  2142.           CHARIN() built-in function, SysGetKey() does not require the 
  2143.           character to be followed by the Enter key. 
  2144.  
  2145.  
  2146. ΓòÉΓòÉΓòÉ 9.12. SysGetMessage ΓòÉΓòÉΓòÉ
  2147.  
  2148. Function: SysGetMessage 
  2149.  
  2150. Syntax:   msg = SysGetMessage(num, [file] [str1],...[str9]) 
  2151.  
  2152.    msg       The message associated with the number given. 
  2153.  
  2154.    num       The message number. 
  2155.  
  2156.    file      The message file to be searched.  The default message file is 
  2157.              OSO001.MSG. Message files will be searched for in the system root 
  2158.              directory ( C:\), the current directory, and along the DPATH. 
  2159.  
  2160.    str1,...str9 Insertion text variables.  If the message contains insertion 
  2161.              fields designated by %x, in the range %1 to %9, then the optional 
  2162.              parameters str1 through str9 may be used to designate the 
  2163.              replacement strings. 
  2164.  
  2165. Purpose:  OS/2 applications commonly use message files to provide National 
  2166.           Language Support (NLS).  Message files contain text strings which any 
  2167.           application can reference by their associated number. 
  2168.  
  2169.           Note:   Use the MKMSGF utility contained in the OS/2 Programmer's 
  2170.                   Toolkit to create message files.  MKMSGF is documented in the 
  2171.                   Building Programs book included with the toolkit. 
  2172.  
  2173.                     /*** Sample code segment using SysGetMessage and insertion text vars ***/
  2174.                     msg =  SysGetMessage(34, , 'A:', 'diskette labeled "Disk 2"', 'SER0002')
  2175.                     say msg
  2176.  
  2177.                     /** Output **/
  2178.                     The wrong diskette is in the drive.
  2179.                     Insert diskette labeled "Disk 2" (Volume Serial Number: SER0002)
  2180.                     into drive A:.
  2181.  
  2182.  
  2183. ΓòÉΓòÉΓòÉ 9.13. SysIni ΓòÉΓòÉΓòÉ
  2184.  
  2185. Function: SysIni 
  2186.  
  2187.    Syntax - Mode 1: Setting single key value. 
  2188.  
  2189.              result = SysIni([inifile], app, key, val) 
  2190.  
  2191.    Syntax - Mode 2: Querying single key value. 
  2192.  
  2193.              result = SysIni([inifile], app, key) 
  2194.  
  2195.    Syntax - Mode 3: Deleting a single key. 
  2196.  
  2197.              result = SysIni([inifile], app, key, 'DELETE:') 
  2198.  
  2199.    Syntax - Mode 4: Deleting an application and all associated keys. 
  2200.  
  2201.              result = SysIni([inifile], app, ['DELETE:']) 
  2202.  
  2203.    Syntax - Mode 5: Querying names of all keys associated with a certain 
  2204.              application. 
  2205.  
  2206.              result = SysIni([inifile], app, 'ALL:', 'stem') 
  2207.  
  2208.    Syntax - Mode 6: Querying names of all applications. 
  2209.  
  2210.              result = SysIni([inifile], 'ALL:', 'stem') 
  2211.  
  2212.    result    For successful setting invocations, result will equal ''. For 
  2213.              successful querying invocations, result will be given the value of 
  2214.              the specified application keyword.  For successful deleting 
  2215.              invocations, result will equal ''. 
  2216.  
  2217.              The error string 'ERROR:' may be returned if an error occurs: 
  2218.  
  2219.              Possible error conditions: 
  2220.  
  2221.       o An attempt was made to query or delete an application/key pair which 
  2222.         does not exist. 
  2223.  
  2224.       o An error occurred opening the specified INI file. You may have 
  2225.         specified the current user or system INI file using a relative 
  2226.         filespec. Make sure to use the full filespec, specifying drive, path, 
  2227.         and file name. 
  2228.  
  2229.    inifile   The name of the INI file which you would like to work with.  This 
  2230.              parameter should be a file specification, or one of the following: 
  2231.  
  2232.       'USER'    The user INI file (usually C:\OS2\OS2.INI).  This is the 
  2233.                 default. 
  2234.  
  2235.       'SYSTEM'  The system INI file (usually C:\OS2\OS2SYS.INI). 
  2236.  
  2237.       'BOTH'    For querying invocations, both the user and system INI files 
  2238.                 will be searched. For setting invocations, the user INI file 
  2239.                 will be written to. 
  2240.  
  2241.    app       The application name or some other meaningful value with which you 
  2242.              would like to store keywords (some sort of data). 
  2243.  
  2244.    key       The name of a keyword which is used to hold data. 
  2245.  
  2246.    val       The value to associate with the keyword of the specified 
  2247.              application. 
  2248.  
  2249.    stem      The name of the stem variable to store the resultant information 
  2250.              in.  STEM.0 will be set equal to the number of elements. 
  2251.  
  2252. Purpose:  This function allows limited editing of INI file variables. Variables 
  2253.           are stored in the INI file under Application Names and their 
  2254.           associated Key Names or keywords.  SysIni can be used to share 
  2255.           variables between applications or as a way of implementing GLOBALV in 
  2256.           the OS/2 operating system. 
  2257.  
  2258.           Note:   This function works on all types of data stored in an INI 
  2259.           file (text, numeric, or binary). 
  2260.  
  2261.                     /* Sample code segments */
  2262.  
  2263.                      /***  Save the user entered name under the key 'NAME' of *****
  2264.                      ****  the application 'MYAPP'.                           ****/
  2265.                      pull name .
  2266.                      call SysIni , 'MYAPP', 'NAME', name /* Save the value        */
  2267.                      say  SysIni(, 'MYAPP', 'NAME')      /* Query the value       */
  2268.                      call SysIni , 'MYAPP'               /* Delete all MYAPP info */
  2269.                      exit
  2270.  
  2271.                      /****  Type all OS2.INI file information to the screen  *****/
  2272.                     call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  2273.                     call sysloadfuncs
  2274.                        call SysIni 'USER', 'All:', 'Apps.'
  2275.                        if Result \= 'ERROR:' then
  2276.                          do i = 1 to Apps.0
  2277.                            call SysIni 'USER', Apps.i, 'All:', 'Keys'
  2278.                            if Result \= 'ERROR:' then
  2279.                             do j=1 to Keys.0
  2280.                               val = SysIni('USER', Apps.i, Keys.j)
  2281.                               say left(Apps.i, 20) left(Keys.j, 20),
  2282.                                     'Len=x'''Left(d2x(length(val)),4) left(val, 20)
  2283.                             end
  2284.                          end
  2285.  
  2286.  
  2287. ΓòÉΓòÉΓòÉ 9.14. SysMkDir ΓòÉΓòÉΓòÉ
  2288.  
  2289. Function: SysMkDir 
  2290.  
  2291. Syntax:   rc = SysMkDir(dirspec) 
  2292.  
  2293.    dirspec   The directory that should be created. 
  2294.  
  2295. Purpose:  Creates a specified directory quickly.  In case of failure, one of 
  2296.           many return codes is given so that the exact reason for failure can 
  2297.           be determined. 
  2298.  
  2299. RC:       Return Codes 
  2300.  
  2301.    0         Directory creation was successful. 
  2302.  
  2303.    2         Error.  File not found. 
  2304.  
  2305.    3         Error.  Path not found. 
  2306.  
  2307.    5         Error.  Access denied. 
  2308.  
  2309.    26        Error.  Not a DOS disk. 
  2310.  
  2311.    87        Error.  Invalid parameter. 
  2312.  
  2313.    108       Error.  Drive locked. 
  2314.  
  2315.    206       Error.  Filename exceeds range. 
  2316.  
  2317. Example:  call SysMkDir 'c:\rexx' 
  2318.  
  2319.  
  2320. ΓòÉΓòÉΓòÉ 9.15. SysOS2Ver ΓòÉΓòÉΓòÉ
  2321.  
  2322. Function: SysOS2Ver 
  2323.  
  2324. Syntax:   ver = SysOS2Ver( ) 
  2325.  
  2326.    ver       String containing OS/2 version info in the form 'x.xx' 
  2327.  
  2328. Purpose:  Returns the OS/2 version information. 
  2329.  
  2330.  
  2331. ΓòÉΓòÉΓòÉ 9.16. SysRmDir ΓòÉΓòÉΓòÉ
  2332.  
  2333. Function: SysRmDir 
  2334.  
  2335. Syntax:   rc = SysRmDir(dirspec) 
  2336.  
  2337.    dirspec   The directory that should be deleted. 
  2338.  
  2339. Purpose:  Deletes a specified directory quickly.  In case of failure, one of 
  2340.           many return codes is given so that the exact reason for failure can 
  2341.           be determined. 
  2342.  
  2343. RC:       Return Codes 
  2344.  
  2345.    0         Directory removal was successful. 
  2346.  
  2347.    2         Error.  File not found. 
  2348.  
  2349.    3         Error.  Path not found. 
  2350.  
  2351.    5         Error.  Access denied. 
  2352.  
  2353.    16        Error.  Current directory. 
  2354.  
  2355.    26        Error.  Not a DOS disk. 
  2356.  
  2357.    87        Error.  Invalid parameter. 
  2358.  
  2359.    108       Error.  Drive locked. 
  2360.  
  2361.    206       Error.  Filename exceeds range. 
  2362.  
  2363. Example:  call SysRmDir 'c:\rexx' 
  2364.  
  2365.  
  2366. ΓòÉΓòÉΓòÉ 9.17. SysSearchPath ΓòÉΓòÉΓòÉ
  2367.  
  2368. Function: SysSearchPath 
  2369.  
  2370. Syntax:   filespec = SysSearchPath(path, filename) 
  2371.  
  2372.    filespec  The complete filespec of the file found, or '' if the filename was 
  2373.              not located along the path. 
  2374.  
  2375.    path      Any environment variable that resembles a path, such as 'PATH', 
  2376.              'DPATH', and so on. 
  2377.  
  2378.    filename  The file to search the path for. 
  2379.  
  2380. Purpose:  Searches the specified path for the specified file and returns the 
  2381.           full filespec of the file if found, otherwise it returns. 
  2382.  
  2383.                     Example:
  2384.  
  2385.                      /* Code */
  2386.                      fspec = SysSearchPath('PATH', 'CMD.EXE')
  2387.                      say fspec
  2388.  
  2389.                      /* Output */
  2390.                      C:\OS2\CMD.EXE
  2391.  
  2392.  
  2393. ΓòÉΓòÉΓòÉ 9.18. SysSleep ΓòÉΓòÉΓòÉ
  2394.  
  2395. Function: SysSleep 
  2396.  
  2397. Syntax:   call SysSleep secs 
  2398.  
  2399.    secs      The number of seconds to sleep. 
  2400.  
  2401. Purpose:  Sleep a specified number of seconds. 
  2402.  
  2403.  
  2404. ΓòÉΓòÉΓòÉ 9.19. SysTempFileName ΓòÉΓòÉΓòÉ
  2405.  
  2406. Function: SysTempFileName 
  2407.  
  2408. Syntax:   file = SysTempFileName(template, [filter]) 
  2409.  
  2410.    template  The template that describes the temporary file or directory name 
  2411.              to be returned.  The template should resemble a valid file or 
  2412.              directory specification with up to 5 filter characters. 
  2413.  
  2414.    filter    The filter character found in the template.  Each filter character 
  2415.              found in the template is replaced with a numeric value.  The 
  2416.              resulting string represents a file or directory that does not 
  2417.              exist.  The default filter character is ?. 
  2418.  
  2419.    file      A file or directory that does not currently exist.  If an error 
  2420.              occurred or if no unique file or directory exists given the 
  2421.              template provided, a null string is returned. 
  2422.  
  2423. Purpose:  Returns a unique file or directory name given a certain template. 
  2424.           Useful when a program requires a temporary file but is not to 
  2425.           overwrite an existing file. 
  2426.  
  2427.                     Examples:
  2428.  
  2429.                      /* Code */
  2430.                      say SysTempFileName('C:\TEMP\MYEXEC.???')
  2431.                      say SysTempFileName('C:\TEMP\??MYEXEC.???')
  2432.                      say SysTempFileName('C:\MYEXEC@.@@@', '@')
  2433.  
  2434.                      /* Output */
  2435.                      C:\TEMP\MYEXEC.251
  2436.                      C:\TEMP\10MYEXEC.392
  2437.                      C:\MYEXEC6.019
  2438.  
  2439.           Note: 
  2440.  
  2441.           Since it is not required that the filter characters be contiguous 
  2442.           within the template, it is impossible to quickly determine the number 
  2443.           of files already residing in the target directory that would fit the 
  2444.           template description. 
  2445.  
  2446.           SysTempFileName uses a random number algorithm to determine a number 
  2447.           to replace the filter characters with.  It then tests if the 
  2448.           resulting file exists.  If it does not, it increments the number, 
  2449.           replaces the filter characters, and tests for the existence of the 
  2450.           new file, and so on.  This continues until a free file is found or 
  2451.           all possibilities have been exhausted. 
  2452.  
  2453.  
  2454. ΓòÉΓòÉΓòÉ 9.20. SysTextScreenRead ΓòÉΓòÉΓòÉ
  2455.  
  2456. Function: SysTextScreenRead 
  2457.  
  2458. Syntax:   string = SysReadScreen(row, col, [len]) 
  2459.  
  2460.    row       The row from which to start reading. 
  2461.  
  2462.    col       The column from which to start reading. 
  2463.  
  2464.    len       The number of characters to read.  The default is to read up to 
  2465.              the end of the screen. 
  2466.  
  2467.    string    The character reads from the screen.  This includes carriage 
  2468.              return and linefeed characters which comprise the end of lines 
  2469.              should the number of character reads span multiple lines. 
  2470.  
  2471. Purpose:  Reads a specified number of characters from a specified location of 
  2472.           the screen. 
  2473.  
  2474. Limitations  This function only reads in characters and does not consider the 
  2475. color attributes of each character read.  When restoring the character string 
  2476. to the screen with say or charout, the previous color settings will be lost. 
  2477.  
  2478. /* Example which reads in the entire screen */
  2479.  screen = SysTextScreenRead( 0, 0 )
  2480.  
  2481. /* Example which reads in one line */
  2482.  line = SysTextScreenRead( 2, 0, 80 )
  2483.  
  2484.  
  2485. ΓòÉΓòÉΓòÉ 9.21. SysTextScreenSize ΓòÉΓòÉΓòÉ
  2486.  
  2487. Function: SysTextScreenSize 
  2488.  
  2489. Syntax:   result = SysTextScreenSize() 
  2490.  
  2491.    result    The size of the screen.  The format of the result string is 'row 
  2492.              col'. 
  2493.  
  2494. Purpose:  This function returns the size of the screen. 
  2495.  
  2496. /* Example */
  2497. call RxFuncAdd 'SysTextScreenSize', 'RexxUtil', 'SysTextScreenSize'
  2498. parse value SysTextScreenSize() with row col
  2499. say 'Rows='row', Columns='col
  2500.  
  2501.  
  2502. ΓòÉΓòÉΓòÉ 9.22. SysGetEA ΓòÉΓòÉΓòÉ
  2503.  
  2504. Function: SysGetEA 
  2505.  
  2506. Syntax:   result = SysGetEA(file, name, variable) 
  2507.  
  2508.    file      The file containing the extended attribute. 
  2509.  
  2510.    name      The name of the extended attribute. 
  2511.  
  2512.    variable  The name of a REXX variable in which the extended attribute value 
  2513.              is placed. 
  2514.  
  2515.    result    The function result. If the result is 0, the extended attribute 
  2516.              has been retrieved and placed in a variable.  A non-zero result is 
  2517.              the OS/2 return code of the failing function. 
  2518.  
  2519. Purpose:  Read a named extended attribute from a file. 
  2520.  
  2521. Examples:
  2522.  
  2523.   /* Code    */
  2524.   if (SysGetEA("C:\CONFIG.SYS", ".type", "TYPEINFO") = 0 then
  2525.     parse var typeinfo 11 type
  2526.     say type
  2527.  
  2528.   /* Output */
  2529.   OS/2 Command File
  2530.  
  2531.  
  2532. ΓòÉΓòÉΓòÉ 9.23. SysPutEA ΓòÉΓòÉΓòÉ
  2533.  
  2534. Function: SysPutEA 
  2535.  
  2536. Syntax:   result = SysPutEA(file, name, value) 
  2537.  
  2538.    file      The file where the extended attribute will be written. 
  2539.  
  2540.    name      The name of the extended attribute. 
  2541.  
  2542.    value     The new value of the extended attribute. 
  2543.  
  2544.    result    The function result. If the result is 0, the extended attribute 
  2545.              has been written to the file. A non-zero result is the OS/2 return 
  2546.              code of the failing function. 
  2547.  
  2548. Purpose:  Write a named extended attribute to a file. 
  2549.  
  2550. Examples:
  2551.  
  2552.   /* Code    */
  2553.   type = "OS/2 Command File"
  2554.   typeinfo = "DFFF00000100FDFF'x || d2c(length(type)) || '00'x || type
  2555.   call SysPutEA "C:\CONFIG.SYS", "TYPE", typeinfo
  2556.  
  2557.  
  2558. ΓòÉΓòÉΓòÉ 9.24. SysWaitNamedPipe ΓòÉΓòÉΓòÉ
  2559.  
  2560. Function: SysWaitNamedPipe 
  2561.  
  2562. Syntax:   result = SysWaitNamedPipe(name, [timeout]) 
  2563.  
  2564.    name      The name of the named pipe.  Named pipe names must be of the form 
  2565.              "\PIPE\pipename". 
  2566.  
  2567.    timeout   The number of microseconds to wait on the pipe.  If timeout is 
  2568.              omitted or is zero, the default timeout value is be used. A value 
  2569.              of -1 can be used to wait until the pipe is no longer busy. 
  2570.  
  2571.    result    The return code from DosWaitNmPipe. The following return codes are 
  2572.              of particular interest: 
  2573.  
  2574.       0         The named pipe is no longer busy. 
  2575.  
  2576.       2         The named pipe was not found. 
  2577.  
  2578.       231       The wait timed out before the pipe became available. 
  2579.  
  2580. Purpose:  Perform a timed wait on a named pipe. 
  2581.  
  2582. Examples:
  2583.  
  2584.   /* Code    */
  2585.    Parse value stream(PipeName,'C','OPEN') with PipeState ':' OS2RC
  2586.    If OS2RC=231 then call SysWaitNamedPipe(PipeName, -1)
  2587.  
  2588.  
  2589. ΓòÉΓòÉΓòÉ 9.25. SysSetIcon ΓòÉΓòÉΓòÉ
  2590.  
  2591. Function: SysSetIcon 
  2592.  
  2593. Syntax:   result = SysSetIcon(filename, iconfilename) 
  2594.  
  2595.    filename          The name of the file to have the icon set. 
  2596.  
  2597.    iconfilename      The name of a .ICO file containing icon data. 
  2598.  
  2599.    result            The return code from WinSetIcon. This returns 1 (TRUE) if 
  2600.                      the icon was set and 0 (FALSE) if the new icon was not 
  2601.                      set. 
  2602.  
  2603.    Purpose:          Associate an icon file with a specified file. 
  2604.  
  2605.                     Examples:
  2606.  
  2607.                       /* Code    */
  2608.                        if SysSetIcon(file, "NEW.ICO") then
  2609.                          say 'Install successfully completed for' file
  2610.  
  2611.  
  2612. ΓòÉΓòÉΓòÉ 9.26. SysRegisterObjectClass ΓòÉΓòÉΓòÉ
  2613.  
  2614. Function: SysRegisterObjectClass 
  2615.  
  2616. Syntax:   result = SysRegisterObjectClass(classname, modulename) 
  2617.  
  2618.    classname         The name of the new object class. 
  2619.  
  2620.    modulename        The name of the module containing the object definition. 
  2621.  
  2622.    result            The return code from WinRegisterObjectClass.  This returns 
  2623.                      1 (TRUE) if the class was registered and 0 (FALSE) if the 
  2624.                      new class was not registered. 
  2625.  
  2626.    Purpose:          Register a new object class definition to the system. 
  2627.  
  2628.                     Examples:
  2629.  
  2630.                       /* Code    */
  2631.                        if SysRegisterObjectClass("NewObject","NEWDLL") then
  2632.                          say 'Install successfully completed for NewObject'
  2633.  
  2634.  
  2635. ΓòÉΓòÉΓòÉ 9.27. SysDeregisterObjectClass ΓòÉΓòÉΓòÉ
  2636.  
  2637. Function: SysDeregisterObjectClass 
  2638.  
  2639. Syntax:   result = SysDeregisterObjectClass(classname) 
  2640.  
  2641.    classname         The name of the object class to deregister. 
  2642.  
  2643.    result            The return code from WinDeregisterObjectClass.  This 
  2644.                      returns 1 (TRUE) if the class was deregistered and 0 
  2645.                      (FALSE) if the class was not deregistered. 
  2646.  
  2647.    Purpose:          Deregister an object class definition from the system. 
  2648.  
  2649.                     Examples:
  2650.  
  2651.                       /* Code    */
  2652.                        call SysDeregisterObjectClass "OldObject","NEWDLL"
  2653.  
  2654.  
  2655. ΓòÉΓòÉΓòÉ 9.28. SysCreateObject ΓòÉΓòÉΓòÉ
  2656.  
  2657. Function: SysCreateObject 
  2658.  
  2659. Syntax:   result = SysCreateObject(classname, title, location <,setup>) 
  2660.  
  2661.    classname         The name of the object class. 
  2662.  
  2663.    title             The object title. 
  2664.  
  2665.    location          The object location.  This can be specified as either a 
  2666.                      descriptive path (for example, OS/2 System Folder\System 
  2667.                      Configuration) or a file system path (for example, 
  2668.                      C:\bin\mytools). 
  2669.  
  2670.    setup             A WinCreateObject setup string. 
  2671.  
  2672.    result            The return code from WinCreateObject.  This returns 1 
  2673.                      (TRUE) if the object was created and 0 (FALSE) if the 
  2674.                      object was not created. 
  2675.  
  2676.    Purpose:          Create a new instance of an object class. 
  2677.  
  2678.                     Examples:
  2679.  
  2680.                       /* Code    */
  2681.                        if \SysCreateObject("Program","NEWDLL") then
  2682.                          say 'Install successfully completed for NewObject'
  2683.  
  2684.  
  2685. ΓòÉΓòÉΓòÉ 9.29. SysQueryClassList ΓòÉΓòÉΓòÉ
  2686.  
  2687. Function: SysQueryClassList 
  2688.  
  2689. Syntax:   call  SysQueryClassList stem 
  2690.  
  2691.    stem      The name of a stem variable in which the entire set of registered 
  2692.              classes is placed. 
  2693.  
  2694.    Purpose:  Retrieve the complete list of registered object classes. 
  2695.  
  2696.                     Examples:
  2697.  
  2698.                       /* Code    */
  2699.                        call SysQueryClassList "list."
  2700.                        do i = 1 to list.0
  2701.                          say 'Class' i 'is' list.i
  2702.                        end
  2703.  
  2704.  
  2705. ΓòÉΓòÉΓòÉ <hidden> Arithmetic Examples ΓòÉΓòÉΓòÉ
  2706.  
  2707. This sample procedure named MATH.CMD shows you how to perform four arithmetic 
  2708. operations on variables: 
  2709.  
  2710. /* Performing arithmetic operations on variables */
  2711. a = 4
  2712. b = 2
  2713. c = a + b
  2714. SAY 'The result of 'a '+' b 'is' c
  2715. SAY
  2716. c = a * b
  2717. SAY 'The result of ' a '*' b 'is' c
  2718. SAY
  2719. c = a - b
  2720. SAY 'The result of ' a '-' b 'is' c
  2721. SAY
  2722. c = a / b
  2723. SAY 'The result of 'a '/' b 'is' c
  2724. EXIT
  2725. Your screen looks like this: 
  2726.  
  2727. [C:\]MATH
  2728. The result of 4 + 2 is 6
  2729.  
  2730. The result of 4 * 2 is 8
  2731.  
  2732. The result of 4 - 2 is 2
  2733.  
  2734. The result of 4 / 2 is 2
  2735.  
  2736. [C:\]
  2737.  
  2738.  
  2739. ΓòÉΓòÉΓòÉ <hidden> Using Comparisons ΓòÉΓòÉΓòÉ
  2740.  
  2741. The following procedure, TF.CMD, uses comparisons and an equal expression to 
  2742. determine if numeric expressions are true or false. 
  2743.  
  2744. /* Determine if expression is true or false  */
  2745. /* 1 is true; 0 is false                     */
  2746. a = 4
  2747. b = 2
  2748. c = a > b
  2749. SAY 'The result of' a '>' b 'is' c
  2750. c = a < b
  2751. SAY 'The result of' a '<' b 'is' c
  2752. c = a = b
  2753. SAY 'The result of' a '=' b 'is' c
  2754. EXIT
  2755.  
  2756. When you run the procedure, it gives the following results: 
  2757.  
  2758.  
  2759. [C:\]TF
  2760. The result of 4 > 2 is 1
  2761. The result of 4 < 2 is 0
  2762. The result of 4 = 2 is 0
  2763.  
  2764. [C:\]
  2765.  
  2766.  
  2767. ΓòÉΓòÉΓòÉ <hidden> Logical Operators - Examples ΓòÉΓòÉΓòÉ
  2768.  
  2769. The following procedure, AND.CMD, shows the AND operator checking for two true 
  2770. statements. 
  2771.  
  2772. /* Using the AND (&) Operator   */
  2773. /* 0 is false; 1 is true        */
  2774. a = 4
  2775. b = 2
  2776. c = 5
  2777. d = (a > b) & (b > c)
  2778. SAY 'The result of (a > b) & (b > c) is' d
  2779. d = (a > b) & (b < c)
  2780. SAY 'The result of (a > b) & (b < c) is' d
  2781. EXIT
  2782.  
  2783. When run on your system, AND.CMD displays the following on your screen as: 
  2784.  
  2785.  
  2786.  
  2787. [C:\]AND
  2788. The result of (a > b) & (b > c) is 0
  2789. The result of (a > b) & (b < c) is 1
  2790.  
  2791. [C:\]
  2792.  
  2793. The following procedure, OR.CMD, shows the OR operator in a true statement 
  2794. unless both values are false: 
  2795.  
  2796. /* Using the OR (|) Operator    */
  2797. /* 0 is false; 1 is true        */
  2798. a = 4
  2799. b = 2
  2800. c = 5
  2801. d = (a > b) | (b > c)
  2802. SAY 'The result of (a > b) | (b > c) is' d
  2803. d = (a > b) | (b < c)
  2804. SAY 'The result of (a > b) | (b < c) is' d
  2805. EXIT
  2806.  
  2807. When run on your system, the procedure displays the following: 
  2808.  
  2809.  
  2810. [C:\]OR
  2811. The result of (a > b) | (b > c) is 1
  2812. The result of (a > b) | (b < c) is 1
  2813.  
  2814. [C:\]
  2815.  
  2816.  
  2817. ΓòÉΓòÉΓòÉ <hidden> DO WHILE Example ΓòÉΓòÉΓòÉ
  2818.  
  2819. A procedure using a DO WHILE loop is DOWHILE.CMD.  It tests for a true or false 
  2820. condition at the top of the loop. 
  2821.  
  2822. /* Using a DO WHILE loop */
  2823. SAY 'Enter the amount of money available'
  2824. PULL salary
  2825. spent = 0
  2826. DO WHILE spent < salary
  2827.    SAY 'Type in cost of item'
  2828.    PULL cost
  2829.    spent = spent + cost
  2830. END
  2831. SAY 'Empty pockets.'
  2832. EXIT
  2833.  
  2834. After running the DOWHILE procedure, you see this on your screen: 
  2835.  
  2836. [C:\]dowhile
  2837. Enter the amount of money available
  2838. 100
  2839. Type in cost of item
  2840. 57
  2841. Type in cost of item
  2842. 24
  2843. Type in cost of item
  2844. 33
  2845. Empty pockets.
  2846. [C:\]
  2847.  
  2848.  
  2849. ΓòÉΓòÉΓòÉ <hidden> DO UNTIL Example ΓòÉΓòÉΓòÉ
  2850.  
  2851. A procedure using a DO UNTIL loop is DOUNTIL.CMD.  It tests for a true or false 
  2852. condition at the bottom of the loop: 
  2853.  
  2854. /* Using a DO UNTIL loop */
  2855. SAY 'Enter the amount of money available'
  2856. PULL salary
  2857. spent = 0          /* Sets spent to a value of 0 */
  2858. DO UNTIL spent > salary
  2859.    SAY 'Type the cost of item'
  2860.    PULL cost
  2861.    spent = spent + cost
  2862. END
  2863. SAY 'Empty pockets.'
  2864. EXIT
  2865.  
  2866. When run, DOUNTIL.CMD displays on your screen as: 
  2867.  
  2868. [C:\] DOUNTIL
  2869. Enter the amount of money available
  2870. 50
  2871. Type the cost of item
  2872. 37
  2873. Type the cost of item
  2874. 14
  2875. Empty pockets.
  2876. [C:\]
  2877.  
  2878.  
  2879. ΓòÉΓòÉΓòÉ <hidden> OS/2 ΓòÉΓòÉΓòÉ
  2880.  
  2881. Trademark of the IBM Corporation. 
  2882.  
  2883.  
  2884. ΓòÉΓòÉΓòÉ <hidden> Systems Application Architecture ΓòÉΓòÉΓòÉ
  2885.  
  2886. Trademark of the IBM Corporation. 
  2887.  
  2888.  
  2889. ΓòÉΓòÉΓòÉ <hidden> Presentation Manager ΓòÉΓòÉΓòÉ
  2890.  
  2891. Trademark of the IBM Corporation. 
  2892.  
  2893.  
  2894. ΓòÉΓòÉΓòÉ 10. Keyword Instructions ΓòÉΓòÉΓòÉ
  2895.  
  2896. A keyword instruction is one or more clauses, the first of which starts with a 
  2897. keyword that identifies the instruction.  If the instruction has more than one 
  2898. clause, the clauses are separated by a delimiter, in this case a semicolon (;). 
  2899.  
  2900. Some keyword instructions, such as those starting with the keyword DO, can 
  2901. include nested instructions. 
  2902.  
  2903. In the syntax diagrams, symbols (words) in upper case letters denote keywords; 
  2904. other words (such as expression) denote a collection of symbols. Keywords are 
  2905. not case dependent: the symbols if, If, and iF would all invoke the instruction 
  2906. IF. Also, you usually omit most of the clause delimiters (;) shown because they 
  2907. are implied by the end of a line. 
  2908.  
  2909.  
  2910. ΓòÉΓòÉΓòÉ 10.1. ADDRESS ΓòÉΓòÉΓòÉ
  2911.  
  2912.  
  2913.  ΓöÇΓöÇADDRESSΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ;ΓöÇΓöÇΓöÇ
  2914.                  Γö£ΓöÇenvironmentΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ
  2915.                  Γöé             ΓööΓöÇexpressionΓöÇΓöÿ Γöé
  2916.                  ΓööΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇexpression1ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2917.                   ΓööΓöÇVALUEΓöÇΓöÿ
  2918.  
  2919. Address is used to send a single command to a specified environment, code an 
  2920. environment, a literal string, or a single symbol, which is taken to be a 
  2921. constant, followed by an expression. The expression is evaluated, and the 
  2922. resulting command string is routed to environment. After the command is 
  2923. executed, environment is set back to whatever it was before, thus temporarily 
  2924. changing the destination for a single command. 
  2925.  
  2926. Example: 
  2927.  
  2928. ADDRESS CMD "DIR C:\STARTUP.CMD"   /*   OS/2   */
  2929.  
  2930. If only environment is specified, a lasting change of destination occurs: all 
  2931. commands that follow (clauses that are neither REXX instructions nor assignment 
  2932. instructions) will be routed to the given command environment, until the next 
  2933. ADDRESS instruction is executed. The previously selected environment is saved. 
  2934.  
  2935. Example: 
  2936.  
  2937. Suppose that the environment for a text editor is registered by the name EDIT: 
  2938.  
  2939. address CMD
  2940. 'DIR C:\STARTUP.CMD'
  2941. if rc=0 then 'COPY STARTUP.CMD *.TMP'
  2942. address EDIT
  2943.  
  2944. Subsequent commands are passed to the editor until the next ADDRESS 
  2945. instruction. 
  2946.  
  2947. Similarly, you can use the VALUE form to make a lasting change to the 
  2948. environment.  Here expression1 (which may be just a variable name) is 
  2949. evaluated, and the result forms the name of the environment.  The subkeyword 
  2950. VALUE can be omitted as long as expression1 starts with a special character (so 
  2951. that it cannot be mistaken for a symbol or string). 
  2952.  
  2953. Example: 
  2954.  
  2955. ADDRESS ('ENVIR'||number)
  2956.  
  2957. With no arguments, commands are routed back to the environment that was 
  2958. selected before the previous lasting change of environment was made, and the 
  2959. current environment name is saved. Repeated execution of ADDRESS alone, 
  2960. therefore, switches the command destination between two environments 
  2961. alternately. A null string for the environment name (" ") is the same as the 
  2962. default environment. 
  2963.  
  2964.  
  2965. ΓòÉΓòÉΓòÉ 10.2. ARG ΓòÉΓòÉΓòÉ
  2966.  
  2967.  
  2968.  ΓöÇΓöÇΓöÇΓöÇARGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  2969.                  ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÿ
  2970.  
  2971. ARG is used to retrieve the argument strings provided to a program or internal 
  2972. routine and assign them to variables.  It is a short form of the following 
  2973. instruction: 
  2974.  
  2975.  ΓöÇΓöÇPARSE UPPER ARGΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ;ΓöÇΓöÇΓöÇ
  2976.                      ΓööΓöÇΓöÇΓöÇΓöÇtemplateΓöÇΓöÇΓöÇΓöÇΓöÿ
  2977.  
  2978. Template is a list of symbols separated by blanks or patterns. 
  2979.  
  2980. Unless a subroutine or internal function is being run, the interpreter reads 
  2981. the arguments given on the program invocation, translates them to uppercase 
  2982. (for example, a lowercase a-z to an uppercase A-Z), and then parses them into 
  2983. variables. Use the PARSE ARG instruction if you do not want uppercase 
  2984. translation. 
  2985.  
  2986. If a subroutine or internal function is being run, the data used will be the 
  2987. argument strings passed to the routine. 
  2988.  
  2989. The ARG (and PARSE ARG) instructions can be run as often as desired (typically 
  2990. with different templates) and always parse the same current input strings. 
  2991. There are no restrictions on the length or content of the data parsed except 
  2992. those imposed by the caller. 
  2993.  
  2994. Example: 
  2995.  
  2996. /* String passed is "Easy Rider"  */
  2997.  
  2998. Arg adjective noun
  2999.  
  3000. /* Now:  "ADJECTIVE"  contains 'EASY'           */
  3001. /*       "NOUN"       contains 'RIDER'          */
  3002.  
  3003. If more than one string is expected to be available to the program or routine, 
  3004. each can be selected in turn by using a comma in the parsing template. 
  3005.  
  3006. Example: 
  3007.  
  3008. /* function is invoked by  FRED('data X',1,5)   */
  3009.  
  3010. Fred:  Arg string, num1, num2
  3011.  
  3012. /* Now:  "STRING" contains 'DATA X'             */
  3013. /*       "NUM1"   contains '1'                  */
  3014. /*       "NUM2"   contains '5'                  */
  3015.  
  3016. Notes: 
  3017.  
  3018. o The argument strings to a REXX program or internal routine can also be 
  3019.   retrieved or checked by using the ARG built-in function. 
  3020.  
  3021. o The source of the data being processed is also made available on entry to the 
  3022.   program.  See the PARSE instruction (SOURCE option) for details. 
  3023.  
  3024.  
  3025. ΓòÉΓòÉΓòÉ 10.3. CALL ΓòÉΓòÉΓòÉ
  3026.  
  3027.  
  3028.  ΓöÇΓöÇΓöÇΓöÇCALLΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇnameΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇ
  3029.  
  3030.               Γöé           Γöé   ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ       Γöé
  3031.               Γöé           Γöé                 Γöé       Γöé
  3032.               Γöé           ΓööΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇexpressionΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3033.               Γöé                                      Γöé
  3034.               Γö£ΓöÇΓöÇΓöÇOFFΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇERRORΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3035.               Γöé           Γö£ΓöÇΓöÇFAILUREΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  3036.               Γöé           Γö£ΓöÇΓöÇHALTΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  3037.               Γöé           ΓööΓöÇΓöÇNOTREADYΓöÇΓöÇΓöÇΓöÿ            Γöé
  3038.               Γöé                                      Γöé
  3039.               ΓööΓöÇΓöÇONΓöÇΓöÇΓö¼ΓöÇERRORΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÿ
  3040.                      Γö£ΓöÇFAILUREΓöÇΓöÇΓöñ ΓööΓöÇNAMEΓöÇtrapnameΓöÇΓöÿ
  3041.                      Γö£ΓöÇHALTΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3042.                      ΓööΓöÇNOTREADYΓöÇΓöÿ
  3043.  
  3044. CALL is used to invoke a routine (if you specify name) or to control the 
  3045. trapping of certain conditions (if ON or OFF is specified) 
  3046.  
  3047. To control trapping, specify OFF or ON and the condition you want to trap.  OFF 
  3048. turns off the specified condition trap.  ON turns on the specified condition 
  3049. trap. 
  3050.  
  3051. To invoke a routine, specify name, which is a symbol or literal string that is 
  3052. taken as a constant.  The name must be a valid symbol. The routine invoked can 
  3053. be any of the following: 
  3054.  
  3055. o An internal routine 
  3056. o An external routine 
  3057. o A built-in function. 
  3058.  
  3059. If a string is used for name (that is, name is specified in quotation marks) 
  3060. the search for internal labels is bypassed, and only a built-in function or an 
  3061. external routine is invoked.  Note that the names of built-in functions (and 
  3062. generally the names of external routines too) are in uppercase; therefore, the 
  3063. name in the literal string should be in uppercase. 
  3064.  
  3065. The routine can optionally return a result and is functionally identical to the 
  3066. clause: 
  3067.  
  3068. ΓöÇresult=name(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ;ΓöÇΓöÇ
  3069.                 Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ  Γöé
  3070.                 Γöé                Γöé  Γöé
  3071.                 ΓööΓöÇΓö┤Γö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö┤ΓöÇΓöÇΓöÿ
  3072.                    ΓööΓöÇexpressionΓöÇΓöÿ
  3073.  
  3074. The exception is that the variable result becomes uninitialized if no result is 
  3075. returned by the routine invoked. 
  3076.  
  3077. The name given in the CALL instruction must be a valid symbol. 
  3078.  
  3079. The OS/2 interpreter supports the specification of up to 20 expressions, 
  3080. separated by commas. The expressions are evaluated in order from left to right, 
  3081. and form the argument strings during execution of the routine. Any ARG or PARSE 
  3082. ARG instructions or ARG built-in function in the called routine will access 
  3083. these strings rather than those previously active in the calling program.  You 
  3084. can omit expressions, if appropriate, by including extra commas. 
  3085.  
  3086. The CALL then causes a branch to the routine called name using the same 
  3087. mechanism as function calls. The order in which these are searched for is 
  3088. described in the section on functions.  A brief summary follows: 
  3089.  
  3090. Internal routines:  These are sequences of instructions inside the same 
  3091.                     program, starting at the label that matches name in the 
  3092.                     CALL instruction. If the routine name is specified in 
  3093.                     quotation marks, then an internal routine is not considered 
  3094.                     for that search order. 
  3095.  
  3096. Built-in routines:  These are routines built in to the language processor for 
  3097.                     providing various functions.  They always return a string 
  3098.                     containing the result of the function. 
  3099.  
  3100. External routines:  Users can write or make use of routines that are external 
  3101.                     to the language processor and the calling program. An 
  3102.                     external routine can be written in any language, including 
  3103.                     REXX, that supports the system-dependent interfaces.  If an 
  3104.                     external routine, written in REXX, is invoked as a 
  3105.                     subroutine by the CALL instruction, you can retrieve any 
  3106.                     argument strings with the ARG or PARSE ARG instructions or 
  3107.                     the ARG built-in function. 
  3108.  
  3109.  
  3110. ΓòÉΓòÉΓòÉ 10.4. DO ΓòÉΓòÉΓòÉ
  3111.  
  3112.  
  3113. ΓöÇDOΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ENDΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼;ΓöÇΓöÇ
  3114.       ΓööΓöÇrepetitorΓöÇΓöÿ ΓööΓöÇconditionalΓöÇΓöÿ   ΓöéΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé    ΓööΓöÇnameΓöÇΓöÿ
  3115.                                       Γöé             ΓöéΓöé
  3116.                                       ΓööΓö┤ΓöÇinstructionΓöÇΓö┤Γöÿ
  3117.  
  3118. repetitor:
  3119.  
  3120. ΓöÇΓö¼ΓöÇname=expriΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ
  3121.   Γöé            ΓööTOΓöÇexprtΓöÿ ΓööBYΓöÇexprbΓöÿ ΓööFORΓöÇexprfΓöÿ Γöé
  3122.   Γö£ΓöÇΓöÇFOREVERΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3123.   ΓööΓöÇΓöÇexprrΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3124.  
  3125.  
  3126. conditional:
  3127.  
  3128. ΓöÇΓöÇΓöÇΓö¼ΓöÇWHILEΓöÇexprwΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ
  3129.     ΓööΓöÇUNTILΓöÇexpruΓöÇΓöÇΓöÿ
  3130.  
  3131. DO is used to group instructions together and optionally to execute them 
  3132. repetitively. During repetitive execution, a control variable (name) can be 
  3133. stepped through some range of values. 
  3134.  
  3135. Syntax Notes: 
  3136.  
  3137. o The exprr, expri, exprb, exprt, and exprf options (if any are present) are 
  3138.   any expressions that evaluate to a number. The exprr and exprf options are 
  3139.   further restricted to result in a nonnegative whole number. If necessary, the 
  3140.   numbers will be rounded according to the setting of NUMERIC DIGITS. 
  3141.  
  3142. o The exprw or expru options (if present) can be any expression that evaluates 
  3143.   to 1 or 0. 
  3144.  
  3145. o The TO, BY, and FOR phrases can be in any order, if used. 
  3146.  
  3147. o The instructions can include assignments, commands, and keyword instructions 
  3148.   (including any of the more complex constructs such as IF, SELECT, and the DO 
  3149.   instruction itself). 
  3150.  
  3151. o The subkeywords TO, BY, FOR, WHILE, and UNTIL are reserved within a DO 
  3152.   instruction, in that they cannot name variables in the expressions but they 
  3153.   can be used as the name of the control variable. FOREVER is similarly 
  3154.   reserved, but only if it immediately follows the keyword DO. 
  3155.  
  3156. o The exprb option defaults to 1, if relevant. 
  3157.  
  3158. Simple DO Group: 
  3159.  
  3160. If neither repetitor nor conditional is given, the construct merely groups a 
  3161. number of instructions together.  These are executed once. Otherwise, the group 
  3162. of instructions is a repetitive DO loop, and they are executed according to the 
  3163. repetitor phrase, optionally modified by the conditional phrase. 
  3164.  
  3165. In the following example, the instructions are executed once. 
  3166.  
  3167. Example: 
  3168.  
  3169. /* The two instructions between DO and END will both */
  3170. /* be executed if A has the value 3.                 */
  3171. If a=3 then Do
  3172.             a=a+2
  3173.             Say 'Smile!'
  3174.             End
  3175.  
  3176. Simple Repetitive Loops: 
  3177.  
  3178. If repetitor is omitted but there is a conditional or the repetitor is FOREVER, 
  3179. the group of instructions will nominally be executed forever, that is, until 
  3180. the condition is satisfied or a REXX instruction is executed that ends the loop 
  3181. (for example, LEAVE). 
  3182.  
  3183. In the simple form of a repetitive loop, exprr is evaluated immediately (and 
  3184. must result in a nonnegative whole number), and the loop is then executed that 
  3185. many times. 
  3186.  
  3187. Example: 
  3188.  
  3189. /* This displays "Hello" five times */
  3190. Do 5
  3191.   say 'Hello'
  3192.   end
  3193.  
  3194. Note that, similar to the distinction between a command and an assignment, if 
  3195. the first character of exprr is a symbol and the second is an "=" character, 
  3196. the controlled form of repetitor is expected. 
  3197.  
  3198. Controlled Repetitive Loops: 
  3199.  
  3200. The controlled form specifies a control variable, name, which is assigned an 
  3201. initial value (the result of expri, formatted as though 0 had been added). The 
  3202. variable is then stepped (that is, the result of exprb is added at the bottom 
  3203. of the loop) each time the group of instructions is run. The group is run 
  3204. repeatedly while the end condition (determined by the result of exprt) is not 
  3205. met. If exprb is positive or zero, the loop will be terminated when name is 
  3206. greater than exprt. If negative, the loop is terminated when name is less than 
  3207. exprt. 
  3208.  
  3209. The expri, exprt, and exprb options must result in numbers.  They are evaluated 
  3210. once only, before the loop begins and before the control variable is set to its 
  3211. initial value. The default value for exprb is 1. If exprt is omitted, the loop 
  3212. is run indefinitely unless some other condition terminates it. 
  3213.  
  3214. Example: 
  3215.  
  3216. Do I=3 to -2 by -1        /* Would display:   */
  3217.   say i                   /*      3           */
  3218.   end                     /*      2           */
  3219.                           /*      1           */
  3220.                           /*      0           */
  3221.                           /*      -1          */
  3222.                           /*      -2          */
  3223.  
  3224. The numbers do not have to be whole numbers. 
  3225.  
  3226. Example: 
  3227.  
  3228. X=0.3                     /* Would display:   */
  3229. Do Y=X to X+4 by 0.7      /*     0.3          */
  3230.   say Y                   /*     1.0          */
  3231.   end                     /*     1.7          */
  3232.                           /*     2.4          */
  3233.                           /*     3.1          */
  3234.                           /*     3.8          */
  3235.  
  3236. The control variable can be altered within the loop, and this may affect the 
  3237. iteration of the loop. Altering the value of the control variable is not 
  3238. normally considered good programming practice, though it may be appropriate in 
  3239. certain circumstances. 
  3240.  
  3241. Note that the end condition is tested at the start of each iteration (and after 
  3242. the control variable is stepped, on the second and subsequent iterations). 
  3243. Therefore, the group of instructions can be skipped entirely if the end 
  3244. condition is met immediately. Note also that the control variable is referred 
  3245. to by name. If, for example, the compound name A.I is used for the control 
  3246. variable, altering I within the loop causes a change in the control variable. 
  3247.  
  3248. The processing of a controlled loop can be bounded further by a FOR phrase. In 
  3249. this case, exprf must be given and must evaluate to a nonnegative whole number. 
  3250. This acts just like the repetition count in a simple repetitive loop, and sets 
  3251. a limit to the number of iterations around the loop if no other condition 
  3252. terminates it. Similar to the TO and BY expressions, it is evaluated once 
  3253. only-when the DO instruction is first executed and before the control variable 
  3254. is given its initial value. Like the TO condition, the FOR condition is checked 
  3255. at the start of each iteration. 
  3256.  
  3257. Example: 
  3258.  
  3259. Do Y=0.3 to 4.3 by 0.7 for 3  /* Would display:    */
  3260.   say Y                       /*     0.3           */
  3261.   end                         /*     1.0           */
  3262.                               /*     1.7           */
  3263.  
  3264. In a controlled loop, the name describing the control variable can be specified 
  3265. on the END clause. This name must match name in the DO clause in all respects 
  3266. except case (note that no substitution for compound variables is carried out); 
  3267. a syntax error results if it does not. This enables the nesting of loops to be 
  3268. checked automatically, with minimal overhead. 
  3269.  
  3270. Example: 
  3271.  
  3272. Do K=1 to 10
  3273.   ...
  3274.   ...
  3275.   End k  /* Checks that this is the END for K loop */
  3276.  
  3277. Note:   The values taken by the control variable may be affected by the NUMERIC 
  3278.         settings, since normal REXX arithmetic rules apply to the computation 
  3279.         of stepping the control variable. 
  3280.  
  3281. Conditional Phrases (WHILE and UNTIL): 
  3282.  
  3283. Any of the forms of repetitor (none, FOREVER, simple, or controlled) can be 
  3284. followed by a conditional phrase, which may cause termination of the loop. If 
  3285. you specify WHILE or UNTIL, exprw or expru, respectively, is evaluated each 
  3286. time around the loop using the latest values of all variables (and must 
  3287. evaluate to either 0 or 1). The group of instructions is repeatedly processed 
  3288. either while the result is 1 or until the result is 1. 
  3289.  
  3290. For a WHILE loop, the condition is evaluated at the top of the group of 
  3291. instructions; for an UNTIL loop, the condition is evaluated at the bottom, 
  3292. before the control variable has been stepped. 
  3293.  
  3294. Example: 
  3295.  
  3296. Do I=1 to 10 by 2 until i>6
  3297.   say i
  3298.   end
  3299. /* Will display: 1, 3, 5, 7 */
  3300.  
  3301. Note:   The processing of repetitive loops can also be modified by using the 
  3302.         LEAVE or ITERATE instructions. 
  3303.  
  3304.  
  3305. ΓòÉΓòÉΓòÉ 10.5. DROP ΓòÉΓòÉΓòÉ
  3306.  
  3307.               ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  3308.                          Γöé
  3309.  ΓöÇΓöÇΓöÇΓöÇDROPΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇnameΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3310.  
  3311. Each name is a valid variable symbol, optionally enclosed in parentheses (to 
  3312. denote a subsidiary list), and separated from any other name by one or more 
  3313. blanks or comments. 
  3314.  
  3315. DROP is used to unassign variables; that is, to restore them to their original 
  3316. uninitialized state. 
  3317.  
  3318. Each variable specified is dropped from the list of known variables. If a 
  3319. single name is enclosed in parentheses, then its value is used as a subsidiary 
  3320. list of variables to drop. This stored list must follow the same rules as for 
  3321. the main list (that is, valid variable names, separated by blanks) but with no 
  3322. parentheses and no leading or trailing blanks. The variables are dropped in 
  3323. sequence from left to right. It is not an error to specify a name more than 
  3324. once, or to DROP a variable that is not known. If an exposed variable is named 
  3325. (see the PROCEDURE instruction), the variable itself in the older generation is 
  3326. dropped. 
  3327.  
  3328. Example: 
  3329.  
  3330. j=4
  3331. Drop  a x.3 x.j
  3332. /* would reset the variables: A, X.3, and X.4 */
  3333. /* so that reference to them returns their name.    */
  3334.  
  3335. Here, a variable name in parentheses is used as a subsidiary list. 
  3336.  
  3337. Example: 
  3338.  
  3339. x=4;y=5;z=6;
  3340. a='x y z'
  3341. DROP (a)    /* will drop x,y, and z */
  3342.  
  3343. If a stem is specified (that is, a symbol that contains only one period, as the 
  3344. last character), all variables starting with that stem are dropped. 
  3345.  
  3346. Example: 
  3347.  
  3348. Drop  x.
  3349. /* would reset all variables with names starting with X. */
  3350.  
  3351.  
  3352. ΓòÉΓòÉΓòÉ 10.6. EXIT ΓòÉΓòÉΓòÉ
  3353.  
  3354.  
  3355.  ΓöÇΓöÇΓöÇΓöÇEXITΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3356.               ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  3357.  
  3358. EXIT is used to leave a program unconditionally. Optionally, EXIT returns a 
  3359. data string to the caller. The program is terminated immediately, even if an 
  3360. internal routine is currently being run.  If no internal routine is active, 
  3361. RETURN and EXIT are identical in their effect on the program that is being run. 
  3362.  
  3363. If you specify expression, it is evaluated and the string resulting from the 
  3364. evaluation is then passed back to the caller when the program terminates. 
  3365.  
  3366. Example: 
  3367.  
  3368. j=3
  3369. Exit j*4
  3370. /* Would exit with the string '12' */
  3371.  
  3372. If you do not specify expression, no data is passed back to the caller. If the 
  3373. program was called as an external function, this is detected as an error, 
  3374. either immediately (if RETURN was used), or on return to the caller (if EXIT 
  3375. was used). 
  3376.  
  3377. "Running off the end" of the program is always equivalent to the EXIT 
  3378. instruction, in that it terminates the whole program and returns no result 
  3379. string. 
  3380.  
  3381. Note:   The language processor does not distinguish between invocation as a 
  3382.         command on the one hand, and invocation as a subroutine or function on 
  3383.         the other. If the program was invoked through a command interface, an 
  3384.         attempt is made to convert the returned value to a return code 
  3385.         acceptable by the REXX caller.  The returned string must be a whole 
  3386.         number whose value will fit in a 16-bit signed integer (within the 
  3387.         range -2**15 to 2**15-1). 
  3388.  
  3389.  
  3390. ΓòÉΓòÉΓòÉ 10.7. IF ΓòÉΓòÉΓòÉ
  3391.  
  3392.  ΓöÇΓöÇIFΓöÇexpressionΓöÇΓö¼ΓöÇΓö¼THENΓöÇΓö¼ΓöÇΓö¼instructionΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ
  3393.                    Γöö;Γöÿ     Γöö;Γöÿ            ΓööΓöÇELSEΓöÇΓö¼ΓöÇΓö¼instructionΓöÿ
  3394.                                                  Γöö;Γöÿ
  3395.  
  3396. IF is used to conditionally process an instruction or group of instructions 
  3397. depending on the evaluation of the expression. The expression must evaluate to 
  3398. 0 or 1. 
  3399.  
  3400. The instruction after the THEN is processed only if the result of the 
  3401. evaluation is 1. If you specify an ELSE clause, the instruction after ELSE is 
  3402. processed only if the result of the evaluation is 0. 
  3403.  
  3404. Example: 
  3405.  
  3406. if answer='YES' then say 'OK!'
  3407.                 else say 'Why not?'
  3408.  
  3409. Remember that if the ELSE clause is on the same line as the last clause of the 
  3410. THEN part, you need a semicolon to terminate that clause. 
  3411.  
  3412. Example: 
  3413.  
  3414. if answer='YES' then say 'OK!';  else say 'Why not?'
  3415.  
  3416. The ELSE binds to the nearest IF at the same level. The NOP instruction can be 
  3417. used to eliminate errors and possible confusion when IF constructs are nested, 
  3418. as in the following example. 
  3419.  
  3420. Example: 
  3421.  
  3422. If answer = 'YES' Then
  3423.    If name = 'FRED' Then
  3424.       say 'OK, Fred.'
  3425.    Else
  3426.       nop
  3427. Else
  3428.    say 'Why not?'
  3429.  
  3430. Notes: 
  3431.  
  3432.  1. The instruction can be any assignment, command, or keyword instruction, 
  3433.     including any of the more complex constructs such as DO, SELECT, or the IF 
  3434.     instruction itself. A null clause is not an instruction; so putting an 
  3435.     extra semicolon after the THEN or ELSE is not equivalent to putting a dummy 
  3436.     instruction (as it would be in C). The NOP instruction is provided for this 
  3437.     purpose. 
  3438.  
  3439.  2. The symbol THEN cannot be used within expression, because the keyword THEN 
  3440.     is treated differently, in that it need not start a clause.  This allows 
  3441.     the expression on the IF clause to be terminated by the THEN, without a 
  3442.     semicolon being required.  If this were not so, users of other computer 
  3443.     languages would experience considerable difficulties. 
  3444.  
  3445.  
  3446. ΓòÉΓòÉΓòÉ 10.8. INTERPRET ΓòÉΓòÉΓòÉ
  3447.  
  3448.  
  3449.  ΓöÇΓöÇΓöÇΓöÇINTERPRETΓöÇΓöÇΓöÇΓöÇexpressionΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3450.  
  3451. INTERPRET is used to process instructions that have been built dynamically by 
  3452. evaluating expression. 
  3453.  
  3454. The expression is evaluated, and is then processed (interpreted) as though the 
  3455. resulting string was a line inserted into the input file (and bracketed by a 
  3456. DO; and an END;). 
  3457.  
  3458. Any instructions (including INTERPRET instructions) are allowed, but note that 
  3459. constructions such as DO ... END and SELECT ... END must be complete. For 
  3460. example, a string of instructions being interpreted cannot contain a LEAVE or 
  3461. ITERATE instruction (valid only within a repetitive DO loop) unless it also 
  3462. contains the whole repetitive DO ... END construct. 
  3463.  
  3464. A semicolon is implied at the end of the expression during processing, as a 
  3465. service to the user. 
  3466.  
  3467. Example: 
  3468.  
  3469. data='FRED'
  3470. interpret data '= 4'
  3471. /* Will a) build the string  "FRED = 4"         */
  3472. /*      b) execute  FRED = 4;                   */
  3473. /* Thus the variable "FRED" will be set to "4"  */
  3474.  
  3475. Example: 
  3476.  
  3477. data='do 3; say "Hello there!"; end'
  3478. interpret data        /* Would display:         */
  3479.                       /*  Hello there!          */
  3480.                       /*  Hello there!          */
  3481.                       /*  Hello there!          */
  3482.  
  3483. Notes: 
  3484.  
  3485.  1. Labels within the interpreted string are not permanent and are therefore 
  3486.     ignored. Therefore, executing a SIGNAL instruction from within an 
  3487.     interpreted string causes immediate exit from that string before the label 
  3488.     search begins. 
  3489.  
  3490.  2. If you are new to the concept of the INTERPRET instruction and are getting 
  3491.     results that you do not understand, you might find that executing the 
  3492.     instruction with TRACE R or TRACE I set is helpful. 
  3493.  
  3494.     Example: 
  3495.  
  3496.         /* Here we have a small program. */
  3497.         Trace Int
  3498.         name='Kitty'
  3499.         indirect='name'
  3500.         interpret 'say "Hello"' indirect'"!"'
  3501.  
  3502.     when run, the following trace is displayed: 
  3503.  
  3504.         [C:\]kitty
  3505.         kitty
  3506.              3 *-* name='Kitty'
  3507.                >L>   "Kitty"
  3508.              4 *-* indirect='name'
  3509.                >L>   "name"
  3510.              5 *-* interpret 'say "Hello"' indirect'"!"'
  3511.                >L>   "say "Hello""
  3512.                >V>   "name"
  3513.                >O>   "say "Hello" name"
  3514.                >L>   ""!""
  3515.                >O>   "say "Hello" name"!""
  3516.                *-*  say "Hello" name"!"
  3517.                >L>    "Hello"
  3518.                >V>    "Kitty"
  3519.                >O>    "Hello Kitty"
  3520.                >L>    "!"
  3521.                >O>    "Hello Kitty!"
  3522.         Hello Kitty!
  3523.         [C:\]
  3524.  
  3525.     Lines 3 and 4 set the variables used in line 5. Execution of line 5 then 
  3526.     proceeds in two stages. First the string to be interpreted is built up, 
  3527.     using a literal string, a variable (INDIRECT), and another literal. The 
  3528.     resulting pure character string is then interpreted, as though it were 
  3529.     actually part of the original program. Since it is a new clause, it is 
  3530.     traced as such (the second *-* trace flag under line 5) and is then 
  3531.     executed. Again a literal string is concatenated to the value of a variable 
  3532.     (NAME) and another literal, and the final result is then displayed as 
  3533.     follows: 
  3534.  
  3535.         Hello Kitty!
  3536.  
  3537.  3. For many purposes, the VALUE function can be used instead of the INTERPRET 
  3538.     instruction.  Line 5 in the last example could therefore have been replaced 
  3539.     by: 
  3540.  
  3541.         say "Hello" value(indirect)"!"
  3542.  
  3543.     INTERPRET is usually only required in special cases, such as when more than 
  3544.     one statement is to be interpreted at once. 
  3545.  
  3546.  
  3547. ΓòÉΓòÉΓòÉ 10.9. ITERATE ΓòÉΓòÉΓòÉ
  3548.  
  3549.  ΓöÇΓöÇΓöÇΓöÇITERATEΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3550.                 ΓööΓöÇΓöÇnameΓöÇΓöÇΓöÿ
  3551.  
  3552. ITERATE is used to alter the flow within a repetitive DO loop (that is, any DO 
  3553. construct other than that with a simple DO loop). 
  3554.  
  3555. Processing of the group of instructions stops, and control is passed to the DO 
  3556. instruction just as though the END clause had been encountered. The control 
  3557. variable (if any) is incremented and tested, as normal, and the group of 
  3558. instructions is processed again, unless the loop is terminated by the DO 
  3559. instruction. 
  3560.  
  3561. If name is not specified, ITERATE steps the innermost active repetitive loop. 
  3562. If name is specified, it must be the name of the control variable of a 
  3563. currently active loop which may be the innermost loop; this is the loop that is 
  3564. stepped. Any active loops inside the one selected for iteration are terminated 
  3565. (as though by a LEAVE instruction). 
  3566.  
  3567. Example: 
  3568.  
  3569. do i=1 to 4
  3570.   if i=2 then iterate
  3571.   say i
  3572.   end
  3573. /* Would display the numbers:   1, 3, 4  */
  3574.  
  3575. Notes: 
  3576.  
  3577.  1. If specified, name must match the name on the DO instruction in all 
  3578.     respects except case. No substitution for compound variables is carried out 
  3579.     when the comparison is made. 
  3580.  
  3581.  2. A loop is active if it is currently being processed. If during execution of 
  3582.     a loop, a subroutine is called or an INTERPRET instruction is processed, 
  3583.     the loop becomes inactive until the subroutine has returned or the 
  3584.     INTERPRET instruction has completed. ITERATE cannot be used to step an 
  3585.     inactive loop. 
  3586.  
  3587.  3. If more than one active loop uses the same control variable, the innermost 
  3588.     loop is the one selected by ITERATE. 
  3589.  
  3590.  
  3591. ΓòÉΓòÉΓòÉ 10.10. LEAVE ΓòÉΓòÉΓòÉ
  3592.  
  3593.  ΓöÇΓöÇΓöÇΓöÇLEAVEΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3594.                 ΓööΓöÇΓöÇnameΓöÇΓöÇΓöÿ
  3595.  
  3596. LEAVE is used to cause an immediate exit from one or more repetitive DO loops 
  3597. (that is, any DO construct other than a simple DO loop). 
  3598.  
  3599. Processing of the group of instructions is terminated, and control is passed to 
  3600. the instruction following the END clause as though the END clause had been 
  3601. encountered and the termination condition had been met normally.  However, on 
  3602. exit, the control variable, if any, will contain the value it had when the 
  3603. LEAVE instruction was processed. 
  3604.  
  3605. If name is not specified, LEAVE terminates the innermost active repetitive 
  3606. loop. If name is specified, it must be the name of the control variable of a 
  3607. currently active loop which may be the innermost loop; that loop (and any 
  3608. active loops inside it) is then terminated. Control then passes to the clause 
  3609. following the END clause that matches the DO clause of the selected loop. 
  3610.  
  3611. Example: 
  3612.  
  3613. do i=1 to 5
  3614.   say i
  3615.   if i=3 then leave
  3616.   end
  3617. /* Would display the numbers:   1, 2, 3  */
  3618.  
  3619. Notes: 
  3620.  
  3621.  1. If specified, name must match the one on the DO instruction in all respects 
  3622.     except case. No substitution for compound variables is carried out when the 
  3623.     comparison is made. 
  3624.  
  3625.  2. A loop is active if it is currently being processed. If during execution of 
  3626.     a loop, a subroutine is called or an INTERPRET instruction is processed, 
  3627.     the loop becomes inactive until the subroutine has returned or the 
  3628.     INTERPRET instruction has completed. LEAVE cannot be used to terminate an 
  3629.     inactive loop. 
  3630.  
  3631.  3. If more than one active loop uses the same control variable, the innermost 
  3632.     one is the one selected by LEAVE. 
  3633.  
  3634.  
  3635. ΓòÉΓòÉΓòÉ 10.11. NOP ΓòÉΓòÉΓòÉ
  3636.  
  3637.  ΓöÇΓöÇΓöÇΓöÇNOPΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3638.  
  3639. NOP is a dummy instruction that has no effect.  It can be useful as the target 
  3640. of a THEN or ELSE clause. 
  3641.  
  3642. Example: 
  3643.  
  3644. Select
  3645.    when a=b then nop           /* Do nothing */
  3646.    when a>b then say 'A > B'
  3647.    otherwise     say 'A < B'
  3648. end
  3649.  
  3650. Note:   Using an extra semicolon instead of the NOP inserts a null clause, 
  3651.         which is ignored. The second WHEN clause is seen as the first 
  3652.         instruction expected after the THEN clause, and therefore is treated as 
  3653.         a syntax error. NOP is a true instruction, however, and is a valid 
  3654.         target for the THEN clause. 
  3655.  
  3656.  
  3657. ΓòÉΓòÉΓòÉ 10.12. NUMERIC ΓòÉΓòÉΓòÉ
  3658.  
  3659.  
  3660.  ΓöÇΓöÇNUMERICΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇDIGITSΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ;ΓöÇΓöÇ
  3661.                  Γöé         ΓööΓöÇexpressionΓöÇΓöÇΓöÿ         Γöé
  3662.                  Γö£ΓöÇΓöÇFORMΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ
  3663.                  Γöé        Γö£ΓöÇSCIENTIFICΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γöé
  3664.                  Γöé        Γö£ΓöÇENGINEERINGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γöé
  3665.                  Γöé        ΓööΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇexpressionΓöÇΓöÿ Γöé
  3666.                  Γöé          ΓööΓöÇVALUEΓöÇΓöÿ              Γöé
  3667.                  ΓööΓöÇΓöÇFUZZΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3668.                           ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  3669.  
  3670. The NUMERIC instruction is used to change the way in which arithmetic 
  3671. operations are carried out. The options of this instruction are described in 
  3672. detail in the OS/2 Procedures Language 2/REXX Reference. 
  3673.  
  3674. NUMERIC DIGITS controls the precision to which arithmetic operations and 
  3675. arithmetic built-in functions are evaluated. If expression is omitted, then the 
  3676. default value of 9 is used.  Otherwise the result of the expression is rounded, 
  3677. if necessary, according to the current setting of NUMERIC DIGITS. The value 
  3678. used must be a positive whole number that is larger than the current NUMERIC 
  3679. FUZZ setting. 
  3680.  
  3681. There is no limit to the value for DIGITS (except the amount of storage 
  3682. available), but note that high precisions are likely to require a good deal of 
  3683. processor time. It is recommended that you use the default value wherever 
  3684. possible. 
  3685.  
  3686. You can retrieve the current setting of NUMERIC DIGITS with the DIGITS built-in 
  3687. function 
  3688.  
  3689. NUMERIC FORM controls the form of exponential notation used by REXX for the 
  3690. result of arithmetic operations and arithmetic built-in functions. This may be 
  3691. either SCIENTIFIC (in which case only one, nonzero digit appears before the 
  3692. decimal point), or ENGINEERING (in which case the power of ten is always a 
  3693. multiple of three). The default is SCIENTIFIC. The FORM is set either directly 
  3694. by the subkeywords SCIENTIFIC or ENGINEERING or is taken from the result of 
  3695. evaluating the expression following VALUE. The result in this case must be 
  3696. either SCIENTIFIC or ENGINEERING. You can omit the subkeyword VALUE if the 
  3697. expression does not begin with a symbol or a literal string (for example, if it 
  3698. starts with a special character, such as an operator or parenthesis). 
  3699.  
  3700. You can retrieve the current setting of NUMERIC FORM with the FORM built-in 
  3701. function 
  3702.  
  3703. NUMERIC FUZZ controls how many digits, at full precision, are ignored during a 
  3704. numeric comparison operation. If expression is omitted, the default is 0 
  3705. digits.  Otherwise expression must evaluate to 0 or a positive whole number 
  3706. rounded, if necessary, according to the current setting of NUMERIC DIGITS 
  3707. before it is used. The value used must be a positive whole number that is 
  3708. smaller than the current NUMERIC DIGITS setting. 
  3709.  
  3710. FUZZ temporarily reduces the value of DIGITS by the FUZZ value before every 
  3711. numeric comparison operation. The numbers being compared are subtracted from 
  3712. each other under a precision of DIGITS minus FUZZ digits and this result is 
  3713. then compared with 0. 
  3714.  
  3715. You can retrieve the current NUMERIC FUZZ setting with the FUZZ built-in 
  3716. function 
  3717.  
  3718. Note:   The three numeric settings are automatically saved across subroutine 
  3719.         and internal function calls.  See the CALL instruction for more 
  3720.         details. 
  3721.  
  3722.  
  3723. ΓòÉΓòÉΓòÉ 10.13. OPTIONS ΓòÉΓòÉΓòÉ
  3724.  
  3725.  ΓöÇΓöÇΓöÇΓöÇOPTIONSΓöÇΓöÇΓöÇΓöÇΓöÇexpressionΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3726.  
  3727. OPTIONS is used to pass special requests or parameters to the language 
  3728. processor.  For example, they can be language processor options or they can 
  3729. define a special character set. 
  3730.  
  3731. The expression is evaluated, and the result is examined one word at a time.  If 
  3732. the words are recognized by the language processor, then they are obeyed. 
  3733. Words that are not recognized are ignored and assumed to be instructions to a 
  3734. different processor. 
  3735.  
  3736. The following words are recognized by the language processors: 
  3737.  
  3738. ETMODE            Specifies that literal strings containing double-byte 
  3739.                   character set (DBCS) characters can be used in the program. 
  3740.  
  3741. NOETMODE          Specifies that literal strings containing DBCS characters 
  3742.                   cannot be used in the program. NOETMODE is the default. 
  3743.  
  3744. EXMODE            Specifies that DBCS data in mixed strings is handled on a 
  3745.                   logical character basis by instructions, operators and 
  3746.                   functions. DBCS data integrity is maintained. 
  3747.  
  3748. NOEXMODE          Specifies that any data in strings is handled on a byte 
  3749.                   basis. The integrity of any DBCS characters might be lost. 
  3750.                   NOEXMODE is the default. 
  3751. Notes: 
  3752.  
  3753.  1. Because of the scanning procedures of the language processor, you are 
  3754.     advised to place an OPTIONS ETMODE instruction as the first instruction of 
  3755.     a program containing DBCS literal strings. 
  3756.  
  3757.  2. To ensure proper scanning of a program containing DBCS literals, type the 
  3758.     words ETMODE, NOETMODE, EXMODE, and NOEXMODE as literal strings (that is, 
  3759.     enclosed in quotation marks) in the OPTIONS instruction. 
  3760.  
  3761.  3. The OPTIONS ETMODE and OPTIONS EXMODE settings are saved and restored 
  3762.     across subroutine and function calls. 
  3763.  
  3764.  4. The words ETMODE, EXMODE, NOEXMODE, and NOETMODE can occur several times 
  3765.     within the result. The word that takes effect is determined by the last 
  3766.     valid one specified between the pairs ETMODE/NOETMODE and EXMODE/NOEXMODE. 
  3767.  
  3768.  
  3769. ΓòÉΓòÉΓòÉ 10.14. PARSE ΓòÉΓòÉΓòÉ
  3770.  
  3771.  
  3772.  ΓöÇΓöÇPARSEΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇARGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇ
  3773.            ΓööΓöÇUPPERΓöÇΓöÿ Γö£ΓöÇΓöÇPULLΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÿ
  3774.                      Γö£ΓöÇΓöÇSOURCEΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ      list
  3775.                      Γö£ΓöÇΓöÇVALUEΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇWITHΓöÇΓöñ
  3776.                      Γöé        ΓööΓöÇexpressionΓöÇΓöÿ      Γöé
  3777.                      Γö£ΓöÇΓöÇVARΓöÇΓöÇnameΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3778.                      ΓööΓöÇΓöÇVERSIONΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3779.  
  3780. PARSE is used to assign data from various sources to one or more variables 
  3781. according to the rules and templates described in the section on parsing in the 
  3782. OS/2 Procedures Language 2/REXX Reference. 
  3783.  
  3784. If specified, a template is a list of symbols separated by blanks or patterns. 
  3785.  
  3786. If template is not specified, no variables are set but action is taken to get 
  3787. the data ready for parsing if necessary. Thus, for PARSE PULL, a data string is 
  3788. removed from the current data queue; for PARSE LINEIN (and PARSE PULL if the 
  3789. current queue is empty), a line is taken from the default character input 
  3790. stream; and for PARSE VALUE, expression is evaluated. For PARSE VAR, the 
  3791. specified variable is accessed. If it does not have a value, the NOVALUE 
  3792. condition is raised, if it is enabled. 
  3793.  
  3794. If the UPPER option is specified, the data to be parsed is first translated to 
  3795. uppercase (for example, a lowercase a-z to an uppercase A-Z). Otherwise, no 
  3796. uppercase translation takes place during the parsing. 
  3797.  
  3798. The data used for each variant of the PARSE instruction is as follows: 
  3799.  
  3800. PARSE ARG - The strings passed to the program, subroutine, or function as the 
  3801. input argument list, are parsed. See the ARG instruction for details and 
  3802. examples. 
  3803.  
  3804. Note:   The argument strings to a REXX program or internal routine can also be 
  3805.         retrieved or checked by using the ARG built-in function. 
  3806.  
  3807. PARSE LINEIN - The next line from the default character input stream is parsed. 
  3808. (See the OS/2 Procedures Language 2/REXX Reference for a discussion of the REXX 
  3809. input model.) PARSE LINEIN is a shorter form of the following instruction: 
  3810.  
  3811.  
  3812.  ΓöÇΓöÇPARSEΓöÇVALUEΓöÇLINEIN()ΓöÇWITHΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇ
  3813.                                ΓööΓöÇtemplateΓöÇΓöÿ
  3814.  
  3815. If no line is available, program execution will normally pause until a line is 
  3816. complete. Note that PARSE LINEIN should only be used when direct access to the 
  3817. character input stream is necessary. Normal line-by-line dialogue with the user 
  3818. should be carried out with the PULL or PARSE PULL instructions, to maintain 
  3819. generality and programmability. 
  3820.  
  3821. To check if any lines are available in the default character input stream, use 
  3822. the built-in function LINES. 
  3823.  
  3824. PARSE PULL - The next string from the queue is parsed.  If the queue is empty, 
  3825. lines will be read from the default input, typically the user's keyboard.  You 
  3826. can add data to the head or tail of the queue by using the PUSH and QUEUE 
  3827. instructions respectively.  You can find the number of lines currently in the 
  3828. queue by using the QUEUED built-in function. The queue remains active as long 
  3829. as the language processor is active. The queue can be altered by other programs 
  3830. in the system and can be used as a means of communication between these 
  3831. programs and programs written in REXX. 
  3832.  
  3833. Note:   PULL and PARSE PULL read first from the current data queue; if the 
  3834.         queue is empty, they read from the default input stream, STDIN 
  3835.         (typically, the keyboard). 
  3836.  
  3837. PARSE SOURCE - The data parsed describes the source of the program being run. 
  3838.  
  3839. The source string contains the characters OS/2, followed by either COMMAND, 
  3840. FUNCTION, or SUBROUTINE, depending on whether the program was invoked as a host 
  3841. command or from a function call in an expression or using the CALL instruction. 
  3842. These two tokens are followed by the complete path specification of the program 
  3843. file. 
  3844.  
  3845. The string parsed might, therefore, be displayed as: 
  3846.  
  3847. OS/2 COMMAND C:\OS2\REXTRY.CMD
  3848.  
  3849. PARSE VALUE - The expression is evaluated, and the result is the data that is 
  3850. parsed. Note that WITH is a subkeyword in this context and so cannot be used as 
  3851. a symbol within expression.  For example: 
  3852.  
  3853. PARSE VALUE time() WITH  hours ':' mins ':' secs
  3854.  
  3855. gets the current time and splits it up into its constituent parts. 
  3856.  
  3857. PARSE VAR name - The value of the variable specified by name is parsed.  The 
  3858. name must be a symbol that is valid as a variable name; that is, it can not 
  3859. start with a period or a digit.  Note that the variable name is not changed 
  3860. unless it appears in the template. For example: 
  3861.  
  3862. PARSE VAR string word1 string
  3863.  
  3864. removes the first word from string and puts it in the variable word1, and 
  3865. assigns the remainder back to string.  Similarly: 
  3866.  
  3867. PARSE UPPER VAR string word1 string
  3868.  
  3869. also translates the data from string to uppercase before it is parsed. 
  3870.  
  3871. PARSE VERSION - Information describing the language level and the date of the 
  3872. language processor is parsed.  This consists of five words (delimited by 
  3873. blanks): first the string "REXXSAA", then the language level description 
  3874. ("4.00"), and finally the release date ("13 June 1989"). 
  3875.  
  3876. Note:   PARSE VERSION information should be parsed on a word basis rather than 
  3877.         on an absolute column position basis. 
  3878.  
  3879.  
  3880. ΓòÉΓòÉΓòÉ 10.15. PROCEDURE ΓòÉΓòÉΓòÉ
  3881.  
  3882.  
  3883.  ΓöÇΓöÇΓöÇPROCEDUREΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3884.                  Γöé          ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ Γöé
  3885.                  Γöé                 Γöé Γöé
  3886.                  ΓööΓöÇΓöÇEXPOSEΓöÇΓöÇΓö┤ΓöÇnameΓöÇΓöÇΓö┤ΓöÇΓöÿ
  3887.  
  3888. The PROCEDURE instruction can be used within an internal routine (subroutine or 
  3889. function) to protect all the existing variables by making them unknown to the 
  3890. instructions that follow. On executing a RETURN instruction, the original 
  3891. variables environment is restored and any variables used in the routine (which 
  3892. were not exposed) are dropped. 
  3893.  
  3894. The EXPOSE option modifies this.  Any variable specified by name is exposed, so 
  3895. that any reference to it (including setting and dropping) is made to the 
  3896. environment of the variables that the caller owns. With the EXPOSE option, you 
  3897. must specify at least one name, a symbol separated from any other name with one 
  3898. or more blanks. Optionally, you can enclose a single name in parentheses to 
  3899. denote a subsidiary variable list. Any variables not specified by name on a 
  3900. PROCEDURE EXPOSE instruction are still protected.  Hence, some limited set of 
  3901. the caller's variables can be made accessible, and these variables can be 
  3902. changed (or new variables in this set can be created).  All these changes will 
  3903. be visible to the caller upon RETURN from the routine. 
  3904.  
  3905. The variables are exposed in sequence from left to right. It is not an error to 
  3906. specify a name more than once, or to specify a name that has not been used as a 
  3907. variable by the caller. 
  3908.  
  3909. Example: 
  3910.  
  3911. /* This is the main program */
  3912. j=1; x.1='a'
  3913. call toft
  3914. say j k m       /* would display "1 7 M" */
  3915. exit
  3916.  
  3917. toft: procedure expose j k x.j
  3918.    say j k x.j  /* would display "1 K a"   */
  3919.    k=7; m=3     /* note "M" is not exposed */
  3920.    return
  3921.  
  3922. Note that if X.J in the EXPOSE list had been placed before J, the caller's 
  3923. value of J would not have been visible at that time, so X.1 would not have been 
  3924. exposed. 
  3925.  
  3926. If name is enclosed in parentheses (blanks are not necessary either inside or 
  3927. outside the parentheses but can be added if desired) then, after that variable 
  3928. is exposed, the value of the variable is immediately used as a subsidiary list 
  3929. of variables.  This list of variables must follow the same rules as the main 
  3930. list except that no parentheses or leading or trailing blanks are allowed. The 
  3931. variables named in a subsidiary list are also exposed from left to right. 
  3932.  
  3933. Example: 
  3934.  
  3935. j=1;k=6;m=9
  3936. a ='j k m'
  3937. test:procedure expose (a)   /* will expose j, k, and x */
  3938.  
  3939. If a stem is specified in names, all possible compound variables whose names 
  3940. begin with that stem are exposed. (A stem is a symbol containing only one 
  3941. period, which is the last character. 
  3942.  
  3943. Example: 
  3944.  
  3945. lucky7:Procedure Expose i j a. b.
  3946. /* This exposes "I", "J", and all variables whose */
  3947. /* names start with "A." or "B."                  */
  3948. A.1='7'  /* This will set "A.1" in the caller's   */
  3949.          /* environment, even if it did not       */
  3950.          /* previously exist.                     */
  3951.  
  3952. Variables can be exposed through several generations of routines, if desired, 
  3953. by ensuring that they are included on all intermediate PROCEDURE instructions. 
  3954.  
  3955. Only one PROCEDURE instruction in each level of routine call is allowed; all 
  3956. others (and those met outside of internal routines) are in error. 
  3957.  
  3958. Notes: 
  3959.  
  3960.  1. An internal routine need not include a PROCEDURE instruction, in which case 
  3961.     the variables it is manipulating are those the caller owns. 
  3962.  
  3963.  2. The PROCEDURE instruction must be the first instruction executed after the 
  3964.     CALL or function invocation, that is, it must be the first instruction 
  3965.     following the label. 
  3966.  
  3967. See the CALL instruction for details and examples of how routines are invoked. 
  3968.  
  3969.  
  3970. ΓòÉΓòÉΓòÉ 10.16. PULL ΓòÉΓòÉΓòÉ
  3971.  
  3972.  
  3973.  ΓöÇΓöÇΓöÇΓöÇPULLΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3974.                  ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÿ
  3975.  
  3976. PULL is used to read a string from the head of the currently active REXX data 
  3977. queue. It is a short form of the instruction: 
  3978.  
  3979.  ΓöÇΓöÇPARSE UPPER PULLΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇΓöÇΓöÇΓöÇ
  3980.                        ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÇΓöÿ
  3981.  
  3982. The current head-of-queue is read as one string.  If no template is specified, 
  3983. no further action is taken, and the string is effectively discarded.  If 
  3984. specified, a template is a list of symbols separated by blanks or patterns. The 
  3985. string is translated to uppercase (for example, a lowercase a-z to an uppercase 
  3986. A-Z), and then parsed into variables according to the rules described in the 
  3987. section on parsing in the OS/2 Procedures Language 2/REXX Reference.  Use the 
  3988. PARSE PULL instruction if you do not want uppercase translation. 
  3989.  
  3990. Note:   If the current data queue is empty, PULL reads instead from STDIN 
  3991.         (typically, the keyboard). The length of data read by the PULL 
  3992.         instruction is restricted to the length of strings contained by 
  3993.         variables. 
  3994.  
  3995. Example: 
  3996.  
  3997. Say 'Do you want to erase the file?  Answer Yes or No:'
  3998. Pull answer .
  3999. if answer='NO' then Say 'The file will not be erased.'
  4000.  
  4001. Here the dummy placeholder "." is used on the template to isolate the first 
  4002. word the user enters. 
  4003.  
  4004. The number of lines currently in the queue can be found with the QUEUED 
  4005. built-in function. 
  4006.  
  4007.  
  4008. ΓòÉΓòÉΓòÉ 10.17. PUSH ΓòÉΓòÉΓòÉ
  4009.  
  4010.  
  4011.  ΓöÇΓöÇΓöÇΓöÇPUSHΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4012.                  ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4013.  
  4014. PUSH is used to stack the string resulting from the evaluation of expression in 
  4015. LIFO (last in, first out) format onto the currently active REXX data queue. If 
  4016. you do not specify expression, a null string is stacked. 
  4017.  
  4018. Example: 
  4019.  
  4020. a='Fred'
  4021. push       /* Puts a null line onto the queue */
  4022. push a 2   /* Puts "Fred 2"    onto the queue */
  4023.  
  4024. The number of lines currently in the queue can be found with the QUEUED 
  4025. built-in function. 
  4026.  
  4027.  
  4028. ΓòÉΓòÉΓòÉ 10.18. QUEUE ΓòÉΓòÉΓòÉ
  4029.  
  4030.  ΓöÇΓöÇΓöÇΓöÇQUEUEΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4031.                  ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4032.  
  4033. QUEUE is used to append the string resulting from expression to the tail of the 
  4034. currently active REXX data queue. That is, it is added in FIFO (first in, first 
  4035. out) format. 
  4036.  
  4037. If you do not specify expression, a null string is queued. 
  4038.  
  4039. Example: 
  4040.  
  4041. a='Toft'
  4042. queue a 2  /* Enqueues "Toft 2" */
  4043. queue      /* Enqueues a null line behind the last */
  4044.  
  4045. The number of lines currently in the queue can be found with the QUEUED 
  4046. built-in function. 
  4047.  
  4048.  
  4049. ΓòÉΓòÉΓòÉ 10.19. RETURN ΓòÉΓòÉΓòÉ
  4050.  
  4051.  ΓöÇΓöÇΓöÇΓöÇRETURNΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4052.                  ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4053.  
  4054. RETURN is used to return control (and possibly a result) from a REXX program or 
  4055. internal routine to the point of its invocation. 
  4056.  
  4057. If no internal routine (subroutine or function) is active, RETURN and EXIT are 
  4058. identical in their effect on the program that is being run. 
  4059.  
  4060. If a subroutine is being processed (see the CALL instruction), expression (if 
  4061. any) is evaluated, control passes back to the caller, and the REXX special 
  4062. variable RESULT is set to the value of expression. If expression is omitted, 
  4063. the special variable RESULT is dropped (becomes uninitialized). The various 
  4064. settings saved at the time of the CALL (tracing, addresses, and so on) are also 
  4065. restored. 
  4066.  
  4067. If a function is being processed, the action taken is identical, except that 
  4068. expression must be specified on the RETURN instruction. The result of 
  4069. expression is then used in the original expression at the point where the 
  4070. function was invoked. 
  4071.  
  4072. If a PROCEDURE instruction was processed within the routine (subroutine or 
  4073. internal function), all variables of the current generation are dropped (and 
  4074. those of the previous generation are exposed) after expression is evaluated and 
  4075. before the result is used or assigned to RESULT. 
  4076.  
  4077.  
  4078. ΓòÉΓòÉΓòÉ 10.20. SAY ΓòÉΓòÉΓòÉ
  4079.  
  4080.  ΓöÇΓöÇΓöÇΓöÇSAYΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4081.                 ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4082.  
  4083. SAY is used to write to the output stream the result of evaluating expression. 
  4084. The result is usually displayed to the user, but the output destination can 
  4085. depend on the implementation. The result of expression can be of any length. 
  4086.  
  4087. Notes: 
  4088.  
  4089.  1. Data from the SAY instruction is sent to the default output stream 
  4090.     (STDOUT:) However, the standard OS/2 rules for redirecting output apply to 
  4091.     SAY output. 
  4092.  
  4093.  2. The SAY instruction does not format data; line wrapping is handled by the 
  4094.     operating system and the hardware. However formatting is accomplished, the 
  4095.     output data remains a single logical line. 
  4096.  
  4097. Example: 
  4098.  
  4099. data=100
  4100. Say data 'divided by 4 =>' data/4
  4101. /* Would display: "100 divided by 4 => 25"  */
  4102.  
  4103.  
  4104. ΓòÉΓòÉΓòÉ 10.21. SELECT ΓòÉΓòÉΓòÉ
  4105.  
  4106.  
  4107.              ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  4108.                                                        Γöé
  4109.  ΓöÇΓöÇSELECT;ΓöÇΓö┤WHENΓöÇexpressionΓöÇΓö¼ΓöÇΓö¼ΓöÇTHENΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇinstructionΓö┤ΓöÇΓöÇ
  4110.                               Γöö;Γöÿ      Γöö;Γöÿ
  4111.  
  4112.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇEND;ΓöÇΓöÇΓöÇΓöÇΓöÇ
  4113.         ΓööΓöÇOTHERWISEΓöÇΓö¼ΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  4114.                     Γöö;Γöÿ Γöé  ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ  Γöé
  4115.                         Γöé               Γöé  Γöé
  4116.                         ΓööΓöÇΓöÇΓö┤ΓöÇinstructionΓöÇΓö┤ΓöÇΓöÇΓöÿ
  4117.  
  4118. SELECT is used to conditionally process one of several alternative 
  4119. instructions. 
  4120.  
  4121. Each expression after a WHEN clause is evaluated in turn and must result in 0 
  4122. or 1. If the result is 1, the instruction following the THEN clause, which can 
  4123. be a complex instruction such as IF, DO, or SELECT, is processed and control 
  4124. then passes to the END clause. If the result is 0, control passes to the next 
  4125. WHEN clause. 
  4126.  
  4127. If none of the WHEN expressions evaluate to 1, control passes to the 
  4128. instructions, if any, after OTHERWISE. In this situation, the absence of 
  4129. OTHERWISE causes an error. 
  4130.  
  4131. Example: 
  4132.  
  4133.   balance = balance - check
  4134.   Select
  4135.     when balance > 0 then
  4136.       say 'Congratulations! You still have' balance 'dollars left.'
  4137.     when balance = 0 then do
  4138.       say 'Warning, Balance is now zero!  STOP all spending.'
  4139.       say "You cut it close this month! Hope you don't have any"
  4140.       say "checks left outstanding."
  4141.       end
  4142.     Otherwise
  4143.       say "You have just overdrawn your account."
  4144.       say "Your balance now shows" balance "dollars."
  4145.       say "Oops!  Hope the bank doesn't close your account."
  4146.   end  /* Select */
  4147.  
  4148. Notes: 
  4149.  
  4150.  1. The instruction can be any assignment, command, or keyword instruction, 
  4151.     including any of the more complex constructs such as DO, IF, or the SELECT 
  4152.     instruction itself. 
  4153.  
  4154.  2. A null clause is not an instruction, so putting an extra semicolon after a 
  4155.     WHEN clause is not equivalent to putting a dummy instruction. The NOP 
  4156.     instruction is provided for this purpose. 
  4157.  
  4158.  3. The symbol THEN cannot be used within expression, because the keyword THEN 
  4159.     is treated differently, in that it need not start a clause.  This allows 
  4160.     the expression on the WHEN clause to be terminated by the THEN without a ; 
  4161.     (delimiter) being required. 
  4162.  
  4163.  
  4164. ΓòÉΓòÉΓòÉ 10.22. SIGNAL ΓòÉΓòÉΓòÉ
  4165.  
  4166.  
  4167.  ΓöÇΓöÇSIGNALΓöÇΓöÇΓöÇΓö¼ΓöÇ labelname ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇ
  4168.               Γö£ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ expression ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4169.               Γöé Γöö VALUE Γöÿ                            Γöé
  4170.               Γö£ΓöÇΓöÇ OFF ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ ERROR ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4171.               Γöé           Γö£ΓöÇ FAILURE ΓöÇΓöÇΓöÇΓöñ            Γöé
  4172.               Γöé           Γö£ΓöÇ HALT ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  4173.               Γöé           Γö£ΓöÇ NOVALUE ΓöÇΓöÇΓöÇΓöñ            Γöé
  4174.               Γöé           Γö£ΓöÇ SYNTAX ΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  4175.               Γöé           ΓööΓöÇ NOTREADY ΓöÇΓöÇΓöÿ            Γöé
  4176.               Γöé                                      Γöé
  4177.               ΓööΓöÇ ON ΓöÇΓö¼ΓöÇ ERROR ΓöÇΓöÇΓöÇΓö¼Γö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  4178.                      Γö£ΓöÇ FAILURE ΓöÇΓöñΓöö NAME ΓöÇ trapname Γöÿ
  4179.                      Γö£ΓöÇ HALT ΓöÇΓöÇΓöÇΓöÇΓöñ
  4180.                      Γö£ΓöÇ NOVALUE ΓöÇΓöñ
  4181.                      Γö£ΓöÇ SYNTAX ΓöÇΓöÇΓöñ
  4182.                      ΓööΓöÇ NOTREADY Γöÿ
  4183.  
  4184. SIGNAL is used to cause an abnormal change in the flow of control, or, if ON or 
  4185. OFF is specified, controls the trapping of certain conditions. 
  4186.  
  4187. To control trapping, you specify OFF or ON and the condition you want to trap. 
  4188. OFF turns off the specified condition trap.  ON turns on the specified 
  4189. condition trap. 
  4190.  
  4191. Note:   For information on condition traps, see the OS/2 Procedures Language 
  4192.         2/REXX Reference. 
  4193.  
  4194. To change the flow of control, a label name is derived from labelname or taken 
  4195. from the result of evaluating the expression after VALUE. The labelname you 
  4196. specify must be a symbol, treated literally, or a literal string that is taken 
  4197. as a constant. The subkeyword VALUE can be omitted if expression does not begin 
  4198. with a symbol or literal string (for example, if it starts with a special 
  4199. character, such as an operator or parenthesis).  All active pending DO, IF, 
  4200. SELECT, and INTERPRET instructions in the current routine are then terminated; 
  4201. that is, they cannot be reactivated. Control then passes to the first label in 
  4202. the program that matches the required string, as though the search had started 
  4203. from the top of the program. 
  4204.  
  4205. Example: 
  4206.  
  4207. Signal fred;  /* Jump to label "FRED" below */
  4208.   ....
  4209.   ....
  4210. Fred: say 'Hi!'
  4211.  
  4212. Because the search effectively starts at the top of the program, if duplicates 
  4213. are present, control always passes to the first occurrence of the label in the 
  4214. program 
  4215.  
  4216. When control reaches the specified label, the line number of the SIGNAL 
  4217. instruction is assigned to the special variable SIGL. This can aid debugging 
  4218. because SIGNAL can determine the source of a jump to a label. 
  4219.  
  4220. Using SIGNAL with the INTERPRET Instruction 
  4221.  
  4222. If, as the result of an INTERPRET instruction, a SIGNAL instruction is issued 
  4223. or a trapped event occurs, the remainder of the strings being interpreted are 
  4224. not searched for the given label. In effect, labels within interpreted strings 
  4225. are ignored. 
  4226.  
  4227.  
  4228. ΓòÉΓòÉΓòÉ 10.23. TRACE ΓòÉΓòÉΓòÉ
  4229.  
  4230.  
  4231. ΓöÇ TRACE ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇ
  4232.            Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ    ΓööΓöÇ number ΓöÇΓöÿ        Γöé
  4233.            Γöé            Γöé                        Γöé
  4234.            ΓööΓöÇΓö┤ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö┤ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4235.                ΓööΓöÇΓöÇΓöÇ?ΓöÇΓöÇΓöÇΓöÿ   Γö£ΓöÇΓöÇ All ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4236.                            Γö£ΓöÇΓöÇ Commands ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4237.                            Γö£ΓöÇΓöÇ Error ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4238.                            Γö£ΓöÇΓöÇ Failure ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4239.                            Γö£ΓöÇΓöÇ Intermediates ΓöÇΓöÇΓöÇΓöñ
  4240.                            Γö£ΓöÇΓöÇ Labels ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4241.                            Γö£ΓöÇΓöÇ Normal ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4242.                            Γö£ΓöÇΓöÇ Off ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4243.                            ΓööΓöÇΓöÇ Results ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  4244.  
  4245. Or, alternatively: 
  4246.  
  4247.  
  4248. ΓöÇΓöÇTRACEΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4249.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇstringΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4250.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇsymbolΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4251.             ΓööΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇexpressionΓöÇΓöÇΓöÇΓöÿ
  4252.                ΓööΓöÇVALUEΓöÇΓöÿ
  4253.  
  4254. TRACE is used for debugging.  It controls the tracing action taken (that is, 
  4255. how much is displayed to the user) during execution of a REXX program.  The 
  4256. syntax of TRACE is more concise than other REXX instructions.  The economy of 
  4257. key strokes for this instruction is especially convenient since TRACE is 
  4258. usually entered manually during interactive debugging. 
  4259.  
  4260. The number is a whole number. 
  4261.  
  4262. The string or expression evaluates to: 
  4263.  
  4264. o A number option 
  4265. o One of the valid prefix, alphabetic character (word) options, or both, shown 
  4266.   in this panel 
  4267. o Null. 
  4268.  
  4269. The symbol is taken as a constant and is: 
  4270.  
  4271. o A number option 
  4272. o One of the valid prefix, alphabetic character (word) options, or both, shown 
  4273.   in this panel. 
  4274.  
  4275. The tracing action is determined from the option specified following TRACE or 
  4276. from the result of evaluating expression. If expression is used, you can omit 
  4277. the subkeyword VALUE as long as expression starts with a special character or 
  4278. operator (so it is not mistaken for a symbol or string). 
  4279.  
  4280. Alphabetic Character (Word) Options 
  4281.  
  4282. Although it is acceptable to enter the word in full, only the uppercase letter 
  4283. is significant; all other letters are ignored. That is why these are referred 
  4284. to as alphabetic character options. 
  4285.  
  4286. TRACE actions correspond to the alphabetic character options as follows: 
  4287.  
  4288. All                   All clauses are traced (that is, displayed) before 
  4289.                       execution. 
  4290.  
  4291. Commands              All host commands are traced before execution, and any 
  4292.                       error return code is displayed. 
  4293.  
  4294. Error                 Any host command resulting in an error return code is 
  4295.                       traced after execution. 
  4296.  
  4297. Failure               Any host command resulting in a failure is traced after 
  4298.                       execution. This is the same as the Normal option. 
  4299.  
  4300. Intermediates         All clauses are traced before execution. Intermediate 
  4301.                       results during evaluation of expressions and substituted 
  4302.                       names are also traced. 
  4303.  
  4304. Labels                Labels passed during execution are traced. This is 
  4305.                       especially useful with debug mode, when the language 
  4306.                       processor pauses after each label.  It is also convenient 
  4307.                       for the user to make note of all subroutine calls and 
  4308.                       signals. 
  4309.  
  4310. Normal                Any failing host command is traced after execution. This 
  4311.                       is the default setting. 
  4312.  
  4313.                       For the default CMD processor in the OS/2 operating 
  4314.                       system, an attempt to issue an unknown command raises a 
  4315.                       FAILURE condition. An attempt to issue a command to an 
  4316.                       unknown subcommand environment also raises a FAILURE 
  4317.                       condition; in such a case, the variable RC is set to 2, 
  4318.                       the OS/2 return code for "file not found". 
  4319.  
  4320. Off                   Nothing is traced, and the special prefix actions (see 
  4321.                       below) are reset to OFF. 
  4322.  
  4323. Results               All clauses are traced before execution.  Final results 
  4324.                       (contrast with Intermediates, above) of evaluating an 
  4325.                       expression are traced.  Values assigned during PULL, ARG, 
  4326.                       and PARSE instructions are also displayed.  This setting 
  4327.                       is recommended for general debugging. 
  4328.  
  4329. Prefix Option 
  4330.  
  4331. The prefix ? is valid either alone or with one of the alphabetic character 
  4332. options. You can specify the prefix more than once, if desired.  Each 
  4333. occurrence of a prefix on an instruction reverses the action of the previous 
  4334. prefix. The prefix must immediately precede the option (no intervening blanks). 
  4335.  
  4336. The prefix ? modifies tracing and execution.  ? is used to control interactive 
  4337. debug. During normal execution, a TRACE instruction prefixed with ? causes 
  4338. interactive debug to be switched on. 
  4339.  
  4340. When interactive debug is in effect, you can switch it off by issuing a TRACE 
  4341. instruction with a prefix ?.  Repeated use of the ? prefix, therefore, switchs 
  4342. you alternately in and out of interactive debug. Or, interactive debug can be 
  4343. turned off at any time by issuing TRACE O or TRACE with no options. 
  4344.  
  4345. Numeric Options 
  4346.  
  4347. If interactive debug is active and if the option specified is a positive whole 
  4348. number (or an expression that evaluates to a positive whole number), that 
  4349. number indicates the number of debug pauses to be skipped over. However, if the 
  4350. option is a negative whole number (or an expression that evaluates to a 
  4351. negative whole number), all tracing, including debug pauses, is temporarily 
  4352. inhibited for the specified number of clauses. 
  4353.  
  4354. If interactive debug is not active, numeric options are ignored. 
  4355.  
  4356. Format of TRACE Output 
  4357.  
  4358. Every clause traced will be displayed with automatic formatting (indentation) 
  4359. according to its logical depth of nesting and so on, and the results (if 
  4360. requested) are indented an extra two spaces and are enclosed in double 
  4361. quotation marks so that leading and trailing blanks are apparent. 
  4362.  
  4363. All lines displayed during tracing have a three-character prefix to identify 
  4364. the type of data being traced.  The prefixes and their definitions are the 
  4365. following: 
  4366.  
  4367. *-*       Identifies the source of a single clause, that is, the data actually 
  4368.           in the program. 
  4369.  
  4370. +++       Identifies a trace message.  This can be the nonzero return code from 
  4371.           a command, the prompt message when interactive debug is entered, an 
  4372.           indication of a syntax error when in interactive debug, or the 
  4373.           traceback clauses after a syntax error in the program. 
  4374.  
  4375. >>>       Identifies the result of an expression (for TRACE R) or the value 
  4376.           assigned to a variable during parsing, or the value returned from a 
  4377.           subroutine call. 
  4378.  
  4379. >.>       Identifies the value assigned to a placeholder during parsing. 
  4380.  
  4381. The following prefixes are only used if Intermediates (TRACE I) are being 
  4382. traced: 
  4383.  
  4384. >C>       The data traced is the name of a compound variable, traced after 
  4385.           substitution and before use, provided that the name had the value of 
  4386.           a variable substituted into it. 
  4387.  
  4388. >F>       The data traced is the result of a function call. 
  4389.  
  4390. >L>       The data traced is a literal (string, uninitialized variable, or 
  4391.           constant symbol). 
  4392.  
  4393. >O>       The data traced is the result of an operation on two terms. 
  4394.  
  4395. >P>       The data traced is the result of a prefix operation. 
  4396.  
  4397. >V>       The data traced is the contents of a variable. 
  4398.  
  4399.  
  4400. ΓòÉΓòÉΓòÉ 11. Functions ΓòÉΓòÉΓòÉ
  4401.  
  4402. Syntax 
  4403.  
  4404. You can include function calls to internal and external routines in an 
  4405. expression anywhere that a data term (such as a string) would be valid, using 
  4406. the notation: 
  4407.  
  4408.  ΓöÇΓöÇfunctionΓöÇname(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  4409.  
  4410.                     Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ Γöé
  4411.                     Γöé               Γöé Γöé
  4412.                     ΓööΓöÇΓö┤Γö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γö┤ΓöÇΓöÿ
  4413.                        ΓööΓöÇexpressionΓöÇΓöÿ
  4414.  
  4415. function-name is a literal string or a single symbol, that is taken to be a 
  4416. constant. 
  4417.  
  4418. There can be up to a maximum of 20 expressions, separated by commas, between 
  4419. the parentheses. These expressions are called the arguments to the function. 
  4420. Each argument expression may include further function calls. 
  4421.  
  4422. The ( must be adjacent to the name of the function, with no blank in between, 
  4423. or the construct is not recognized as a function call. (A blank operator is 
  4424. assumed at this point instead.) 
  4425.  
  4426. The arguments are evaluated in turn from left to right and they are all then 
  4427. passed to the function. This then executes some operation (usually dependent on 
  4428. the argument strings passed, though arguments are not mandatory) and eventually 
  4429. returns a single character string. This string is then included in the original 
  4430. expression as though the entire function reference had been replaced by the 
  4431. name of a variable that contained that data. 
  4432.  
  4433. For example, the function SUBSTR is built-in to the language processor and 
  4434. could be used as: 
  4435.  
  4436. N1='abcdefghijk'
  4437. Z1='Part of N1 is: 'Substr(N1,2,7)
  4438. /* would set Z1 to 'Part of N1 is: bcdefgh' */
  4439.  
  4440. A function call without any arguments must always include the parentheses to be 
  4441. recognized as a function call. 
  4442.  
  4443. date()  /* returns the date in the default format dd mon yyyy */
  4444.  
  4445. Calls to Functions and Subroutines 
  4446.  
  4447. The mechanism for calling functions and subroutines is the same. The only 
  4448. difference is that functions must return data, whereas subroutines need not. 
  4449. The following types of routines can be called as functions: 
  4450.  
  4451. Internal  If the routine name exists as a label in the program, the current 
  4452.           processing status is saved, so that it will later be possible to 
  4453.           return to the point of invocation to resume processing. Control is 
  4454.           then passed to the first label in the program that matches the name. 
  4455.           As with a routine invoked by the CALL instruction, various other 
  4456.           pieces of status information (TRACE and NUMERIC settings and so on) 
  4457.           are also saved. See the CALL instruction for details of this. If an 
  4458.           internal routine is to be called as a function, you must specify an 
  4459.           expression in any RETURN instruction to return from the function. 
  4460.           This is not necessary if the function is called only as a subroutine. 
  4461.  
  4462.           Example: 
  4463.  
  4464.                     /* Recursive internal function execution... */
  4465.                     arg x
  4466.                     say x'! =' factorial(x)
  4467.                     exit
  4468.  
  4469.                     factorial: procedure   /* calculate factorial by..  */
  4470.                       arg n                /*  .. recursive invocation. */
  4471.                       if n=0 then return 1
  4472.                       return  factorial(n-1) * n
  4473.  
  4474.           FACTORIAL is unusual in that it invokes itself (this is known as 
  4475.           recursive invocation).  The PROCEDURE instruction ensures that a new 
  4476.           variable n is created for each invocation). 
  4477.  
  4478. Built-in  These functions are always available and are defined later in this 
  4479.           section. 
  4480.  
  4481. External  You can write or make use of functions that are external to a program 
  4482.           and to the language processor. An external function can be written in 
  4483.           any language, including REXX, that supports the system-dependent 
  4484.           interfaces used by the language processor to invoke it. Again, when 
  4485.           called as a function, it must return data to the caller. 
  4486.  
  4487. Notes: 
  4488.  
  4489.  1. Calling an external REXX program as a function is similar to calling an 
  4490.     internal routine.  The external routine is, however, an implicit PROCEDURE 
  4491.     in that all the caller variables are always hidden and the status of 
  4492.     internal values (NUMERIC settings and so on) start with their defaults 
  4493.     (rather than inheriting those of the caller). 
  4494.  
  4495.  2. Other REXX programs can be called as functions. You can use either EXIT or 
  4496.     RETURN to leave the invoked REXX program; in either case, you must specify 
  4497.     an expression. 
  4498.  
  4499. Search Order 
  4500.  
  4501. The search order for functions is the same as in the preceding list. That is, 
  4502. internal labels take first precedence, then built-in functions, and finally 
  4503. external functions. 
  4504.  
  4505. Internal labels are not used if the function name is given as a string (that 
  4506. is, is specified in quotation marks); in this case the function must be 
  4507. built-in or external. This lets you usurp the name of, for example, a built-in 
  4508. function to extend its capabilities, but still be able to invoke the built-in 
  4509. function when needed. 
  4510.  
  4511. Example: 
  4512.  
  4513. /* Modified DATE to return sorted date by default */
  4514. date: procedure
  4515.       arg in
  4516.       if in='' then in='Sorted'
  4517.       return 'DATE'(in)
  4518.  
  4519. Built-in functions have names in uppercase letters.  The name in the literal 
  4520. string must be in uppercase for the search to succeed, as in the example.  The 
  4521. same is usually true of external functions. 
  4522.  
  4523. External functions and subroutines have a system-defined search order. 
  4524.  
  4525. REXX searches for external functions in the following order: 
  4526.  
  4527.  1. Functions that have been loaded into the macrospace for pre-order execution 
  4528.  2. Functions that are part of a function package. 
  4529.  3. REXX functions in the current directory, with the current extension 
  4530.  4. REXX functions along environment PATH, with the current extension 
  4531.  5. REXX functions in the current directory, with the default extension 
  4532.  6. REXX functions along environment PATH, with the default extension 
  4533.  7. Functions that have been loaded into the macrospace for post-order 
  4534.     execution. 
  4535.  
  4536. Errors during Execution 
  4537.  
  4538. If an external or built-in function detects an error of any kind, the language 
  4539. processor is informed, and a syntax error results.  Processing of the clause 
  4540. that included the function call is therefore terminated. Similarly, if an 
  4541. external function fails to return data correctly, this is detected by the 
  4542. language processor and reported as an error. 
  4543.  
  4544. If a syntax error occurs during the processing of an internal function, it can 
  4545. be trapped (using SIGNAL ON SYNTAX) and recovery may then be possible. If the 
  4546. error is not trapped, the program is terminated. 
  4547.  
  4548. Return Values 
  4549.  
  4550. A function normally returns a value that is substituted for the function call 
  4551. when the expression is evaluated. 
  4552.  
  4553. How the value returned by a function (or any REXX routine) is handled depends 
  4554. on whether it is called by a function call or called as a subroutine with the 
  4555. CALL instruction. 
  4556.  
  4557. A routine called as a subroutine: If the routine returns a value, that value is 
  4558. stored in the special variable named RESULT. Otherwise, the RESULT variable is 
  4559. dropped, and its value is the string "RESULT". 
  4560.  
  4561. A routine called as a function: If the function returns a value, that value is 
  4562. substituted into the expression at the position where the function was called. 
  4563. Otherwise, REXX stops with an error message. 
  4564.  
  4565. Examples: 
  4566.  
  4567.  
  4568. /* Different ways to call a REXX procedure */
  4569. call Beep 500, 100         /* Example 1: a subroutine call */
  4570. bc = Beep(500, 100)        /* Example 2: a function call   */
  4571. Beep(500, 100)             /* Example 3: result passed as  */
  4572.                            /*            a command         */
  4573.  
  4574. o In Example 1, the built-in function BEEP is called as a REXX subroutine. The 
  4575.   return value from BEEP is placed in the REXX special variable RESULT. 
  4576.  
  4577. o Example 2 shows BEEP called as a REXX function. The return value from the 
  4578.   function is substituted for the function call. The clause itself is an 
  4579.   assignment instruction; the return value from the BEEP function is placed in 
  4580.   the variable bc. 
  4581.  
  4582. o In Example 3, the BEEP function is processed and its return value is 
  4583.   substituted in the expression for the function call, just as in Example 2. In 
  4584.   this case, however, the clause as a whole evaluates to a single expression; 
  4585.   therefore the evaluated expression is passed to the current default 
  4586.   environment as a command. 
  4587.  
  4588.   Note:   Many other languages (such as C) throw away the return value of a 
  4589.           function if it is not assigned to a variable. In REXX, however, a 
  4590.           value returned as in Example 3 is passed on to the current 
  4591.           environment or subcommand handler. If that environment is CMD (the 
  4592.           default), then this action will result in the operating system 
  4593.           performing a disk search for what seems to be a command. 
  4594.  
  4595.  
  4596. Built-in Functions 
  4597.  
  4598. REXX provides a rich set of built-in functions. These include character 
  4599. manipulation, conversion, and information functions. 
  4600.  
  4601. Here are some general notes on the built-in functions: 
  4602.  
  4603. o The parentheses in a function are always needed, even if no arguments are 
  4604.   required. The first parenthesis must follow the name of the function with no 
  4605.   space in between. 
  4606.  
  4607. o The built-in functions work internally with NUMERIC DIGITS 9 and NUMERIC FUZZ 
  4608.   0 and are unaffected by changes to the NUMERIC settings, except where stated. 
  4609.  
  4610. o You can supply a null string where a string is referenced. 
  4611.  
  4612. o If an argument specifies a length, it must be a nonnegative whole number. If 
  4613.   it specifies a start character or word in a string, it must be a positive 
  4614.   whole number, unless otherwise stated. 
  4615.  
  4616. o Where the last argument is optional, you can always include a comma to 
  4617.   indicate that you have omitted it; for example, DATATYPE(1,), like 
  4618.   DATATYPE(1), would return NUM. 
  4619.  
  4620. o If you specify a pad character, it must be exactly one character long. 
  4621.  
  4622. o If a function has a suboption you can select by specifying the first 
  4623.   character of a string, that character can be in uppercase or lowercase 
  4624.   letters. 
  4625.  
  4626. o Conversion between characters and hexadecimal involves the machine 
  4627.   representation of character strings, and hence returns appropriately 
  4628.   different results for ASCII and EBCDIC machines. 
  4629.  
  4630. o A number of the functions described in this chapter support the 
  4631.   double-byte-character-set (DBCS).  A complete list and description of these 
  4632.   functions is given in the OS/2 Procedures Language 2/REXX Reference. 
  4633.  
  4634.  
  4635. ΓòÉΓòÉΓòÉ 11.1. ABBREV ΓòÉΓòÉΓòÉ
  4636.  
  4637.  ΓöÇΓöÇABBREV(information,info ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4638.                               ΓööΓöÇ,lengthΓöÇΓöÇΓöÿ
  4639.  
  4640. ABBREV returns 1 if info is equal to the leading characters of information and 
  4641. the length of info is not less than length. ABBREV returns 0 if neither of 
  4642. these conditions is met. 
  4643.  
  4644. If specified, length must be a nonnegative whole number. The default for length 
  4645. is the number of characters in info. 
  4646.  
  4647. Here are some examples: 
  4648.  
  4649. ABBREV('Print','Pri')      ->    1
  4650. ABBREV('PRINT','Pri')      ->    0
  4651. ABBREV('PRINT','PRI',4)    ->    0
  4652. ABBREV('PRINT','PRY')      ->    0
  4653. ABBREV('PRINT','')         ->    1
  4654. ABBREV('PRINT','',1)       ->    0
  4655.  
  4656. Note:   A null string will always match if a length of 0 (or the default) is 
  4657.         used. This allows a default keyword to be selected automatically if 
  4658.         desired. For example: 
  4659.  
  4660.                 say 'Enter option:';   pull option .
  4661.                 select  /* keyword1 is to be the default */
  4662.                   when abbrev('keyword1',option) then ...
  4663.                   when abbrev('keyword2',option) then ...
  4664.                   ...
  4665.                   otherwise nop;
  4666.                 end;
  4667.  
  4668.  
  4669. ΓòÉΓòÉΓòÉ 11.2. ABS (Absolute Value) ΓòÉΓòÉΓòÉ
  4670.  
  4671.  ΓöÇΓöÇABS(number)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4672.  
  4673. ABS returns the absolute value of number. The result has no sign and is 
  4674. formatted according to the current NUMERIC settings. 
  4675.  
  4676. Here are some examples: 
  4677.  
  4678. ABS('12.3')       ->    12.3
  4679. ABS(' -0.307')    ->    0.307
  4680.  
  4681.  
  4682. ΓòÉΓòÉΓòÉ 11.3. ADDRESS ΓòÉΓòÉΓòÉ
  4683.  
  4684.  ΓöÇΓöÇADDRESS()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4685.  
  4686. ADDRESS returns the name of the environment to which host commands are 
  4687. currently being submitted.  Trailing blanks are removed from the result. 
  4688.  
  4689. Here are some examples: 
  4690.  
  4691. ADDRESS( )    ->    'CMD'        /* OS/2 environment */
  4692. ADDRESS( )    ->    'EDIT'      /* possible editor */
  4693.  
  4694.  
  4695. ΓòÉΓòÉΓòÉ 11.4. API Functions ΓòÉΓòÉΓòÉ
  4696.  
  4697. The following built-in REXX functions can be used in a REXX program to 
  4698. register, drop, or query external function packages and to create and 
  4699. manipulate external data queues. 
  4700.  
  4701. RXFUNCADD 
  4702.  
  4703.  ΓöÇRXFUNCADD(name,module,procedure)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4704.  
  4705. RXFUNCADD registers the function name, making it available to REXX procedures. 
  4706. A zero return value signifies successful registration. 
  4707.  
  4708. RXFUNCDROP 
  4709.  
  4710.  ΓöÇRXFUNCDROP(name)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4711.  
  4712. RXFUNCDROP removes (deregisters) the function name from the list of available 
  4713. functions. A zero return value signifies successful removal. 
  4714.  
  4715. RXFUNCQUERY 
  4716.  
  4717.  ΓöÇRXFUNCQUERY(name)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4718.  
  4719. RXFUNCQUERY queries the list of available functions for a registration of the 
  4720. name function. The function returns a value of 0 if the function is registered, 
  4721. and a value of 1 if it is not. 
  4722.  
  4723. RXQUEUE 
  4724.  
  4725.  ΓöÇΓöÇRXQUEUE(ΓöÇΓö¼ΓöÇΓöÇ"Get"ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  4726.               Γö£ΓöÇΓöÇ"Set"ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇnewqueuenameΓöÇΓöñ
  4727.               Γö£ΓöÇΓöÇ"Delete"ΓöÇΓöÇΓöÇqueuenameΓöÇΓöÇΓöÇΓöÇΓöñ
  4728.               ΓööΓöÇΓöÇ"Create"ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4729.                           ΓööΓöÇ,queuenameΓöÇΓöÇΓöÇΓöÿ
  4730.  
  4731. RXQUEUE is used in a REXX program to create and delete external data queues and 
  4732. to set and query their names. 
  4733.  
  4734.  
  4735. ΓòÉΓòÉΓòÉ 11.5. ARG ΓòÉΓòÉΓòÉ
  4736.  
  4737.  ΓöÇΓöÇARG(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4738.           ΓööΓöÇnΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÿ
  4739.                ΓööΓöÇ,optionΓöÇΓöÇΓöÇΓöÿ
  4740.  
  4741. ARG returns an argument string, or information about the argument strings to a 
  4742. program or internal routine. 
  4743.  
  4744. If you do not specify a parameter, the number of arguments passed to the 
  4745. program or internal routine is returned. 
  4746.  
  4747. If only n is specified, the n th argument string is returned. If the argument 
  4748. string does not exist, the null string is returned. n must be a positive whole 
  4749. number. 
  4750.  
  4751. If you specify option, ARG tests for the existence of the n th argument string. 
  4752. Valid options (of which only the capitalized letter is significant and all 
  4753. others are ignored) are: 
  4754.  
  4755. Exists      Returns 1 if the n th argument exists; that is, if it was 
  4756.             explicitly specified when the routine was called. Returns 0 
  4757.             otherwise. 
  4758.  
  4759. Omitted     Returns 1 if the nth argument was omitted; that is, if it was not 
  4760.             explicitly specified when the routine was called. Returns 0 
  4761.             otherwise. 
  4762.  
  4763. Here are some examples: 
  4764.  
  4765. /*  following "Call name;" (no arguments) */
  4766. ARG( )        ->    0
  4767. ARG(1)        ->    ''
  4768. ARG(2)        ->    ''
  4769. ARG(1,'e')    ->    0
  4770. ARG(1,'O')    ->    1
  4771.  
  4772. /*  following "Call name 'a',,'b';" */
  4773. ARG( )        ->    3
  4774. ARG(1)        ->    'a'
  4775. ARG(2)        ->    ''
  4776. ARG(3)        ->    'b'
  4777. ARG(n)        ->    ''    /* for n>=4 */
  4778. ARG(1,'e')    ->    1
  4779. ARG(2,'E')    ->    0
  4780. ARG(2,'O')    ->    1
  4781. ARG(3,'o')    ->    0
  4782. ARG(4,'o')    ->    1
  4783.  
  4784. Notes: 
  4785.  
  4786.  1. You can retrieve and directly parse the argument strings to a program or 
  4787.     internal routine using the ARG or PARSE ARG instructions. 
  4788.  2. Programs called as commands can have only 0 or 1 argument strings. The 
  4789.     program has no argument strings if it is called with the name only and has 
  4790.     1 argument string if anything else (including blanks) is included with the 
  4791.     command. 
  4792.  3. Programs called by the REXXSTART entry point can have multiple argument 
  4793.     strings. 
  4794.  
  4795.  
  4796. ΓòÉΓòÉΓòÉ 11.6. BEEP ΓòÉΓòÉΓòÉ
  4797.  
  4798.  ΓöÇΓöÇBEEP(frequency,duration)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4799.  
  4800. BEEP sounds the speaker at frequency (Hertz) for duration milliseconds. The 
  4801. frequency can be any number in the range 37 to 32767 Hertz. The duration can be 
  4802. any number in the range 1 to 60000 milliseconds. 
  4803.  
  4804. This routine is most useful when called as a subroutine. A null string is 
  4805. returned if the routine is successful. 
  4806.  
  4807. Here is an example: 
  4808.  
  4809. /* C scale */
  4810. note.1 = 262    /* middle C */
  4811. note.2 = 294    /*    D     */
  4812. note.3 = 330    /*    E     */
  4813. note.4 = 349    /*    F     */
  4814. note.5 = 392    /*    G     */
  4815. note.6 = 440    /*    A     */
  4816. note.7 = 494    /*    B     */
  4817. note.8 = 524    /*    C     */
  4818.  
  4819. do i=1 to 8
  4820.   call beep note.i,250    /* hold each note for */
  4821.                           /* one-quarter second */
  4822. end
  4823.  
  4824.  
  4825. ΓòÉΓòÉΓòÉ 11.7. BITAND ΓòÉΓòÉΓòÉ
  4826.  
  4827.  ΓöÇΓöÇBITAND(string1ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4828.                     ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4829.                         ΓööΓöÇstring2Γöÿ ΓööΓöÇ,padΓöÇΓöÿ
  4830.  
  4831. BITAND returns a string composed of the two input strings logically compared, 
  4832. bit by bit, using the AND operator. The length of the result is the length of 
  4833. the longer of the two strings. If no pad character is provided, the AND 
  4834. operation terminates when the shorter of the two strings is exhausted, and the 
  4835. unprocessed portion of the longer string is appended to the partial result.  If 
  4836. pad is provided, it is used to extend the shorter of the two strings on the 
  4837. right, before carrying out the logical operation. The default for string2 is 
  4838. the zero length (null) string. 
  4839.  
  4840. Here are some examples: 
  4841.  
  4842. BITAND('73'x,'27'x)            ->    '23'x
  4843. BITAND('13'x,'5555'x)          ->    '1155'x
  4844. BITAND('13'x,'5555'x,'74'x)    ->    '1154'x
  4845. BITAND('pQrS',,'DF'x)          ->    'PQRS' /* ASCII only  */
  4846.  
  4847.  
  4848. ΓòÉΓòÉΓòÉ 11.8. BITOR ΓòÉΓòÉΓòÉ
  4849.  
  4850.  ΓöÇΓöÇBITOR(string1ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4851.                    ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4852.                        ΓööΓöÇstring2Γöÿ ΓööΓöÇ,padΓöÇΓöÿ
  4853.  
  4854. BITOR returns a string composed of the two input strings logically compared, 
  4855. bit by bit, using the OR operator. The length of the result is the length of 
  4856. the longer of the two strings. If no pad character is provided, the OR 
  4857. operation terminates when the shorter of the two strings is exhausted, and the 
  4858. unprocessed portion of the longer string is appended to the partial result.  If 
  4859. pad is provided, it is used to extend the shorter of the two strings on the 
  4860. right, before carrying out the logical operation. The default for string2 is 
  4861. the zero length (null) string. 
  4862.  
  4863. Here are some examples: 
  4864.  
  4865. BITOR('15'x,'24'x)            ->    '35'x
  4866. BITOR('15'x,'2456'x)          ->    '3556'x
  4867. BITOR('15'x,'2456'x,'F0'x)    ->    '35F6'x
  4868. BITOR('1111'x,,'4D'x)         ->    '5D5D'x
  4869. BITOR('pQrS',,'20'x)          ->    'pqrs' /* ASCII only  */
  4870.  
  4871.  
  4872. ΓòÉΓòÉΓòÉ 11.9. BITXOR ΓòÉΓòÉΓòÉ
  4873.  
  4874.  ΓöÇΓöÇBITXOR(string1ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4875.                     ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4876.                         ΓööΓöÇstring2Γöÿ ΓööΓöÇ,padΓöÇΓöÿ
  4877.  
  4878. BITXOR returns a string composed of the two input strings logically compared 
  4879. bit by bit using the exclusive OR operator. The length of the result is the 
  4880. length of the longer of the two strings. If no pad character is provided, the 
  4881. XOR operation terminates when the shorter of the two strings is exhausted, and 
  4882. the unprocessed portion of the longer string is appended to the partial result. 
  4883. If pad is provided, it is used to extend the shorter of the two strings on the 
  4884. right, before carrying out the logical operation. The default for string2 is 
  4885. the zero length (null) string. 
  4886.  
  4887. Here are some examples: 
  4888.  
  4889. BITXOR('12'x,'22'x)               ->  '30'x
  4890. BITXOR('1211'x,'22'x)             ->  '3011'x
  4891. BITXOR('C711'x,'222222'x,' ')     ->  'E53302'x  /* ASCII  */
  4892. BITXOR('1111'x,'444444'x)         ->  '555544'x
  4893. BITXOR('1111'x,'444444'x,'40'x)   ->  '555504'x
  4894. BITXOR('1111'x,,'4D'x)            ->  '5C5C'x
  4895.  
  4896.  
  4897. ΓòÉΓòÉΓòÉ 11.10. B2X (Binary to Hexadecimal) ΓòÉΓòÉΓòÉ
  4898.  
  4899.  ΓöÇΓöÇΓöÇB2X(binary_string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4900.  
  4901. Converts binary_string, a string of binary (0 or 1) digits, to an equivalent 
  4902. string of hexadecimal characters. You can optionally include blanks in 
  4903. binary_string (at four-digit boundaries only, not leading or trailing) to aid 
  4904. readability; they are ignored. 
  4905.  
  4906. The returned string uses uppercase letters for the values A-F, and does not 
  4907. include blanks. 
  4908.  
  4909. binary_string can be of any length; if it is the null string, then a null 
  4910. string is returned. If the number of binary digits in the string is not a 
  4911. multiple of four, then up to three 0 digits will be added on the left before 
  4912. the conversion to make a total that is a multiple of four. 
  4913.  
  4914. Here are some examples: 
  4915.  
  4916. B2X('11000011')    ==   'C3'
  4917. B2X('10111')       ==   '17'
  4918. B2X('101')         ==   '5'
  4919. B2X('1 1111 0000') ==   '1F0'
  4920.  
  4921. B2X( ) can be combined with the functions X2D( ) and X2C( ) to convert a binary 
  4922. number into other forms. For example: 
  4923.  
  4924. X2D(B2X('10111'))  ==   '23'   /* decimal 23 */
  4925.  
  4926.  
  4927. ΓòÉΓòÉΓòÉ 11.11. CENTER/CENTRE ΓòÉΓòÉΓòÉ
  4928.  
  4929.      ΓöîΓöÇCENTER(ΓöÇΓöÉ
  4930.  ΓöÇΓöÇΓöñ         Γö£ΓöÇΓöÇstring,length ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4931.      ΓööΓöÇCENTRE(ΓöÇΓöÿ                 ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  4932.  
  4933. CENTER or CENTRE returns a string of length length with string centered in it, 
  4934. with pad characters added as necessary to make up length. The default pad 
  4935. character is blank. If the string is longer than length, it will be truncated 
  4936. at both ends to fit. If an odd number of characters are truncated or added, the 
  4937. right-hand end loses or gains one more character than the left-hand end. 
  4938.  
  4939. Here are some examples: 
  4940.  
  4941. CENTER(abc,7)               ->    '  ABC  '
  4942. CENTER(abc,8,'-')           ->    '--ABC---'
  4943. CENTRE('The blue sky',8)    ->    'e blue s'
  4944. CENTRE('The blue sky',7)    ->    'e blue '
  4945.  
  4946. Note:   This function can be called either CENTRE or CENTER, which avoids 
  4947. errors due to the difference between the British and American spellings. 
  4948.  
  4949.  
  4950. ΓòÉΓòÉΓòÉ 11.12. CHARIN ΓòÉΓòÉΓòÉ
  4951.  
  4952.  ΓöÇΓöÇCHARIN(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  4953.              ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4954.                            ΓööΓöÇstartΓöÇΓöÿ  ΓööΓöÇ,lengthΓöÇΓöÿ
  4955.  
  4956. CHARIN returns a string of up to length characters read from the character 
  4957. input stream name. The form of the name is implementation dependent. If name is 
  4958. omitted, characters are read from the default input stream, STDIN:. The default 
  4959. length is 1. 
  4960.  
  4961. For persistent streams, a read position is maintained for each stream. In the 
  4962. OS/2 operating system, this is the same as the write position. Any read from 
  4963. the stream will by default start at the current read position.  When the read 
  4964. is completed, the read position is increased by the number of characters read. 
  4965. A start value can be given to specify an explicit read position.  This read 
  4966. position must be positive and within the bounds of the stream, and must not be 
  4967. specified for a transient stream ( a port or other serial device).  A value of 
  4968. 1 for start refers to the first character in the stream. 
  4969.  
  4970. If you specify a length of 0, then the read position will be set to the value 
  4971. of start, but no characters are read and the null string is returned. 
  4972.  
  4973. In a transient stream, if there are fewer then length characters available, 
  4974. then execution of the program will normally stop until sufficient characters do 
  4975. become available.  If, however, it is impossible for those characters to become 
  4976. available due to an error or other problem, the NOTREADY condition is raised 
  4977. and CHARIN will return with fewer than the requested number of characters. 
  4978.  
  4979. Here are some examples: 
  4980.  
  4981. CHARIN(myfile,1,3)   ->   'MFC'   /* the first 3     */
  4982.                                    /* characters      */
  4983. CHARIN(myfile,1,0)   ->   ''      /* now at start    */
  4984. CHARIN(myfile)       ->   'M'     /* after last call */
  4985. CHARIN(myfile,,2)    ->   'FC'    /* after last call */
  4986.  
  4987. /* Reading from the default input (here, the keyboard) */
  4988. /* User types 'abcd efg' */
  4989. CHARIN( )            ->   'a'      /* default is  */
  4990.                                              /* 1 character */
  4991. CHARIN(,,5)          ->   'bcd e'
  4992.  
  4993. Note 1: 
  4994.  
  4995. CHARIN returns all characters that appear in the stream including control 
  4996. characters such as line feed, carriage return, and end of file. 
  4997.  
  4998. Note 2: 
  4999.  
  5000. When CHARIN is used to read from the keyboard, program execution stops until 
  5001. you press the Enter key. 
  5002.  
  5003.  
  5004. ΓòÉΓòÉΓòÉ 11.13. CHAROUT ΓòÉΓòÉΓòÉ
  5005.  
  5006.  ΓöÇΓöÇCHAROUT(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5007.               ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  5008.                             ΓööΓöÇstringΓöÇΓöÿ  ΓööΓöÇ,startΓöÇΓöÿ
  5009.  
  5010. CHAROUT returns the count of characters remaining after attempting to write 
  5011. string to the character output stream name. The form of the name is 
  5012. implementation dependent. If name is omitted, characters in string will be 
  5013. written to the default output stream, STDOUT: (normally the display) in the 
  5014. OS/2 operating system. string can be the null string, in which case no 
  5015. characters are written to the stream and 0 is always returned. 
  5016.  
  5017. For persistent streams, a write position is maintained for each stream. In the 
  5018. OS/2 implementation, this is the same as the read position. Any write to the 
  5019. stream starts at the current write position by default.  When the write is 
  5020. completed the write position is increased by the number of characters written. 
  5021. The initial write position is the end of the stream, so that calls to CHAROUT 
  5022. normally append to the end of the stream. 
  5023.  
  5024. A start value can be given to specify an explicit write position for a 
  5025. persistent stream. This write position must be a positive whole number within 
  5026. the bounds of the stream (though it can specify the character position 
  5027. immediately after the end of the stream). A value of 1 for start refers to the 
  5028. first character in the stream. 
  5029.  
  5030. Note:   In some environments, overwriting a stream with CHAROUT or LINEOUT can 
  5031.         erase (destroy) all existing data in the stream. However, this is not 
  5032.         the case in the OS/2 environment. 
  5033.  
  5034. The string can be omitted for persistent streams. In this case, the write 
  5035. position is set to the value of start that was given, no characters are written 
  5036. to the stream, and 0 is returned. If neither start nor string are given, the 
  5037. write position is set to the end of the stream. This use of CHAROUT can also 
  5038. have the side effect of closing or fixing the file in environments which 
  5039. support this concept.  Again, 0 is returned. If you do not specify start or 
  5040. string, the stream is closed. Again, 0 is returned. 
  5041.  
  5042. Processing of the program normally stops until the output operation is 
  5043. effectively complete. If, however, it is impossible for all the characters to 
  5044. be written, the NOTREADY condition is raised and CHAROUT returns with the 
  5045. number of characters that could not be written (the residual count). 
  5046.  
  5047. Here are some examples: 
  5048.  
  5049. CHAROUT(myfile,'Hi')     ->   0   /* normally */
  5050. CHAROUT(myfile,'Hi',5)   ->   0   /* normally */
  5051. CHAROUT(myfile,,6)       ->   0   /* now at char 6 */
  5052. CHAROUT(myfile)          ->   0   /* at end of stream */
  5053. CHAROUT(,'Hi')           ->   0   /* normally */
  5054. CHAROUT(,'Hello')        ->   2   /* maybe */
  5055.  
  5056. Note:   This routine is often best called as a subroutine. The residual count 
  5057.         is then available in the variable RESULT. 
  5058.  
  5059. For example: 
  5060.  
  5061. Call CHAROUT myfile,'Hello'
  5062. Call CHAROUT myfile,'Hi',6
  5063. Call CHAROUT myfile
  5064.  
  5065.  
  5066. ΓòÉΓòÉΓòÉ 11.14. CHARS ΓòÉΓòÉΓòÉ
  5067.  
  5068.  ΓöÇΓöÇCHARS(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5069.             ΓööΓöÇnameΓöÇΓöÿ
  5070.  
  5071. CHARS returns the total number of characters remaining in the character input 
  5072. stream name. The count includes any line separator characters, if these are 
  5073. defined for the stream, and in the case of persistent streams, is the count of 
  5074. characters from the current read position to the end of the stream. If name is 
  5075. omitted, OS/2 will use STDIN: as the default. 
  5076.  
  5077. The total number of characters remaining cannot be determined for some streams 
  5078. (for example, STDIN:).  For these streams, the CHARS function returns 1 to 
  5079. indicate that data is present, or 0 if no data is present. For OS/2 devices, 
  5080. CHARS always returns 1. 
  5081.  
  5082. Here are some examples: 
  5083.  
  5084. CHARS(myfile)     ->   42   /* perhaps */
  5085. CHARS(nonfile)    ->   0    /* perhaps */
  5086. CHARS()           ->   1    /* perhaps */
  5087.  
  5088.  
  5089. ΓòÉΓòÉΓòÉ 11.15. COMPARE ΓòÉΓòÉΓòÉ
  5090.  
  5091.  ΓöÇΓöÇΓöÇCOMPARE(string1,string2 ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5092.                                ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  5093.  
  5094. COMPARE returns 0 if the strings, string1 and string2, are identical. 
  5095. Otherwise, COMPARE returns the position of the first character that does not 
  5096. match. The shorter string is padded on the right with pad if necessary.  The 
  5097. default pad character is a blank. 
  5098.  
  5099. Here are some examples: 
  5100.  
  5101. COMPARE('abc','abc')         ->    0
  5102. COMPARE('abc','ak')          ->    2
  5103. COMPARE('ab ','ab')          ->    0
  5104. COMPARE('ab ','ab',' ')      ->    0
  5105. COMPARE('ab ','ab','x')      ->    3
  5106. COMPARE('ab-- ','ab','-')    ->    5
  5107.  
  5108.  
  5109. ΓòÉΓòÉΓòÉ 11.16. CONDITION ΓòÉΓòÉΓòÉ
  5110.  
  5111.  ΓöÇΓöÇΓöÇCONDITION(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5112.                  ΓööΓöÇoptionΓöÇΓöÿ
  5113.  
  5114. CONDITION returns the condition information associated with the current trapped 
  5115. condition.  You can request four pieces of information: 
  5116.  
  5117. o The name of the current trapped condition 
  5118. o Any descriptive string associated with that condition 
  5119. o The instruction executed as a result of the condition trap (CALL or SIGNAL) 
  5120. o The status of the trapped condition. 
  5121.  
  5122. The following options (of which only the capitalized letter is needed, all 
  5123. others are ignored) can be used to obtain the following information: 
  5124.  
  5125. Condition name    Returns the name of the current trapped condition. 
  5126.  
  5127. Description       Returns any descriptive string associated with the current 
  5128.                   trapped condition. If no description is available, a null 
  5129.                   string is returned. 
  5130.  
  5131. Instruction       Returns the keyword for the instruction executed when the 
  5132.                   current condition was trapped.  The keywords are CALL or 
  5133.                   SIGNAL. This is the default if you omit option. 
  5134.  
  5135. Status            Returns the status of the current trapped condition.  This 
  5136.                   can change during execution, and is either: 
  5137.  
  5138.    ON - the condition is enabled 
  5139.  
  5140.    OFF - the condition is disabled 
  5141.  
  5142.    DELAY - any new occurrence of the condition is delayed. 
  5143.  
  5144. If no condition has been trapped (that is, there is no current trapped 
  5145. condition) then the CONDITION function returns a null string in all four cases. 
  5146.  
  5147. Here are some examples: 
  5148.  
  5149. CONDITION()            ->    'CALL'        /* perhaps */
  5150. CONDITION('C')         ->    'FAILURE'
  5151. CONDITION('I')         ->    'CALL'
  5152. CONDITION('D')         ->    'FailureTest'
  5153. CONDITION('S')         ->    'OFF'        /* perhaps */
  5154.  
  5155. Note:   The condition information returned by the CONDITION function is saved 
  5156.         and restored across subroutine calls (including those caused by a CALL 
  5157.         ON condition trap). Therefore, once a subroutine invoked due to a CALL 
  5158.         ON trap has returned, the current trapped condition reverts to the 
  5159.         current condition before the CALL took place. CONDITION returns the 
  5160.         values it returned before the condition was trapped. 
  5161.  
  5162.  
  5163. ΓòÉΓòÉΓòÉ 11.17. COPIES ΓòÉΓòÉΓòÉ
  5164.  
  5165.  ΓöÇΓöÇΓöÇCOPIES(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5166.  
  5167. COPIES returns n concatenated copies of string. n must be a nonnegative whole 
  5168. number. 
  5169.  
  5170. Here are some examples: 
  5171.  
  5172. COPIES('abc',3)    ->    'abcabcabc'
  5173. COPIES('abc',0)    ->    ''
  5174.  
  5175.  
  5176. ΓòÉΓòÉΓòÉ 11.18. C2D (Character to Decimal) ΓòÉΓòÉΓòÉ
  5177.  
  5178.  ΓöÇΓöÇΓöÇC2D(string ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5179.                   ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  5180.  
  5181. C2D returns the decimal value of the binary representation of string. If the 
  5182. result cannot be expressed as a whole number, an error results. That is, the 
  5183. result must not have more digits than the current setting of NUMERIC DIGITS. 
  5184.  
  5185. If string is the null string, then 0 is returned. 
  5186.  
  5187. If n is not specified, string is processed as an unsigned binary number. 
  5188.  
  5189. Here are some examples: 
  5190.  
  5191. C2D('09'X)      ->        9
  5192. C2D('81'X)      ->      129
  5193. C2D('FF81'X)    ->    65409
  5194. C2D('a')        ->       97     /* ASCII */
  5195.  
  5196. If n is specified, the given string is padded on the left with 00x characters 
  5197. (note, not sign-extended), or truncated on the left to n characters. The 
  5198. resulting string of n hexadecimal digits is taken to be a signed binary number: 
  5199. positive if the leftmost bit is OFF, and negative, in two's complement 
  5200. notation, if the leftmost bit is ON. If n is 0, then 0 is always returned. 
  5201.  
  5202. Here are some examples: 
  5203.  
  5204. C2D('81'X,1)      ->     -127
  5205. C2D('81'X,2)      ->      129
  5206. C2D('FF81'X,2)    ->     -127
  5207. C2D('FF81'X,1)    ->     -127
  5208. C2D('FF7F'X,1)    ->      127
  5209. C2D('F081'X,2)    ->    -3967
  5210. C2D('F081'X,1)    ->     -127
  5211. C2D('0031'X,0)    ->        0
  5212.  
  5213. Implementation maximum: The input string cannot have more than 250 characters 
  5214. that will be significant in forming the final result.  Leading sign characters 
  5215. (00x and ffx) do not count toward this total. 
  5216.  
  5217.  
  5218. ΓòÉΓòÉΓòÉ 11.19. C2X (Character to Hexadecimal) ΓòÉΓòÉΓòÉ
  5219.  
  5220.  ΓöÇΓöÇΓöÇC2X(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5221.  
  5222. C2X converts a character string to its hexadecimal representation. The data to 
  5223. be converted can be of any length. The returned string contains twice as many 
  5224. bytes as the input string because it is in literal string notation. 
  5225.  
  5226. Here are some examples: 
  5227.  
  5228. C2X('0123'X)    ->    '0123'
  5229. C2X('ZD8')      ->    '5A4438'     /*   ASCII    */
  5230.  
  5231.  
  5232. ΓòÉΓòÉΓòÉ 11.20. DATATYPE ΓòÉΓòÉΓòÉ
  5233.  
  5234.  ΓöÇΓöÇΓöÇDATATYPE(string ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5235.                        ΓööΓöÇΓöÇ,typeΓöÇΓöÇΓöÿ
  5236.  
  5237. DATATYPE determines whether 'data' is numeric or alphabetic and returns a 
  5238. result of NUM or CHAR. If only string is specified, the returned result is NUM 
  5239. if string is a valid REXX number (any format); otherwise CHAR will be the 
  5240. returned result. 
  5241.  
  5242. If type is specified, the returned result is 1 if string matches the type; 
  5243. otherwise, a 0 is returned. If string is null, 0 is returned (except when type 
  5244. is X, which returns 1). The following is a list of valid types. Only the 
  5245. capitalized letter is significant (all others are ignored). 
  5246.  
  5247. Alphanumeric      Returns 1 if string contains only characters from the ranges 
  5248.                   a-z, A-Z, and 0-9. 
  5249.  
  5250. Bits              Returns 1 if string contains only the characters 0 and/or 1. 
  5251.  
  5252. C                 Returns 1 if string is a mixed SBCS/DBCS string. 
  5253.  
  5254. Dbcs              Returns 1 if string is a pure DBCS string. 
  5255.  
  5256. Lowercase         Returns 1 if string contains only characters from the range 
  5257.                   a-z. 
  5258.  
  5259. Mixed case        Returns 1 if string contains only characters from the ranges 
  5260.                   a-z and A-Z. 
  5261.  
  5262. Number            Returns 1 if string is a valid REXX number. 
  5263.  
  5264. Symbol            Returns 1 if string contains only characters that are valid 
  5265.                   in REXX symbols. Note that both uppercase and lowercase 
  5266.                   letters are permitted. 
  5267.  
  5268. Uppercase         Returns 1 if string contains only characters from the range 
  5269.                   A-Z. 
  5270.  
  5271. Whole number      Returns 1 if string is a REXX whole number under the current 
  5272.                   setting of NUMERIC DIGITS. 
  5273.  
  5274. heXadecimal       Returns 1 if string contains only characters from the ranges 
  5275.                   a-f, A-F, 0-9, and blank (so long as blanks only appear 
  5276.                   between pairs of hexadecimal characters). Also returns 1 if 
  5277.                   string is a null string. 
  5278.  
  5279. DATATYPE(' 12 ')         ->   'NUM'
  5280. DATATYPE('')             ->   'CHAR'
  5281. DATATYPE('123*')         ->   'CHAR'
  5282. DATATYPE('12.3','N')     ->    1
  5283. DATATYPE('12.3','W')     ->    0
  5284. DATATYPE('Fred','M')     ->    1
  5285. DATATYPE('','M')         ->    0
  5286. DATATYPE('Fred','L')     ->    0
  5287. DATATYPE('?20K','S')     ->    1
  5288. DATATYPE('BCd3','X')     ->    1
  5289. DATATYPE('BC d3','X')    ->    1
  5290.  
  5291.  
  5292. ΓòÉΓòÉΓòÉ 11.21. DATE ΓòÉΓòÉΓòÉ
  5293.  
  5294.  ΓöÇΓöÇΓöÇDATE(ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5295.              ΓööΓöÇoptionΓöÇΓöÇΓöÿ
  5296.  
  5297. DATE returns, by default, the local date in the format: dd mon yyyy (for 
  5298. example, 27 Aug 1988), with no leading zero or blank on the day. For mon, the 
  5299. first three characters of the English name of the month will be used. 
  5300.  
  5301. The following options (of which only the capitalized letter is needed, all 
  5302. others are ignored) can be used to obtain alternative formats: 
  5303.  
  5304. Basedate        Returns the number of complete days (that is, not including the 
  5305.                 current day) since and including the base date, January 1, 
  5306.                 0001, in the format: dddddd (no leading zeros). The expression 
  5307.                 DATE(B)//7  returns a number in the range 0-6, where 0 is 
  5308.                 Monday and 6 is Sunday. 
  5309.  
  5310.                 Note:   The origin of January 1, 0001 is based on the Gregorian 
  5311.                         calendar. Though this calendar did not exist prior to 
  5312.                         1582, Basedate is calculated as if it did: 365 days per 
  5313.                         year, an extra day every four years except century 
  5314.                         years, and leap centuries if the century is divisible 
  5315.                         by 400. It does not take into account any errors in the 
  5316.                         calendar system that created the Gregorian calendar 
  5317.                         originally. 
  5318.  
  5319. Days            Returns the number of days, including the current day, so far 
  5320.                 in this year in the format: ddd (no leading zeros) 
  5321.  
  5322. European        Returns date in the format: dd/mm/yy. 
  5323.  
  5324. Language        Returns date in an implementation and language dependent or 
  5325.                 local date format. In the OS/2 operating system, the Language 
  5326.                 format is dd Month yyyy. If no local format is available, the 
  5327.                 default format is returned. 
  5328.  
  5329.                 Note:   This format is intended to be used as a whole; REXX 
  5330.                         programs should not make any assumptions about the form 
  5331.                         or content of the returned string. 
  5332.  
  5333. Month           Returns full English name of the current month, for example, 
  5334.                 August 
  5335.  
  5336. Normal          Returns date in the default format: dd mon yyyy 
  5337.  
  5338. Ordered         Returns date in the format: yy/mm/dd (suitable for sorting, and 
  5339.                 so on.) 
  5340.  
  5341. Sorted          Returns date in the format: yyyymmdd (suitable for sorting, and 
  5342.                 so on.) 
  5343.  
  5344. Usa             Returns date in the format: mm/dd/yy 
  5345.  
  5346. Weekday         Returns the English name for the day of the week, in mixed 
  5347.                 case. For example, Tuesday. 
  5348.  
  5349. Here are some examples: 
  5350.  
  5351. DATE( )        ->    '27 Aug 1988'  /*  perhaps  */
  5352. DATE('B')      ->    725975
  5353. DATE('D')      ->    240
  5354. DATE('E')      ->    '27/08/88'
  5355. DATE('L')      ->    '27 August 1988'
  5356. DATE('M')      ->    'August'
  5357. DATE('N')      ->    '27 Aug 1988'
  5358. DATE('O')      ->    '88/08/27'
  5359. DATE('S')      ->    '19880827'
  5360. DATE('U')      ->    '08/27/88'
  5361. DATE('W')      ->    'Saturday'
  5362.  
  5363. Note:   The first call to DATE or TIME in one expression causes a time stamp to 
  5364.         be made which is then used for all calls to these functions in that 
  5365.         expression. Therefore, if multiple calls to any of the DATE and/or TIME 
  5366.         functions are made in a single expression, they are guaranteed to be 
  5367.         consistent with each other. 
  5368.  
  5369.  
  5370. ΓòÉΓòÉΓòÉ 11.22. DELSTR (Delete String) ΓòÉΓòÉΓòÉ
  5371.  
  5372.  ΓöÇΓöÇΓöÇDELSTR(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5373.                        ΓööΓöÇΓöÇ,lengthΓöÇΓöÇΓöÿ
  5374.  
  5375. DELSTR deletes the substring of string that begins at the nth character, and is 
  5376. of length length. If length is not specified, the rest of string is deleted. If 
  5377. n is greater than the length of string, the string is returned unchanged. n 
  5378. must be a positive whole number. 
  5379.  
  5380. Here are some examples: 
  5381.  
  5382. DELSTR('abcd',3)       ->    'ab'
  5383. DELSTR('abcde',3,2)    ->    'abe'
  5384. DELSTR('abcde',6)      ->    'abcde'
  5385.  
  5386.  
  5387. ΓòÉΓòÉΓòÉ 11.23. DELWORD ΓòÉΓòÉΓòÉ
  5388.  
  5389.  ΓöÇΓöÇΓöÇDELWORD(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5390.                         ΓööΓöÇΓöÇ,lengthΓöÇΓöÇΓöÿ
  5391.  
  5392. DELWORD deletes the substring of string that starts at the n th word. The 
  5393. length option refers to the number of blank-delimited words. If length is 
  5394. omitted, it defaults to be the remaining words in string. n must be a positive 
  5395. whole number. If n is greater than the number of words in string, string is 
  5396. returned unchanged. The string deleted includes any blanks following the final 
  5397. word involved. 
  5398.  
  5399. Here are some examples: 
  5400.  
  5401. DELWORD('Now is the  time',2,2)  ->  'Now time'
  5402. DELWORD('Now is the time ',3)    ->  'Now is '
  5403. DELWORD('Now is the  time',5)    ->  'Now is the  time'
  5404.  
  5405.  
  5406. ΓòÉΓòÉΓòÉ 11.24. DIGITS ΓòÉΓòÉΓòÉ
  5407.  
  5408.  ΓöÇΓöÇDIGITS()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5409.  
  5410. DIGITS returns the current setting of NUMERIC DIGITS. 
  5411.  
  5412. Here is an example: 
  5413.  
  5414. DIGITS()    ->    9      /* by default */
  5415.  
  5416.  
  5417. ΓòÉΓòÉΓòÉ 11.25. D2C (Decimal to Character) ΓòÉΓòÉΓòÉ
  5418.  
  5419.  ΓöÇΓöÇΓöÇD2C(wholenumber ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5420.                        ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  5421.  
  5422. D2C returns a character string that is the ASCII representation of the decimal 
  5423. number. If you specify n, it is the length of the final result in characters 
  5424. and leading blanks are added to the output character. 
  5425.  
  5426. If n is not specified, wholenumber must be a nonnegative number and the 
  5427. resulting length is as needed; therefore, the returned result has no leading 
  5428. 00x characters. 
  5429.  
  5430. Here are some examples: 
  5431.  
  5432. D2C(65)      ->   'A'      /* '41'x is an ASCII 'A'    */
  5433. D2C(65,1)    ->   'A'
  5434. D2C(65,2)    ->   ' A'
  5435. D2C(65,5)    ->   '    A'
  5436. D2C(109)     ->   'm'      /* '6D'x  is an ASCII 'm'   */
  5437. D2C(-109,1)  ->   '╨ú'      /* '147'x is an ASCII '╨ú'   */
  5438. D2C(76,2)    ->   ' L'     /* '76'x  is an ASCII ' L'  */
  5439. D2C(-180,2)  ->   ' L'
  5440.  
  5441.  
  5442. ΓòÉΓòÉΓòÉ 11.26. D2X (Decimal to Hexadecimal) ΓòÉΓòÉΓòÉ
  5443.  
  5444.  ΓöÇΓöÇΓöÇD2X(wholenumber ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5445.                        ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  5446.  
  5447. D2X returns a string of hexadecimal characters that is the hexadecimal 
  5448. representation of the decimal number. 
  5449.  
  5450. If n is not specified, wholenumber must be a nonnegative number and the 
  5451. returned result has no leading 0 characters. 
  5452.  
  5453. If n is specified, it is the length of the final result in characters; that is, 
  5454. after conversion the input string is sign-extended to the required length. If 
  5455. the number is too big to fit into n characters, it is shortened on the left. 
  5456.  
  5457. Here are some examples: 
  5458.  
  5459. D2X(9)         ->    '9'
  5460. D2X(129)       ->    '81'
  5461. D2X(129,1)     ->    '1'
  5462. D2X(129,2)     ->    '81'
  5463. D2X(129,4)     ->    '0081'
  5464. D2X(257,2)     ->    '01'
  5465. D2X(-127,2)    ->    '81'
  5466. D2X(-127,4)    ->    'FF81'
  5467. D2X(12,0)      ->    ''
  5468.  
  5469. Implementation maximum: The output string cannot have more than 250 significant 
  5470. hexadecimal characters, though a longer result is possible if it has additional 
  5471. leading sign characters (0 and F). 
  5472.  
  5473.  
  5474. ΓòÉΓòÉΓòÉ 11.27. DIRECTORY ΓòÉΓòÉΓòÉ
  5475.  
  5476.  ΓöÇΓöÇDIRECTORY(ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5477.                  ΓööΓöÇnewdirectoryΓöÇΓöÿ
  5478.  
  5479. DIRECTORY returns the current directory, first changing it to newdirectory if 
  5480. an argument is supplied and the named directory exists. 
  5481.  
  5482. The return string includes a drive letter prefix as the first two characters of 
  5483. the directory name. Specifying a drive letter prefix as part of newdirectory 
  5484. causes the specified drive to become the current drive. If a drive letter is 
  5485. not specified, then the current drive remains unchanged. 
  5486.  
  5487. For example, the following program fragment saves the current directory and 
  5488. switches to a new directory; it performs an operation there, and then returns 
  5489. to the former directory. 
  5490.  
  5491. /* get current directory */
  5492. curdir = directory()
  5493. /* go play a game */
  5494. newdir = directory("d:/usr/games")
  5495. if newdir = "d:/usr/games" then
  5496.    do
  5497.    fortune  /* tell a fortune */
  5498. /* return to former directory */
  5499.    call directory curdir
  5500.    end
  5501. else
  5502.    say 'Can't find /usr/games'
  5503.  
  5504.  
  5505. ΓòÉΓòÉΓòÉ 11.28. ERRORTEXT ΓòÉΓòÉΓòÉ
  5506.  
  5507.  ΓöÇΓöÇΓöÇERRORTEXT(n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5508.  
  5509. ERRORTEXT returns the error message associated with error number n. n must be 
  5510. in the range 0-99, and any other value is an error. If n is in the allowed 
  5511. range, but is not a defined REXX error number, the null string is returned. 
  5512.  
  5513. Here are some examples: 
  5514.  
  5515. ERRORTEXT(16)    ->    'Label not found'
  5516. ERRORTEXT(60)    ->    ''
  5517.  
  5518.  
  5519. ΓòÉΓòÉΓòÉ 11.29. ENDLOCAL ΓòÉΓòÉΓòÉ
  5520.  
  5521.  ΓöÇENDLOCAL()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5522.  
  5523. ENDLOCAL restores the drive directory and environment variables in effect 
  5524. before the last SETLOCAL function was executed. If ENDLOCAL is not included in 
  5525. a procedure, then the initial environment saved by SETLOCAL will be restored 
  5526. upon exiting the procedure. 
  5527.  
  5528. ENDLOCAL returns a value of 1 if the initial environment is successfully 
  5529. restored, and a value of 0 if no SETLOCAL has been issued or if the actions is 
  5530. otherwise unsuccessful. 
  5531.  
  5532. Note:   Unlike their counterparts in the OS/2 Batch language (the Setlocal and 
  5533.         Endlocal statements), the REXX SETLOCAL and ENDLOCAL functions can be 
  5534.         nested. 
  5535.  
  5536. Here is an example: 
  5537.  
  5538. n = SETLOCAL()          /* saves the current environment    */
  5539.  
  5540.          /* The program can now change environment   */
  5541.          /* variables (with the VALUE function) and  */
  5542.          /* then work in that changed envirnonment.  */
  5543.  
  5544. n = ENDLOCAL()          /* restores the initial environment */
  5545.  
  5546. For additional examples, view the SETLOCAL function. 
  5547.  
  5548.  
  5549. ΓòÉΓòÉΓòÉ 11.30. FILESPEC ΓòÉΓòÉΓòÉ
  5550.  
  5551.  ΓöÇΓöÇFILESPEC(option,filespec)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5552.  
  5553. FILESPEC returns a selected element of filespec, a given file specification, 
  5554. identified by one of the following strings for option: 
  5555.  
  5556. Drive       The drive letter of the given filespec. 
  5557.  
  5558. Path        The directory path of the given filespec. 
  5559.  
  5560. Name        The filename of the given filespec. 
  5561.  
  5562. If the requested string is not found, then FILESPEC returns a null string (" 
  5563. "). 
  5564.  
  5565. Note:   Only the the initial letter of option is needed. 
  5566.  
  5567. Here are some examples: 
  5568.  
  5569. thisfile = "C:\OS2\UTIL\EXAMPLE.EXE"
  5570. say FILESPEC("drive",thisfile)     /* says "C:"          */
  5571. say FILESPEC("path",thisfile)      /* says "\OS2\UTIL\"  */
  5572. say FILESPEC("name",thisfile)      /* says "EXAMPLE.EXE" */
  5573.  
  5574. part = "name"
  5575. say FILESPEC(part,thisfile)        /* says "EXAMPLE.EXE" */
  5576.  
  5577.  
  5578. ΓòÉΓòÉΓòÉ 11.31. FORM ΓòÉΓòÉΓòÉ
  5579.  
  5580.  ΓöÇΓöÇFORM()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5581. FORM returns the current setting of NUMERIC FORM. 
  5582.  
  5583. Here is an example: 
  5584.  
  5585. FORM()    ->    'SCIENTIFIC'  /* by default */
  5586.  
  5587.  
  5588. ΓòÉΓòÉΓòÉ 11.32. FORMAT ΓòÉΓòÉΓòÉ
  5589.  
  5590.  ΓöÇΓöÇFORMAT(numberΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ
  5591.                    ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5592.                        ΓööbeforeΓöÿ Γöö,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5593.                                    ΓööafterΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5594.                                                ΓööexppΓöÿ Γöö,exptΓöÿ
  5595.  
  5596. FORMAT returns number rounded and formatted. 
  5597.  
  5598. The number is first rounded and formatted to standard REXX rules, just as 
  5599. though the operation number+0 had been carried out. If only number is given, 
  5600. the result is precisely that of this operation. If any other options are 
  5601. specified, the number is formatted as follows. 
  5602.  
  5603. The before and after options describe how many characters are to be used for 
  5604. the integer part and decimal part of the result respectively. If either or both 
  5605. of these are omitted, the number of characters used for that part is as needed. 
  5606.  
  5607. If before is not large enough to contain the integer part of the number, an 
  5608. error results. If before is too large, the number is padded on the left with 
  5609. blanks. If after is not the same size as the decimal part of the number, the 
  5610. number will be rounded (or extended with zeros) to fit. Specifying 0 will cause 
  5611. the number to be rounded to an integer. 
  5612.  
  5613. Here are some examples: 
  5614.  
  5615. FORMAT('3',4)            ->    '   3'
  5616. FORMAT('1.73',4,0)       ->    '   2'
  5617. FORMAT('1.73',4,3)       ->    '   1.730'
  5618. FORMAT('-.76',4,1)       ->    '  -0.8'
  5619. FORMAT('3.03',4)         ->    '   3.03'
  5620. FORMAT(' - 12.73',,4)    ->    '-12.7300'
  5621. FORMAT(' - 12.73')       ->    '-12.73'
  5622. FORMAT('0.000')          ->    '0'
  5623.  
  5624. The first three arguments are as previously described.  In addition, expp and 
  5625. expt control the exponent part of the result: expp sets the number of places to 
  5626. be used for the exponent part; the default is to use as many as needed. The 
  5627. expt sets the trigger point for use of exponential notation. If the number of 
  5628. places needed for the integer part exceeds expt, exponential notation is used. 
  5629. Likewise, exponential notation is used if the number of places needed for the 
  5630. decimal part exceeds twice expt. The default is the current setting of NUMERIC 
  5631. DIGITS. If 0 is specified for expt, exponential notation is always used unless 
  5632. the exponent would be 0. The expp must be less than 10, but there is no limit 
  5633. on the other arguments. If 0 is specified for the expp field, no exponent is 
  5634. supplied, and the number is expressed in simple form with added zeros as 
  5635. necessary (this overrides a 0 value of expt). Otherwise, if expp is not large 
  5636. enough to contain the exponent, an error results. If the exponent is 0, in this 
  5637. case (a non-zero expp), then expp+2 blanks are supplied for the exponent part 
  5638. of the result. 
  5639.  
  5640. Here are some examples: 
  5641.  
  5642. FORMAT('12345.73',,,2,2)    ->    '1.234573E+04'
  5643. FORMAT('12345.73',,3,,0)    ->    '1.235E+4'
  5644. FORMAT('1.234573',,3,,0)    ->    '1.235'
  5645. FORMAT('12345.73',,,3,6)    ->    '12345.73'
  5646. FORMAT('1234567e5',,3,0)    ->    '123456700000.000'
  5647.  
  5648.  
  5649. ΓòÉΓòÉΓòÉ 11.33. FUZZ ΓòÉΓòÉΓòÉ
  5650.  
  5651.  ΓöÇΓöÇFUZZ()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5652.  
  5653. FUZZ returns the current setting of NUMERIC FUZZ. 
  5654.  
  5655. Here is an example: 
  5656.  
  5657. FUZZ()    ->    0     /* by default */
  5658.  
  5659.  
  5660. ΓòÉΓòÉΓòÉ 11.34. INSERT ΓòÉΓòÉΓòÉ
  5661.  
  5662.  ΓöÇΓöÇINSERT(new,targetΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5663.                        ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5664.                            ΓööΓöÇnΓöÇΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5665.                                      ΓöölengthΓöÿ Γöö,padΓöÿ
  5666.  
  5667. INSERT inserts the string new, padded to length length, into the string target 
  5668. after the n th character. If specified, n must be a nonnegative whole number. 
  5669. If n is greater than the length of the target string, padding is added there 
  5670. also. The default pad character is a blank. The default value for n is 0, which 
  5671. means insert before the beginning of the string. 
  5672.  
  5673. Here are some examples: 
  5674.  
  5675. INSERT(' ','abcdef',3)         ->    'abc def'
  5676. INSERT('123','abc',5,6)        ->    'abc  123   '
  5677. INSERT('123','abc',5,6,'+')    ->    'abc++123+++'
  5678. INSERT('123','abc')            ->    '123abc'
  5679. INSERT('123','abc',,5,'-')     ->    '123--abc'
  5680.  
  5681.  
  5682. ΓòÉΓòÉΓòÉ 11.35. LASTPOS ΓòÉΓòÉΓòÉ
  5683.  
  5684.  ΓöÇΓöÇLASTPOS(needle,haystackΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5685.                               ΓööΓöÇ,startΓöÇΓöÇΓöÿ
  5686.  
  5687. LASTPOS returns the position of the last occurrence of one string, needle, in 
  5688. another, haystack. If the string needle is not found, 0 is returned. By default 
  5689. the search starts at the last character of haystack (that is, 
  5690. start=LENGTH(string)) and scans backwards. You can override this by specifying 
  5691. start, as the point at which the backward scan starts. start must be a positive 
  5692. whole number, and defaults to LENGTH(string) if larger than that value. 
  5693.  
  5694. Here are some examples: 
  5695.  
  5696. LASTPOS(' ','abc def ghi')      ->    8
  5697. LASTPOS(' ','abcdefghi')        ->    0
  5698. LASTPOS(' ','abc def ghi',7)    ->    4
  5699.  
  5700.  
  5701. ΓòÉΓòÉΓòÉ 11.36. LEFT ΓòÉΓòÉΓòÉ
  5702.  
  5703.  ΓöÇΓöÇLEFT(string,lengthΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5704.                          ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  5705.  
  5706. LEFT returns a string of length length, containing the leftmost length 
  5707. characters of string. The string returned is padded with pad characters (or 
  5708. truncated) on the right as needed. The default pad character is a blank. length 
  5709. must be nonnegative. The LEFT function is exactly equivalent to 
  5710. SUBSTR(string,1,length[,pad]). 
  5711.  
  5712. Here are some examples: 
  5713.  
  5714. LEFT('abc d',8)        ->    'abc d   '
  5715. LEFT('abc d',8,'.')    ->    'abc d...'
  5716. LEFT('abc  def',7)     ->    'abc  de'
  5717.  
  5718.  
  5719. ΓòÉΓòÉΓòÉ 11.37. LENGTH ΓòÉΓòÉΓòÉ
  5720.  
  5721.  ΓöÇΓöÇLENGTH(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5722.  
  5723. LENGTH returns the length of string. 
  5724.  
  5725. Here are some examples: 
  5726.  
  5727. LENGTH('abcdefgh')    ->    8
  5728. LENGTH('abc defg')    ->    8
  5729. LENGTH('')            ->    0
  5730.  
  5731.  
  5732. ΓòÉΓòÉΓòÉ 11.38. LINEIN ΓòÉΓòÉΓòÉ
  5733.  
  5734.  ΓöÇΓöÇLINEIN(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5735.              ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  5736.                            ΓööΓöÇlineΓöÇΓöÿ  ΓööΓöÇ,countΓöÇΓöÿ
  5737.  
  5738. LINEIN returns count (0 or 1) lines read from the character input stream name. 
  5739. The form of the name is implementation dependent. If name is omitted, the line 
  5740. is read from the default input stream, STDIN: in OS/2. The default count is 1. 
  5741.  
  5742. For persistent streams, a read position is maintained for each stream. In the 
  5743. OS/2 operating system, this is the same as the write position. Any read from 
  5744. the stream starts at the current read position by default. A call to LINEIN 
  5745. will return a partial line if the current read position is not at the start of 
  5746. a line. When the read is completed, the read position is moved to the beginning 
  5747. of the next line. The read position may be set to the beginning of the stream 
  5748. by giving line a value of 1- the only valid value for line in OS/2. 
  5749.  
  5750. If a count of 0 is given, then no characters are read and the null string is 
  5751. returned. 
  5752.  
  5753. For transient streams, if a complete line is not available in the stream, then 
  5754. execution of the program will normally stop until the line is complete. If, 
  5755. however, it is impossible for a line to be completed due to an error or other 
  5756. problem, the NOTREADY condition is raised and LINEIN returns whatever 
  5757. characters are available. 
  5758.  
  5759. Here are some examples: 
  5760.  
  5761. LINEIN()                      /* Reads one line from the    */
  5762.                               /* default input stream;      */
  5763.                               /* normally this is an entry  */
  5764.                               /* typed at the keyboard      */
  5765.  
  5766. myfile = 'ANYFILE.TXT'
  5767. LINEIN(myfile)     -> 'Current line' /* Reads one line from  */
  5768.                              /* ANYFILE.TXT, beginning     */
  5769.                              /* at the current read        */
  5770.                              /* position. (If first call,  */
  5771.                              /* file is opened and the     */
  5772.                              /* first line is read.)       */
  5773.  
  5774. LINEIN(myfile,1,1) ->'first line'  /* Opens and reads the first */
  5775.                              /* line of ANYFILE.TXT (if    */
  5776.                              /* the file is already open,  */
  5777.                              /* reads first line); sets    */
  5778.                              /* read position on the       */
  5779.                              /* second line.               */
  5780.  
  5781. LINEIN(myfile,1,0) ->  ''    /* No read; opens ANYFILE.TXT */
  5782.                               /* (if file is already open,  */
  5783.                               /* sets the read position to  */
  5784.                               /* the first line).           */
  5785.  
  5786. LINEIN(myfile,,0)  ->  ''  /* No read; opens ANYFILE.TXT */
  5787.                               /* (no action if the file is  */
  5788.                               /* already open).             */
  5789.  
  5790. LINEIN("QUEUE:") -> 'Queue line' /* Read a line from the queue; */
  5791.                               /* If the queue is empty, the  */
  5792.                               /* program waits until a line  */
  5793.                               /* is put on the queue.        */
  5794.  
  5795. Note:   If the intention is to read complete lines from the default character 
  5796.         stream, as in a simple dialogue with a user, use the PULL or PARSE PULL 
  5797.         instructions instead for simplicity and for improved programmability. 
  5798.         The PARSE LINEIN instruction is also useful in certain cases. 
  5799.  
  5800.  
  5801. ΓòÉΓòÉΓòÉ 11.39. LINEOUT ΓòÉΓòÉΓòÉ
  5802.  
  5803.  ΓöÇΓöÇLINEOUT(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5804.               ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  5805.                             ΓööΓöÇstringΓöÇΓöÿ  ΓööΓöÇ,lineΓöÇΓöÿ
  5806.  
  5807. LINEOUT returns the count of lines remaining after attempting to write string 
  5808. to the character output stream name. The count is either 0 (meaning the line 
  5809. was successfully written) or 1 (meaning that an error occurred while writing 
  5810. the line). string can be the null string, in which case only the action 
  5811. associated with completing a line is taken. LINEOUT adds a line-feed and a 
  5812. carriage-return character to the end of string. 
  5813.  
  5814. The form of the name is implementation dependent. If name is omitted, the line 
  5815. is written to the default output stream, STDOUT: (normally the display) in 
  5816. OS/2. 
  5817.  
  5818. For persistent streams, a write position is maintained for each stream. In the 
  5819. OS/2 operating system, this is the same as the read position. Any write to the 
  5820. stream starts at the current write position by default. Characters written by a 
  5821. call to LINEOUT can be added to a partial line. LINEOUT conceptually terminates 
  5822. a line at the end of each call. When the write is completed, the write position 
  5823. is set to the beginning of the line following the one just written. The initial 
  5824. write position is the end of the stream, so that calls to LINEOUT normally 
  5825. append lines to the end of the stream. 
  5826.  
  5827. You can set the write position to the first character of a persistent stream by 
  5828. giving a value of 1 (the only valid value) for line. 
  5829.  
  5830. Note:   In some environments, overwriting a stream using CHAROUT or LINEOUT can 
  5831.         erase (destroy) all existing data in the stream. This is not, however, 
  5832.         the case in the OS/2 environment. 
  5833.  
  5834. You can omit the string for persistent streams. If you specify line, the write 
  5835. position is set to the beginning of the stream, but nothing is written to the 
  5836. stream, and 0 is returned.  If you specify neither line nor string, the write 
  5837. position is set to the end of the stream. This use of LINEOUT has the effect of 
  5838. closing the stream in environments (such as the OS/2 environment) that support 
  5839. this concept. 
  5840.  
  5841. Execution of the program normally stops until the output operation is 
  5842. effectively completed. If, however, it is impossible for a line to be written, 
  5843. the NOTREADY condition is raised and LINEOUT returns with a result of 1 (that 
  5844. is, the residual count of lines written). 
  5845.  
  5846. Here are some examples: 
  5847.  
  5848. LINEOUT(,'Display this')    /* Writes string to the default   */
  5849.                             /* output stream (normally, the   */
  5850.                             /* display); returns 0 if         */
  5851.                             /* successful                     */
  5852.  
  5853. myfile = 'ANYFILE.TXT'
  5854. LINEOUT(myfile,'A new line')  /* Opens the file ANYFILE.TXT and */
  5855.                               /* appends the string to the end. */
  5856.                               /* If the file is already open,   */
  5857.                               /* the string is written at the   */
  5858.                               /* current write position.        */
  5859.                               /* Returns 0 if successful.       */
  5860.  
  5861. LINEOUT(myfile,'A new start',1)/* Opens the file (if not already */
  5862.                                /* open); overwrites first line   */
  5863.                                /* with a new line.               */
  5864.                                /* Returns 0 if successful.       */
  5865.  
  5866. LINEOUT(myfile,,1)            /* Opens the file (if not already */
  5867.                               /* open). No write; sets write    */
  5868.                               /* position at first character.   */
  5869.  
  5870. LINEOUT(myfile)               /* Closes ANYFILE.TXT             */
  5871.  
  5872. LINEOUT is often most useful when called as a subroutine. The return value is 
  5873. then available in the variable RESULT. For example: 
  5874.  
  5875. Call LINEOUT 'A:rexx.bat','Shell',1
  5876. Call LINEOUT ,'Hello'
  5877.  
  5878. Note:   If the lines are to be written to the default output stream without the 
  5879.         possibility of error, use the SAY instruction instead. 
  5880.  
  5881.  
  5882. ΓòÉΓòÉΓòÉ 11.40. LINES ΓòÉΓòÉΓòÉ
  5883.  
  5884.  ΓöÇΓöÇLINES(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5885.             ΓööΓöÇnameΓöÇΓöÿ
  5886.  
  5887. LINES returns 1 if any data remains between the current read position and the 
  5888. end of the character input stream name, and returns 0 if no data remains. In 
  5889. effect, LINES reports whether a read action performed by CHARIN or LINEIN will 
  5890. succeed. 
  5891.  
  5892. The form of the name is implementation dependent. If you omit name, then the 
  5893. presence or absence of data in the default input stream (STDIN:) is returned. 
  5894. For OS/2 devices, LINES always returns 1. 
  5895.  
  5896. Here are some examples: 
  5897.  
  5898. LINES(myfile)    ->    0    /* at end of the file   */
  5899.  
  5900. LINES()          ->    1    /* data remains in the  */
  5901.                             /* default input stream */
  5902.                             /* STDIN:         */
  5903.  
  5904. LINES("COM1:")   ->    1     /* An OS/2 device name  */
  5905.                             /* always returns '1'   */
  5906.  
  5907. Note:   The CHARS function returns the number of characters in a persistent 
  5908.         stream or the presence of data in a transient stream. 
  5909.  
  5910.  
  5911. ΓòÉΓòÉΓòÉ 11.41. MAX ΓòÉΓòÉΓòÉ
  5912.  
  5913.  ΓöÇΓöÇMAX(numberΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5914.                 ΓöéΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé
  5915.                 Γöé         ΓöéΓöé
  5916.                 ΓööΓö┤ΓöÇ,numberΓöÇΓö┤Γöÿ
  5917.  
  5918. MAX returns the largest number from the list specified, formatted according to 
  5919. the current setting of NUMERIC DIGITS. You can specify up to 20 numbers and can 
  5920. nest calls to MAX if more arguments are needed. 
  5921.  
  5922. Here are some examples: 
  5923.  
  5924. MAX(12,6,7,9)                              ->    12
  5925. MAX(17.3,19,17.03)                         ->    19
  5926. MAX(-7,-3,-4.3)                            ->    -3
  5927. MAX(1,2,3,4,5,6,7,8,9,MAX(10,11,12,13))    ->    13
  5928.  
  5929.  
  5930. ΓòÉΓòÉΓòÉ 11.42. MIN ΓòÉΓòÉΓòÉ
  5931.  
  5932.  ΓöÇΓöÇMIN(numberΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5933.                 ΓöéΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé
  5934.                 Γöé         ΓöéΓöé
  5935.                 ΓööΓö┤ΓöÇ,numberΓöÇΓö┤Γöÿ
  5936.  
  5937. MIN returns the smallest number from the list specified, formatted according to 
  5938. the current setting of NUMERIC DIGITS. Up to 20 numbers can be specified, 
  5939. although calls to MIN can be nested if more arguments are needed. 
  5940.  
  5941. Here are some examples: 
  5942.  
  5943. MIN(12,6,7,9)         ->     6
  5944. MIN(17.3,19,17.03)    ->    17.03
  5945. MIN(-7,-3,-4.3)       ->    -7
  5946.  
  5947.  
  5948. ΓòÉΓòÉΓòÉ 11.43. OVERLAY ΓòÉΓòÉΓòÉ
  5949.  
  5950.  ΓöÇΓöÇOVERLAY(new,target ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ
  5951.                          ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5952.                              ΓööΓöÇnΓöÇΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5953.                                        ΓöölengthΓöÿ Γöö,padΓöÿ
  5954.  
  5955. OVERLAY returns the string target, which, starting at the nth character, is 
  5956. overlaid with the string new, padded or truncated to length length. If length 
  5957. is specified, it must be positive or zero. If n is greater than the length of 
  5958. the target string, padding is added before the new string. The default pad 
  5959. character is a blank, and the default value for n is 1. If you specify n, it 
  5960. must be a positive whole number. 
  5961.  
  5962. Here are some examples: 
  5963.  
  5964. OVERLAY(' ','abcdef',3)         ->    'ab def'
  5965. OVERLAY('.','abcdef',3,2)       ->    'ab. ef'
  5966. OVERLAY('qq','abcd')            ->    'qqcd'
  5967. OVERLAY('qq','abcd',4)          ->    'abcqq'
  5968. OVERLAY('123','abc',5,6,'+')    ->    'abc+123+++'
  5969.  
  5970.  
  5971. ΓòÉΓòÉΓòÉ 11.44. POS ΓòÉΓòÉΓòÉ
  5972.  
  5973.  ΓöÇΓöÇPOS(needle,haystackΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5974.                           ΓööΓöÇ,startΓöÇΓöÇΓöÿ
  5975.  
  5976. POS returns the position of one string, needle, in another, haystack. (See also 
  5977. the LASTPOS function.) If the string needle is not found, 0 is returned. By 
  5978. default, the search starts at the first character of haystack (that is, the 
  5979. value of start is 1). You can override this by specifying start (which must be 
  5980. a positive whole number) as the point at which the search starts. 
  5981.  
  5982. Here are some examples: 
  5983.  
  5984. POS('day','Saturday')       ->    6
  5985. POS('x','abc def ghi')      ->    0
  5986. POS(' ','abc def ghi')      ->    4
  5987. POS(' ','abc def ghi',5)    ->    8
  5988.  
  5989.  
  5990. ΓòÉΓòÉΓòÉ 11.45. QUEUED ΓòÉΓòÉΓòÉ
  5991.  
  5992.  ΓöÇΓöÇQUEUED()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5993.  
  5994. QUEUED returns the number of lines remaining in the currently active REXX data 
  5995. queue at the time the function is invoked. 
  5996.  
  5997. Here is an example: 
  5998.  
  5999. QUEUED()    ->    5    /* Perhaps */
  6000.  
  6001.  
  6002. ΓòÉΓòÉΓòÉ 11.46. RANDOM ΓòÉΓòÉΓòÉ
  6003.  
  6004.  ΓöÇΓöÇRANDOM(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  6005.              Γö£ΓöÇmaxΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  6006.              Γö£ΓöÇmin,ΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6007.              ΓööΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇmaxΓöÇΓöÿ ΓööΓöÇ,seedΓöÇΓöÿ
  6008.  
  6009. RANDOM returns a quasi-random, nonnegative whole number in the range min to max 
  6010. inclusive. If only one argument is specified, the range will be from 0 to that 
  6011. number. Otherwise, the default values for min and max are 0 and 999, 
  6012. respectively. A specific seed (which must be a whole number) for the random 
  6013. number can be specified as the third argument if repeatable results are 
  6014. desired. 
  6015.  
  6016. The magnitude of the range (that is, max minus min) must not exceed 100000. 
  6017.  
  6018. Here are some examples: 
  6019.  
  6020. RANDOM()          ->    305
  6021. RANDOM(5,8)       ->      7
  6022. RANDOM(,,1983)    ->    123  /* reproducible */
  6023. RANDOM(2)         ->      0
  6024.  
  6025. Notes: 
  6026.  
  6027.  1. To obtain a predictable sequence of quasi-random numbers, use RANDOM a 
  6028.     number of times, but specify a seed only the first time. For example, to 
  6029.     simulate 40 throws of a six-sided, unbiased die, use: 
  6030.  
  6031.         sequence = RANDOM(1,6,12345)  /* any number would */
  6032.                                       /* do for a seed    */
  6033.         do 39
  6034.            sequence = sequence RANDOM(1,6)
  6035.            end
  6036.         say sequence
  6037.  
  6038.     The numbers are generated mathematically, using the initial seed, so that 
  6039.     as far as possible they appear to be random. Running the program again will 
  6040.     produce the same sequence; using a different initial seed almost certainly 
  6041.     produces a different sequence. 
  6042.  2. The random number generator is global for an entire program; the current 
  6043.     seed is not saved across internal routine calls. 
  6044.  3. The actual random number generator used may differ from implementation to 
  6045.     implementation. 
  6046.  
  6047.  
  6048. ΓòÉΓòÉΓòÉ 11.47. REVERSE ΓòÉΓòÉΓòÉ
  6049.  
  6050.  ΓöÇΓöÇREVERSE(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6051.  
  6052. REVERSE returns string, swapped end for end. 
  6053.  
  6054. Here are some examples: 
  6055.  
  6056. REVERSE('ABc.')    ->    '.cBA'
  6057. REVERSE('XYZ ')    ->    ' ZYX'
  6058.  
  6059.  
  6060. ΓòÉΓòÉΓòÉ 11.48. RIGHT ΓòÉΓòÉΓòÉ
  6061.  
  6062.  ΓöÇΓöÇRIGHT(string,lengthΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6063.                           ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  6064.  
  6065. RIGHT returns a string of length length containing the rightmost length 
  6066. characters of string. The string returned is padded with pad characters (or 
  6067. truncated) on the left as needed. The default pad character is a blank. length 
  6068. must be nonnegative. 
  6069.  
  6070. Here are some examples: 
  6071.  
  6072. RIGHT('abc  d',8)     ->    '  abc  d'
  6073. RIGHT('abc def',5)    ->    'c def'
  6074. RIGHT('12',5,'0')     ->    '00012'
  6075.  
  6076.  
  6077. ΓòÉΓòÉΓòÉ 11.49. SETLOCAL ΓòÉΓòÉΓòÉ
  6078.  
  6079.   ΓöÇΓöÇSETLOCAL()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6080.  
  6081. SETLOCAL saves the current working drive and directory, and the current values 
  6082. of the OS/2 environment variables that are local to the current process. 
  6083.  
  6084. For example, SETLOCAL can be used to save the current environment before 
  6085. changing selected settings with the VALUE function. To restore the drive, 
  6086. directory, and environment, use the ENDLOCAL function. 
  6087.  
  6088. SETLOCAL returns a value of 1 if the initial drive, directory, and environment 
  6089. are successfully saved, and a value of 0 if unsuccessful. If SETLOCAL is not 
  6090. followed by an ENDLOCAL function in a procedure, then the initial environment 
  6091. saved by SETLOCAL will be restored upon exiting the procedure. 
  6092.  
  6093. Here is an example: 
  6094.  
  6095. /* current path is 'C:\PROJ\FILES' */
  6096. n = SETLOCAL()        /* saves all environment settings    */
  6097.  
  6098. /* Now use the VALUE function to change the PATH variable. */
  6099. p = VALUE('Path','C:\PROC\PROGRAMS'.'OS2ENVIRONMENT')
  6100.  
  6101. /* Programs in directory C:\PROC\PROGRAMS may now be run   */
  6102.  
  6103. n = ENDLOCAL()  /* restores initial environment (including */
  6104.                 /* the changed PATH variable, which is   */
  6105.                 /* once again 'C:\PROJ\FILES'              */
  6106.  
  6107. Note:   Unlike their counterparts in the OS/2 Batch language (the Setlocal and 
  6108.         Endlocal statements), the REXX SETLOCAL and ENDLOCAL functions can be 
  6109.         nested. 
  6110.  
  6111.  
  6112. ΓòÉΓòÉΓòÉ 11.50. SIGN ΓòÉΓòÉΓòÉ
  6113.  
  6114.  ΓöÇΓöÇSIGN(number)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6115.  
  6116. SIGN returns a number that indicates the sign of number. number is first 
  6117. rounded according to standard REXX rules, just as though the operation number+0 
  6118. had been carried out. If number is less than 0, then -1 is returned; if it is 0 
  6119. then 0 is returned; and if it is greater than 0, 1 is returned. 
  6120.  
  6121. Here are some examples: 
  6122.  
  6123. SIGN('12.3')       ->     1
  6124. SIGN(' -0.307')    ->    -1
  6125. SIGN(0.0)          ->     0
  6126.  
  6127.  
  6128. ΓòÉΓòÉΓòÉ 11.51. SOURCELINE ΓòÉΓòÉΓòÉ
  6129.  
  6130.  ΓöÇΓöÇSOURCELINE(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6131.                  ΓööΓöÇΓöÇnΓöÇΓöÇΓöÿ
  6132.  
  6133. SOURCELINE returns the line number of the final line in the source file if you 
  6134. omit n, or returns the n th line in the source file if you specify n. 
  6135.  
  6136. If specified, n must be a positive whole number, and must not exceed the number 
  6137. of the final line in the source file. 
  6138.  
  6139. Here are some examples: 
  6140.  
  6141. SOURCELINE()    ->   10
  6142. SOURCELINE(1)   ->   '/* This is a 10-line program */'
  6143.  
  6144.  
  6145. ΓòÉΓòÉΓòÉ 11.52. SPACE ΓòÉΓòÉΓòÉ
  6146.  
  6147.  ΓöÇΓöÇSPACE(stringΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6148.                   ΓööΓöÇ,ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6149.                        ΓööΓöÇnΓöÇΓöÿ ΓööΓöÇΓöÇ,padΓöÇΓöÇΓöÿ
  6150.  
  6151. SPACE formats the blank-delimited words in string with n pad characters between 
  6152. each word. The n must be nonnegative. If it is 0, all blanks are removed. 
  6153. Leading and trailing blanks are always removed. The default for n is 1, and the 
  6154. default pad character is a blank. 
  6155.  
  6156. Here are some examples: 
  6157.  
  6158. SPACE('abc  def  ')          ->    'abc def'
  6159. SPACE('  abc def',3)         ->    'abc   def'
  6160. SPACE('abc  def  ',1)        ->    'abc def'
  6161. SPACE('abc  def  ',0)        ->    'abcdef'
  6162. SPACE('abc  def  ',2,'+')    ->    'abc++def'
  6163.  
  6164.  
  6165. ΓòÉΓòÉΓòÉ 11.53. STREAM ΓòÉΓòÉΓòÉ
  6166.  
  6167.  ΓöÇΓöÇΓöÇSTREAM(nameΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  6168.                    ΓööΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  6169.                           Γö£ΓöÇC,ΓöÇΓöÇstreamcommandΓöÇΓöñ
  6170.                           Γö£ΓöÇDΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  6171.                           ΓööΓöÇSΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  6172.  
  6173. STREAM returns a string describing the state of, or the result of an operation 
  6174. upon, the character stream name. This function is used to request information 
  6175. on the state of an input or output stream, or to carry out some specific 
  6176. operation on the stream. 
  6177.  
  6178. The first argument, name, specifies the stream to be accessed. The second 
  6179. argument can be one of the following strings (of which only the first letter is 
  6180. needed) which describes the action to be carried out: 
  6181.  
  6182. Command        an operation (specified by the streamcommand given as the third 
  6183.                argument) to be applied to the selected input or output stream. 
  6184.                The string that is returned depends on the command performed, 
  6185.                and can be the null string. 
  6186.  
  6187. Description    Also returns the current state of the specified stream. It is 
  6188.                identical to the State operation, except that the returned 
  6189.                string is followed by a colon and, if available, additional 
  6190.                information about ERROR or NOTREADY states. 
  6191.  
  6192. State          Returns a string that indicates the current state of the 
  6193.                specified stream. This is the default operation. 
  6194.  
  6195. When used with the State option, STREAM returns one of the following strings: 
  6196.  
  6197. 'ERROR'               The stream has been subject to an erroneous operation 
  6198.                       (possibly during input, output, or through the STREAM 
  6199.                       function. Additional information about the error may be 
  6200.                       available by invoking the STREAM function with a request 
  6201.                       for the implementation-dependent description. 
  6202.  
  6203. 'NOTREADY'            The stream is known to be in a state such that normal 
  6204.                       input or output operations attempted upon it would raise 
  6205.                       the NOTREADY condition. For example, a simple input 
  6206.                       stream may have a defined length; an attempt to read that 
  6207.                       stream (with the CHARIN or LINEIN built-in functions, 
  6208.                       perhaps) beyond that limit may make the stream 
  6209.                       unavailable until the stream has been closed, for 
  6210.                       example, with LINEIN(name), and then reopened. 
  6211.  
  6212. 'READY'               The stream is known to be in a state such that normal 
  6213.                       input or output operations can be attempted.  This is the 
  6214.                       usual state for a stream, though it does not guarantee 
  6215.                       that any particular operation will succeed. 
  6216.  
  6217. 'UNKNOWN'             The state of the stream is unknown. In OS/2 
  6218.                       implementations, this generally means that the stream is 
  6219.                       closed (or has not yet been opened). However, this 
  6220.                       response can be used in other environments to indicate 
  6221.                       that the state of the stream cannot be determined. 
  6222.  
  6223. Note:   The state (and operation) of an input or output stream is global to a 
  6224.         REXX program, in that it is not saved and restored across function and 
  6225.         subroutine calls (including those caused by a CALL ON condition trap). 
  6226.  
  6227. Stream Commands 
  6228.  
  6229. The following stream commands are used to: 
  6230.  
  6231. o Open a stream for reading or writing 
  6232. o Close a stream at the end of an operation 
  6233. o Position the read or write position within a persistent stream (for example, 
  6234.   a file) 
  6235. o Get information about a stream (its existence, size, and last edit date). 
  6236.  
  6237. The streamcommand argument must be used when you select the operation C 
  6238. (command). The syntax is: 
  6239.  
  6240.  ΓöÇΓöÇSTREAM(name,'C',streamcommand)ΓöÇΓöÇΓöÇΓöÇ
  6241.  
  6242. In this form, the STREAM function itself returns a string corresponding to the 
  6243. given streamcommand if the command is successful. If the command is 
  6244. unsuccessful, STREAM returns an error message string in the same form as that 
  6245. supplied by the D (Description) operation. 
  6246.  
  6247. Command strings - The argument streamcommand can be any expression that REXX 
  6248. evaluates as one of the following command strings: 
  6249.  
  6250. 'OPEN'              Opens the named stream. The default for 'OPEN' is to open 
  6251.                     the stream for both reading and writing data. To specify 
  6252.                     whether name is only to be read or only to be written to, 
  6253.                     add the word READ or WRITE to the command string. 
  6254.  
  6255.                     The STREAM function itself returns 'READY' if the named 
  6256.                     stream is successfully opened or an appropriate error 
  6257.                     message if unsuccessful. 
  6258.  
  6259.                     Examples: 
  6260.  
  6261.                                         stream(strout,'c','open')
  6262.                                         stream(strout,'c','open write')
  6263.                                         stream(strinp,'c','open read')
  6264.  
  6265. 'CLOSE'             Closes the named stream. The STREAM function itself returns 
  6266.                     'READY' if the named stream is successfully closed or an 
  6267.                     appropriate error message otherwise. If an attempt is made 
  6268.                     to close an unopened file, then STREAM() returns a null 
  6269.                     string (""). 
  6270.  
  6271.                     Example: 
  6272.  
  6273.                                         stream('STRM.TXT','c','close')
  6274.  
  6275. 'SEEK' offset       Sets the read or write position a given number (offset) 
  6276.                     within a persistent stream. 
  6277.  
  6278.                     Note:   In OS/2, the read and write positions are the same. 
  6279.                             To use this command, the named stream must first be 
  6280.                             opened (with the 'OPEN' stream command, described 
  6281.                             previously). 
  6282.  
  6283.                     The offset number can be preceded by one of the following 
  6284.                     characters: 
  6285.  
  6286.    =    Explicitly specifies the offset from the beginning of the stream.  This 
  6287.         is the default if no prefix is supplied. 
  6288.  
  6289.    <    Specifies offset from the end of the stream. 
  6290.  
  6291.    +    Specifies offset forward from the current read or write position. 
  6292.  
  6293.    -    Specifies offset backward from the current read or write position. 
  6294.  
  6295.                     The STREAM function itself returns the new position in the 
  6296.                     stream if the read or write position is successfully 
  6297.                     located; an appropriate error message is displayed 
  6298.                     otherwise. 
  6299.  
  6300.                     Examples: 
  6301.  
  6302.                                         stream(name,'c','seek =2')
  6303.                                         stream(name,'c','seek +15')
  6304.                                         stream(name,'c','seek -7')
  6305.                                         fromend  = 125
  6306.                                         stream(name,'c','seek <'fromend)
  6307.  
  6308. Used with these stream commands, the STREAM function returns specific 
  6309. information about a stream 
  6310.  
  6311. 'QUERY EXISTS'      Returns the full path specification of the named stream, if 
  6312.                     it exists, and a null string otherwise. 
  6313.  
  6314.                                         stream('..\file.txt','c','query exists')
  6315.  
  6316. 'QUERY SIZE'        Returns the size in bytes of a persistent stream. 
  6317.  
  6318.                                         stream('..\file.txt','c','query size')
  6319.  
  6320. 'QUERY DATETIME'    Returns the date and time stamps of a stream. 
  6321.  
  6322.                                         stream('..\file.txt','c','query datetime')
  6323.  
  6324.  
  6325. ΓòÉΓòÉΓòÉ 11.54. STRIP ΓòÉΓòÉΓòÉ
  6326.  
  6327.  ΓöÇΓöÇSTRIP(stringΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6328.                   ΓööΓöÇ,ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6329.                        ΓööΓöÇoptionΓöÇΓöÿ ΓööΓöÇ,charΓöÇΓöÿ
  6330.  
  6331. STRIP removes leading and trailing characters from string based on the option 
  6332. you specify. Valid options (of which only the capitalized letter is 
  6333. significant, all others are ignored) are: 
  6334.  
  6335. Both            Removes both leading and trailing characters from string. This 
  6336.                 is the default. 
  6337.  
  6338. Leading         Removes leading characters from string. 
  6339.  
  6340. Trailing        Removes trailing characters from string. 
  6341.  
  6342. The third argument, char, specifies the character to remove; The default is a 
  6343. blank.  If you specify char, it must be exactly one character long. 
  6344.  
  6345. Here are some examples: 
  6346.  
  6347. STRIP('  ab c  ')        ->    'ab c'
  6348. STRIP('  ab c  ','L')    ->    'ab c  '
  6349. STRIP('  ab c  ','t')    ->    '  ab c'
  6350. STRIP('12.7000',,0)      ->    '12.7'
  6351. STRIP('0012.700',,0)     ->    '12.7'
  6352.  
  6353.  
  6354. ΓòÉΓòÉΓòÉ 11.55. SUBSTR ΓòÉΓòÉΓòÉ
  6355.  
  6356.  ΓöÇΓöÇSUBSTR(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6357.                       ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6358.                           ΓööΓöÇlengthΓöÇΓöÿ ΓööΓöÇ,padΓöÇΓöÿ
  6359.  
  6360. SUBSTR returns the substring of string that begins at the nth character, and is 
  6361. of length length and padded with pad if necessary. n must be a positive whole 
  6362. number. 
  6363.  
  6364. If length is omitted, the rest of the string will be returned.  The default pad 
  6365. character is a blank. 
  6366.  
  6367. Here are some examples: 
  6368.  
  6369. SUBSTR('abc',2)          ->    'bc'
  6370. SUBSTR('abc',2,4)        ->    'bc  '
  6371. SUBSTR('abc',2,6,'.')    ->    'bc....'
  6372.  
  6373. Note:   In some situations the positional (numeric) patterns of parsing 
  6374.         templates are more convenient for selecting substrings, especially if 
  6375.         more than one substring is to be extracted from a string. 
  6376.  
  6377.  
  6378. ΓòÉΓòÉΓòÉ 11.56. SUBWORD ΓòÉΓòÉΓòÉ
  6379.  
  6380.  ΓöÇΓöÇSUBWORD(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6381.                        ΓööΓöÇ,lengthΓöÇΓöÇΓöÿ
  6382.  
  6383. SUBWORD returns the substring of string that starts at the nth word, and is of 
  6384. length length, blank-delimited words. n must be a positive whole number. If you 
  6385. omit length, it defaults to the number of remaining words in string. The 
  6386. returned string never has leading or trailing blanks, but includes all blanks 
  6387. between the selected words. 
  6388.  
  6389. Here are some examples: 
  6390.  
  6391. SUBWORD('Now is the  time',2,2)    ->    'is the'
  6392. SUBWORD('Now is the  time',3)      ->    'the  time'
  6393. SUBWORD('Now is the  time',5)      ->    ''
  6394.  
  6395.  
  6396. ΓòÉΓòÉΓòÉ 11.57. SYMBOL ΓòÉΓòÉΓòÉ
  6397.  
  6398.  ΓöÇΓöÇSYMBOL(name)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6399.  
  6400. SYMBOL returns the state of the symbol named by name. If name is not a valid 
  6401. REXX symbol, BAD is returned. SYMBOL returns VAR if it is the name of a 
  6402. variable (that is, a symbol that has been assigned a value). Otherwise, SYMBOL 
  6403. returns LIT, indicating that it is either a constant symbol or a symbol that 
  6404. has not yet been assigned a value (that is, a literal). 
  6405.  
  6406. As with symbols in REXX expressions, lowercase characters in name are 
  6407. translated to uppercase and substitution in a compound name occurs if possible. 
  6408.  
  6409. Note:   You should specify name as a literal string (or derived from an 
  6410.         expression) to prevent substitution before it is passed to the 
  6411.         function. 
  6412.  
  6413. Here are some examples: 
  6414.  
  6415. /* following: Drop A.3;  J=3 */
  6416. SYMBOL('J')      ->   'VAR'
  6417. SYMBOL(J)        ->   'LIT' /* has tested "3"     */
  6418. SYMBOL('a.j')    ->   'LIT' /* has tested "A.3"   */
  6419. SYMBOL(2)        ->   'LIT' /* a constant symbol  */
  6420. SYMBOL('*')      ->   'BAD' /* not a valid symbol */
  6421.  
  6422.  
  6423. ΓòÉΓòÉΓòÉ 11.58. TIME ΓòÉΓòÉΓòÉ
  6424.  
  6425.  ΓöÇΓöÇTIME(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6426.            ΓööΓöÇoptionΓöÇΓöÿ
  6427.  
  6428. TIME returns the local time in the 24-hour clock format hh:mm:ss (hours, 
  6429. minutes, and seconds) by default; for example: 
  6430.  
  6431. 04:41:37
  6432.  
  6433. You can use the following options (for which only the capitalized letter is 
  6434. needed) to obtain alternative formats, or to gain access to the elapsed-time 
  6435. clock: 
  6436.  
  6437. Civil             Returns hh:mmxx, the time in Civil format, in which the hours 
  6438.                   may take the values 1 through 12, and the minutes the values 
  6439.                   00 through 59.  The minutes are followed immediately by the 
  6440.                   letters "am" or "pm" to distinguish times in the morning 
  6441.                   (midnight 12:00am through 11:59am) from noon and afternoon 
  6442.                   (noon 12:00pm through 11:59pm).  The hour will not have a 
  6443.                   leading zero.  The minute field shows the current minute 
  6444.                   (rather than the nearest minute) for consistency with other 
  6445.                   TIME results. 
  6446.  
  6447. Elapsed           Returns sssssssss.uu0000, the number of seconds.hundredths 
  6448.                   since the elapsed time clock was stared or reset (see below). 
  6449.                   The returned number has no leading zeros, but always has four 
  6450.                   trailing zeros in the decimal portion. It is not affected by 
  6451.                   the setting of NUMERIC DIGITS. 
  6452.  
  6453. Hours             Returns number of hours since midnight in the format hh (no 
  6454.                   leading zeros). 
  6455.  
  6456. Long              Returns time in the format hh:mm:ss.uu0000 (where uu is the 
  6457.                   fraction of seconds in hundredths of a second). 
  6458.  
  6459. Minutes           Returns number of minutes since midnight in the format: mmmm 
  6460.                   (no leading zeros). 
  6461.  
  6462. Normal            Returns the time in the default format hh:mm:ss, as described 
  6463.                   above. 
  6464.  
  6465. Reset             Returns sssssssss.uu0000, the number of seconds.hundredths 
  6466.                   since the elapsed time clock was stared or reset (see below) 
  6467.                   and also resets the elapsed-time clock to zero. The returned 
  6468.                   number has no leading zeros, but always has four trailing 
  6469.                   zeros in the decimal portion. 
  6470.  
  6471. Seconds           Returns number of seconds since midnight in the format sssss 
  6472.                   (no leading zeros). 
  6473. Here are some examples: 
  6474.  
  6475. TIME('L')    ->   '16:54:22.120000'   /* Perhaps */
  6476. TIME()       ->   '16:54:22'
  6477. TIME('H')    ->   '16'
  6478. TIME('M')    ->   '1014'           /* 54 + 60*16 */
  6479. TIME('S')    ->   '60862'  /* 22 + 60*(54+60*16) */
  6480. TIME('N')    ->   '16:54:22'
  6481. TIME('C')    ->   '4:54pm'
  6482.  
  6483. The Elapsed-Time Clock 
  6484.  
  6485. The elapsed-time clock may be used for measuring real time intervals. On the 
  6486. first call to the elapsed-time clock, the clock is started, and both TIME('E') 
  6487. and TIME('R') will return 0. 
  6488.  
  6489. The clock is saved across internal routine calls, which is to say that an 
  6490. internal routine inherits the time clock its caller started.  Any timing the 
  6491. caller is doing is not affected even if an internal routine resets the clock. 
  6492.  
  6493. Here is an example of the elapsed-time clock: 
  6494.  
  6495. time('E')    ->    0          /* The first call */
  6496. /* pause of one second here */
  6497. time('E')    ->    1.020000   /* or thereabouts */
  6498. /* pause of one second here */
  6499. time('R')    ->    2.030000   /* or thereabouts */
  6500. /* pause of one second here */
  6501. time('R')    ->    1.050000   /* or thereabouts */
  6502.  
  6503. Note:   See the DATE function about consistency of times within a single 
  6504.         expression.  The elapsed-time clock is synchronized to the other calls 
  6505.         to TIME and DATE, so multiple calls to the elapsed-time clock in a 
  6506.         single expression always return the same result.  For the same reason, 
  6507.         the interval between two normal TIME and DATE results may be calculated 
  6508.         exactly using the elapsed-time clock. 
  6509.  
  6510. Implementation maximum: If the number of seconds in the elapsed time exceed 
  6511. nine digits (equivalent to over 31.6 years), an error will result. 
  6512.  
  6513.  
  6514. ΓòÉΓòÉΓòÉ 11.59. TRACE ΓòÉΓòÉΓòÉ
  6515.  
  6516.  ΓöÇΓöÇTRACE(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6517.             ΓööΓöÇoptionΓöÇΓöÿ
  6518.  
  6519. TRACE returns trace actions currently in effect. 
  6520.  
  6521. If option is supplied, it must be the valid prefix (?), one of the alphabetic 
  6522. character options (that is, starting with A, C, E, F, I, L, N, O, or R) 
  6523. associated with the TRACE instruction, or both. The function uses option to 
  6524. alter the effective trace action (such as tracing labels). Unlike the TRACE 
  6525. instruction, the TRACE function alters the trace action even if interactive 
  6526. debug is active. 
  6527.  
  6528. Unlike the TRACE instruction, option cannot be a number. 
  6529.  
  6530. Here are some examples: 
  6531.  
  6532. TRACE()       ->   '?R' /* maybe */
  6533. TRACE('O')    ->   '?R' /* also sets tracing off    */
  6534. TRACE('?I')   ->   'O'  /* now in interactive debug */
  6535.  
  6536.  
  6537. ΓòÉΓòÉΓòÉ 11.60. TRANSLATE ΓòÉΓòÉΓòÉ
  6538.  
  6539.  ΓöÇΓöÇTRANSLATE(string ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ
  6540.                        ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  6541.                            ΓööΓöÇtableoΓöÇΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  6542.                                           ΓöötableiΓöÿ Γöö,padΓöÿ
  6543.  
  6544. TRANSLATE translates characters in string to other characters, or reorders 
  6545. characters in a string. If neither translate table is given, string is simply 
  6546. translated to uppercase (for example, a lowercase a-z to an uppercase A-Z). The 
  6547. output table is tableo and the input translate table is tablei (the default is 
  6548. XRANGE('00'x,'FF'x)). The output table defaults to the null string and is 
  6549. padded with pad or truncated as necessary. The default pad is a blank. The 
  6550. tables can be of any length; the first occurrence of a character in the input 
  6551. table is the one that is used if there are duplicates. 
  6552.  
  6553. Here are some examples: 
  6554.  
  6555. TRANSLATE('abcdef')                        ->    'ABCDEF'
  6556. TRANSLATE('abbc','&','b')                  ->    'a&&c'
  6557. TRANSLATE('abcdef','12','ec')              ->    'ab2d1f'
  6558. TRANSLATE('abcdef','12','abcd','.')        ->    '12..ef'
  6559. TRANSLATE('4123','abcd','1234')            ->    'dabc'
  6560.  
  6561. Note:   The last example shows how to use the TRANSLATE function to reorder the 
  6562.         characters in a string.  In the example, the last character of any 
  6563.         four-character string specified as the second argument would be moved 
  6564.         to the beginning of the string. 
  6565.  
  6566.  
  6567. ΓòÉΓòÉΓòÉ 11.61. TRUNC ΓòÉΓòÉΓòÉ
  6568.  
  6569.  ΓöÇΓöÇΓöÇTRUNC(number ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6570.                     ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  6571.  
  6572. TRUNC returns the integer part of number, and n decimal places. The default n 
  6573. is zero, and it returns an integer with no decimal point. If you specify n, it 
  6574. must be a nonnegative whole number. The number is first rounded according to 
  6575. standard REXX rules, just as though the operation number+0 had been carried 
  6576. out. The number is then truncated to n decimal places (or trailing zeros are 
  6577. added if needed to make up the specified length). The result is never in 
  6578. exponential form. 
  6579.  
  6580. Here are some examples: 
  6581.  
  6582. TRUNC(12.3)           ->    12
  6583. TRUNC(127.09782,3)    ->    127.097
  6584. TRUNC(127.1,3)        ->    127.100
  6585. TRUNC(127,2)          ->    127.00
  6586.  
  6587. Note:   The number is rounded according to the current setting of NUMERIC 
  6588.         DIGITS if necessary before being processed by the function. 
  6589.  
  6590.  
  6591. ΓòÉΓòÉΓòÉ 11.62. VALUE ΓòÉΓòÉΓòÉ
  6592.  
  6593.  ΓöÇVALUE(nameΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ)ΓöÇΓöÇΓöÇ
  6594.                  ΓööΓöÇ,ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6595.                       ΓööΓöÇnewvalueΓöÇΓöÇΓöÿ ΓööΓöÇ,selectorΓöÇΓöÿ
  6596.  
  6597. VALUE returns the value of the symbol named by name, and optionally assigns it 
  6598. a new value. By default, VALUE refers to the current REXX-variables 
  6599. environment, but other, external collections of variables may be selected. If 
  6600. you use the function to refer to REXX variables, then name must be a valid REXX 
  6601. symbol. (You can confirm this by using the SYMBOL function.) Lowercase 
  6602. characters in name are translated to uppercase. If name is a compound symbol, 
  6603. then REXX substitutes symbol values to produce the derived name of the symbol. 
  6604.  
  6605. If you specify newvalue, then the named variable is assigned this new value. 
  6606. This does not affect the result returned; that is, the function returns the 
  6607. value of name as it was before the new assignment. 
  6608.  
  6609. Here are some examples: 
  6610.  
  6611.      /* After: Drop A3; A33=7; K=3; fred='K'; list.5='Hi' */
  6612.      VALUE('a'k)     ->  'A3'
  6613.      VALUE('a'k||k)  ->  '7'
  6614.      VALUE('fred')   ->  'K'  /* looks up FRED   */
  6615.      VALUE(fred)     ->  '3'  /* looks up K      */
  6616.      VALUE(fred,5)   ->  '3'  /* and sets K=5    */
  6617.      VALUE(fred)     ->  '5'
  6618.      VALUE('LIST.'k) ->  'Hi' /* looks up LIST.5 */
  6619.  
  6620. To use VALUE to manipulate OS/2 environment variables, selector must be the 
  6621. string 'OS2ENVIRONMENT' or an expression so evaluated. In this case, the 
  6622. variable name need not be a valid REXX symbol. When VALUE is used to set or 
  6623. change the value of an environment variable, the new value is retained after 
  6624. the REXX procedure ends. 
  6625.  
  6626. Here are some examples: 
  6627.  
  6628. /* Given that an external variable FRED has a value of 4      */
  6629. share = 'OS2ENVIRONMENT'
  6630. say VALUE('fred',7,share)      /* says '4' and assigns        */
  6631.                                /* FRED a new value of 7       */
  6632.  
  6633. say VALUE('fred',,share)       /* says '7'                    */
  6634.  
  6635. /* After this procedure ends, FRED again has a value of 4     */
  6636.  
  6637. /* Accessing and changing OS/2 environment entries            */
  6638. env = 'OS2ENVIRONMENT'
  6639. new = 'C:\LIST\PROD;'
  6640. say value('prompt',,env)   /* says '$i[p]' (perhaps)          */
  6641. say value('path',new,env)  /* says 'C:\EDIT\DOCS;' (perhaps)  */
  6642.                            /* and sets PATH = 'C:LIST\PROD'   */
  6643.  
  6644. say value('path',,env)     /* says 'C:LIST\PROD'              */
  6645.  
  6646. /* When this procedure ends, PATH = 'C:\LIST\PROD'           */
  6647.  
  6648. Notes: 
  6649.  
  6650.  1. If the VALUE function refers to an uninitialized REXX variable, then the 
  6651.     default value of the variable is always returned; the NOVALUE condition is 
  6652.     not raised. NOVALUE is never raised by a reference to an external 
  6653.     collection of variables. 
  6654.  
  6655.  2. The VALUE function is used when a variable contains the name of another 
  6656.     variable, or when a name is constructed dynamically. If the name is 
  6657.     specified as a single literal string, the symbol is a constant and so the 
  6658.     whole function call can usually be replaced directly by the string between 
  6659.     the quotation marks.  (For example, fred=VALUE('k'); is identical to the 
  6660.     assignment fred=k;,unless the NOVALUE condition is being trapped. 
  6661.  
  6662.  3. To effect temporary changes to environment variables, use the SETLOCAL and 
  6663.     ENDLOCAL functions. 
  6664.  
  6665.  
  6666. ΓòÉΓòÉΓòÉ 11.63. VERIFY ΓòÉΓòÉΓòÉ
  6667.  
  6668.  ΓöÇΓöÇVERIFY(string,referenceΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  6669.                              ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6670.                                  ΓööΓöÇoptionΓöÇΓöÇΓöÿ ΓööΓöÇ,startΓöÇΓöÿ
  6671.  
  6672. VERIFY returns a number indicating whether string is composed only of 
  6673. characters from reference. VERIFY returns the position of the first character 
  6674. in string that is not also in reference.  If all the characters were found in 
  6675. reference, 0 is returned. 
  6676.  
  6677. The third argument, option, can be any expression that results in a string 
  6678. starting with N or M that represents either Nomatch (the default) or Match.. 
  6679. Only the first character of option is significant and it can be in uppercase or 
  6680. lowercase, as usual. If Nomatch is specified, the position of the first 
  6681. character in string that is not also in reference is returned. 0 is returned if 
  6682. all characters in string were found in reference. If Match is specified, the 
  6683. position of the first character in string that is in reference is returned, or 
  6684. 0 is returned if none of the characters were found. 
  6685.  
  6686. The default for start is 1, thus, the search starts at the first character of 
  6687. string. You can override this by specifying a different start point, which must 
  6688. be a positive whole number. 
  6689.  
  6690. VERIFY always returns 0 if string is null or if start is greater than 
  6691. LENGTH(string). If reference is null, VERIFY returns 0 if you specify Match; 
  6692. otherwise, 1 is returned. 
  6693.  
  6694. Here are some examples: 
  6695.  
  6696. VERIFY('123','1234567890')             ->    0
  6697. VERIFY('1Z3','1234567890')             ->    2
  6698. VERIFY('AB4T','1234567890')            ->    1
  6699. VERIFY('AB4T','1234567890','M')        ->    3
  6700. VERIFY('AB4T','1234567890','N')        ->    1
  6701. VERIFY('1P3Q4','1234567890',,3)        ->    4
  6702. VERIFY('AB3CD5','1234567890','M',4)    ->    6
  6703.  
  6704.  
  6705. ΓòÉΓòÉΓòÉ 11.64. WORD ΓòÉΓòÉΓòÉ
  6706.  
  6707.  ΓöÇΓöÇΓöÇWORD(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6708.  
  6709. WORD returns the n th blank-delimited word in string. n must be a positive 
  6710. whole number. If there are fewer than n words in string, the null string is 
  6711. returned. This function is equivalent to SUBWORD(string,n,1). 
  6712.  
  6713. Here are some examples: 
  6714.  
  6715. WORD('Now is the time',3)    ->    'the'
  6716. WORD('Now is the time',5)    ->    ''
  6717.  
  6718.  
  6719. ΓòÉΓòÉΓòÉ 11.65. WORDINDEX ΓòÉΓòÉΓòÉ
  6720.  
  6721.  ΓöÇΓöÇΓöÇWORDINDEX(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6722.  
  6723. WORDINDEX returns the position of the first character in the n th 
  6724. blank-delimited word in string. n must be a positive whole number. If there are 
  6725. fewer than n words in the string, 0 is returned. 
  6726.  
  6727. Here are some examples: 
  6728.  
  6729. WORDINDEX('Now is the time',3)    ->    8
  6730. WORDINDEX('Now is the time',6)    ->    0
  6731.  
  6732.  
  6733. ΓòÉΓòÉΓòÉ 11.66. WORDLENGTH ΓòÉΓòÉΓòÉ
  6734.  
  6735.  ΓöÇΓöÇΓöÇWORDLENGTH(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6736.  
  6737. WORDLENGTH returns the length of the n th blank-delimited word in string. n 
  6738. must be a positive whole number. If there are fewer than n words in the string, 
  6739. 0 is returned. 
  6740.  
  6741. Here are some examples: 
  6742.  
  6743. WORDLENGTH('Now is the time',2)       ->    2
  6744. WORDLENGTH('Now comes the time',2)    ->    5
  6745. WORDLENGTH('Now is the time',6)       ->    0
  6746.  
  6747.  
  6748. ΓòÉΓòÉΓòÉ 11.67. WORDPOS ΓòÉΓòÉΓòÉ
  6749.  
  6750.  ΓöÇΓöÇΓöÇWORDPOS(phrase,stringΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6751.                              ΓööΓöÇ,startΓöÇΓöÇΓöÿ
  6752.  
  6753. WORDPOS searches string for the first occurrence of the sequence of 
  6754. blank-delimited words phrase, and returns the word number of the first word of 
  6755. phrase in string.  Multiple blanks between words in either phrase or string are 
  6756. treated as a single blank for the comparison, but otherwise the words must 
  6757. match exactly. 
  6758.  
  6759. By default, the search starts at the first word in string. You can override 
  6760. this by specifying start (which must be positive), the word at which to start 
  6761. the search. 
  6762.  
  6763. Here are some examples: 
  6764.  
  6765. WORDPOS('the','now is the time')              ->  3
  6766. WORDPOS('The','now is the time')              ->  0
  6767. WORDPOS('is the','now is the time')           ->  2
  6768. WORDPOS('is   the','now is the time')         ->  2
  6769. WORDPOS('is   time ','now is   the time')     ->  0
  6770. WORDPOS('be','To be or not to be')            ->  2
  6771. WORDPOS('be','To be or not to be',3)          ->  6
  6772.  
  6773.  
  6774. ΓòÉΓòÉΓòÉ 11.68. WORDS ΓòÉΓòÉΓòÉ
  6775.  
  6776.  ΓöÇΓöÇΓöÇWORDS(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6777.  
  6778. WORDS returns the number of blank-delimited words in string. 
  6779.  
  6780. Here are some examples: 
  6781.  
  6782. WORDS('Now is the time')    ->    4
  6783. WORDS(' ')                  ->    0
  6784.  
  6785.  
  6786. ΓòÉΓòÉΓòÉ 11.69. XRANGE ΓòÉΓòÉΓòÉ
  6787.  
  6788.  ΓöÇΓöÇΓöÇXRANGE(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6789.               ΓööΓöÇstartΓöÇΓöÿ  ΓööΓöÇ,endΓöÇΓöÇΓöÿ
  6790.  
  6791. XRANGE returns a string of all one-byte codes between and including the values 
  6792. start and end. The default value for start is `00'x, and the default value for 
  6793. end is `FF'x. If start is greater than end, the values wrap from `FF'x to 
  6794. `00'x. If specified, start and end must be single characters. 
  6795.  
  6796. Here are some examples: 
  6797.  
  6798. XRANGE('a','f')      ->   'abcdef'
  6799. XRANGE('03'x,'07'x)  ->   '0304050607'x
  6800. XRANGE(,'04'x)       ->   '0001020304'x
  6801. XRANGE('i','j')      ->   '898A8B8C8D8E8F9091'x  /* EBCDIC */
  6802. XRANGE('FE'x,'02'x)  ->   'FEFF000102'x
  6803. XRANGE('i','j')      ->   'ij'                   /* ASCII  */
  6804.  
  6805.  
  6806. ΓòÉΓòÉΓòÉ 11.70. X2B (Hexadecimal to Binary). ΓòÉΓòÉΓòÉ
  6807.  
  6808.  ΓöÇΓöÇΓöÇX2B(hexstring)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6809.  
  6810. X2B converts hexstring (a string of hexadecimal characters) to an equivalent 
  6811. string of binary digits. hexstring can be of any length; each hexidecimal 
  6812. character is converted to a string of four binary digits. The returned string 
  6813. has a length that is a multiple of four, and does not include any blanks. 
  6814.  
  6815. Blanks can optionally be added (at byte boundaries only, not leading or 
  6816. trailing) to aid readability; they are ignored. 
  6817.  
  6818. If hexstring is null, X2B returns 0. 
  6819.  
  6820. Here are some examples: 
  6821.  
  6822. X2B('C3')        ==  '11000011'
  6823. X2B('7')         ==  '0111'
  6824. X2B('1 C1')      ==  '000111000001'
  6825.  
  6826. You can combine X2B( ) may be combined with the functions D2X( ) and C2X( ) to 
  6827. convert decimal numbers or character strings into binary form. 
  6828.  
  6829. Here are some examples: 
  6830.  
  6831. X2B(C2X('C3'x))  ==  '11000011'
  6832. X2B(D2X('129'))  ==  '10000001'
  6833. X2B(D2X('12'))   ==  '1100'
  6834.  
  6835.  
  6836. ΓòÉΓòÉΓòÉ 11.71. X2C (Hexadecimal to Character) ΓòÉΓòÉΓòÉ
  6837.  
  6838.  ΓöÇΓöÇΓöÇX2C(hexstring)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6839.  
  6840. X2C converts hexstring (a string of hexadecimal characters) to character. 
  6841.  
  6842. hexstring can be of any length. You can optionally add blanks to hexstring (at 
  6843. byte boundaries only, not leading or trailing positions) to aid readability; 
  6844. they are ignored. 
  6845.  
  6846. If necessary, hexstring is padded with a leading 0 to make an even number of 
  6847. hexadecimal digits. 
  6848.  
  6849. Here are some examples: 
  6850.  
  6851. X2C('4865 6c6c 6f') ->  'Hello'     /*  ASCII   */
  6852. X2C('3732 73')      ->  '72s'       /*  ASCII   */
  6853. X2C('F')          ->    '0F'x
  6854.  
  6855.  
  6856. ΓòÉΓòÉΓòÉ 11.72. X2D (Hexadecimal to Decimal) ΓòÉΓòÉΓòÉ
  6857.  
  6858.  ΓöÇΓöÇΓöÇX2D(hexstring ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6859.                      ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  6860.  
  6861. X2D converts hexstring (a string of hexadecimal characters) to decimal. If the 
  6862. result cannot be expressed as a whole number, an error results. That is, the 
  6863. result must have no more digits than the current setting of NUMERIC DIGITS. 
  6864.  
  6865. You can optionally add blanks to hexstring (at byte boundaries only, not 
  6866. leading or trailing positions) to aid readability; they are ignored. 
  6867.  
  6868. If hexstring is null, X2D returns 0. 
  6869.  
  6870. If n is not specified, hexstring is processed as an unsigned binary number. 
  6871.  
  6872. Here are some examples: 
  6873.  
  6874. X2D('0E')        ->    14
  6875. X2D('81')        ->    129
  6876. X2D('F81')       ->    3969
  6877. X2D('FF81')      ->    65409
  6878. X2D('c6 f0'X)    ->    240
  6879.  
  6880. If n is specified, the given sequence of hexadecimal digits is padded on the 
  6881. left with zeros (note, not sign-extended), or truncated on the left to n 
  6882. characters. The resulting string of n hexadecimal digits is taken to be a 
  6883. signed binary number-positive if the leftmost bit is OFF, and negative, in 
  6884. two's complement notation, if the leftmost bit is ON. If n is 0, X2D returns 0. 
  6885.  
  6886. Here are some examples: 
  6887.  
  6888. X2D('81',2)      ->    -127
  6889. X2D('81',4)      ->    129
  6890. X2D('F081',4)    ->    -3967
  6891. X2D('F081',3)    ->    129
  6892. X2D('F081',2)    ->    -127
  6893. X2D('F081',1)    ->    1
  6894. X2D('0031',0)    ->    0
  6895.  
  6896.  
  6897. ΓòÉΓòÉΓòÉ 12. Queue Interface ΓòÉΓòÉΓòÉ
  6898.  
  6899. REXX provides queuing services entirely separate from the OS/2 interprocess 
  6900. communications queues. The queues discussed here are solely for the use of REXX 
  6901. programs. 
  6902.  
  6903. REXX queues are manipulated within a program by these instructions: 
  6904.  
  6905. PUSH        Stacks a string on top of the queue (LIFO). 
  6906.  
  6907. QUEUE       Adds a string to the tail of the queue (FIFO). 
  6908.  
  6909. PULL        Reads a string from the head of the queue. If the queue is empty, 
  6910.             input is taken from the console (STDIN:). 
  6911.  
  6912. To get the number of items remaining in the queue, use the function QUEUED. 
  6913.  
  6914. Access to Queues 
  6915.  
  6916. There are two kinds of queues in REXX. Both kinds are accessed and processed by 
  6917. name. 
  6918.  
  6919. Session Queues - One session queue is automatically provided for each OS/2 
  6920. session in operation. Its name is always SESSION, and it is created by REXX the 
  6921. first time information is put on the queue by a program or procedure. All 
  6922. processes (programs and procedures) in a session can access the session queue. 
  6923. However, a given process can only access the session queue defined for its 
  6924. session, and the session queue is not unique to any single process in the 
  6925. session. 
  6926.  
  6927. Private Queues - Private queues are created (and deleted) by your program. You 
  6928. can name the queue yourself or leave the naming to REXX. In order for your 
  6929. program to use any queue, it must know the name of the queue. 
  6930.  
  6931.  
  6932. ΓòÉΓòÉΓòÉ 12.1. RXQUEUE Function ΓòÉΓòÉΓòÉ
  6933.  
  6934. Use the RxQueue function in a REXX program to create and delete queues and to 
  6935. set and query their names. The first parameter determines the function, the 
  6936. entire function name must be specified but the case of the function parameter 
  6937. is ignored. 
  6938.  
  6939. Syntax: 
  6940.  
  6941.  
  6942.  ΓöÇΓöÇRXQUEUE(ΓöÇΓö¼ΓöÇΓöÇ"Create"ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6943.               Γöé            ΓööΓöÇ,queuename ΓöÇΓöÿ Γöé
  6944.               Γö£ΓöÇΓöÇΓöÇ"Delete"ΓöÇΓöÇ queuename ΓöÇΓöÇΓöÇΓöÇΓöñ
  6945.               Γö£ΓöÇΓöÇΓöÇ"Get"ΓöÇΓöÇΓöÇΓöÇΓöÇ newqueuename ΓöÇΓöñ
  6946.               ΓööΓöÇΓöÇΓöÇ"Set"ΓöÇΓöÇΓöÇΓöÇΓöÇ newqueuename ΓöÇΓöÿ
  6947.  
  6948. Parameters: 
  6949.  
  6950. Create            Creates a queue with the name, queuename (if specified); if 
  6951.                   no name is specified, then REXX will provide a name. Returns 
  6952.                   the name of the queue in either case. 
  6953.  
  6954. Delete            Deletes the named queue; returns 0 if successful, a nonzero 
  6955.                   number if an error occurs; the possible return values are: 
  6956.  
  6957.    0           Queue has been deleted. 
  6958.  
  6959.    5           Not a valid queue name. 
  6960.  
  6961.    9           Queue named does not exist. 
  6962.  
  6963.    10          Queue is busy; wait is active. 
  6964.  
  6965.    12          A memory failure has occurred. 
  6966.  
  6967.    1000        Initialization error; check file OS/2.INI 
  6968.  
  6969. Get               Returns the name of the queue currently in use. 
  6970.  
  6971. Set               Sets the name of the current queue to newqueuename and 
  6972.                   returns the previous name of the queue. 
  6973.  
  6974. Example: Sample Queue in a REXX Procedure 
  6975.  
  6976.  
  6977. /*                                                                */
  6978. /*        push/pull WITHOUT multiprogramming support         */
  6979. /*                                                                */
  6980. push date() time()          /* push date and time            */
  6981. do 1000                     /* lets pass some time           */
  6982.   nop                       /* doing nothing                 */
  6983. end                         /* end of loop                   */
  6984. pull a b .                  /* pull them                     */
  6985. say 'Pushed at ' a b ', Pulled at ' date()
  6986. time() /* say now and then */
  6987.  
  6988. /*                                                                    */
  6989. /*              push/pull WITH multiprogramming support               */
  6990. /*            (no error recovery, or unsupported env tests            */
  6991. /*                                                                    */
  6992. newq = RXQUEUE('Create')    /* create a unique queue           */
  6993. oq = RXQUEUE('Set',newq)    /* establish new queue             */
  6994. push date() time()          /* push date and time              */
  6995. do 1000                     /* lets spend some time            */
  6996.   nop                       /* doing nothing                   */
  6997. end                         /* end of loop                     */
  6998. pull a b .                  /* get pushed info                 */
  6999. say 'Pushed at ' a b ', Pulled at ' date() time() /* tell user     */
  7000. call RXQUEUE 'Delete',newq         /* destroy unique queue created  */
  7001. call RXQUEUE 'Set',oq         /* reset to default queue (not required)*/
  7002.  
  7003. Special Considerations 
  7004.  
  7005.  1. External programs that must communicate with a REXX procedure by means of 
  7006.     defined data queues can use the default queue or the session queue, or they 
  7007.     can receive the data queue name by some interprocess communication 
  7008.     technique. This could include parameter passing, placement on a prearranged 
  7009.     logical queue, or use of normal OS/2 Inter-Process Communication mechanisms 
  7010.     (for example, pipes, shared memory or IPC queues). 
  7011.  
  7012.  2. Named queues are available across the entire system; therefore, the names 
  7013.     of queues must be unique within the system.  If a queue named os2que exists 
  7014.     and this function is issued: 
  7015.  
  7016.         newqueue = RXQUEUE('Create', 'os2que')
  7017.  
  7018.     a new queue is created and the name is chosen by REXX.  This new name is 
  7019.     returned by the function. 
  7020.  
  7021.  3. Any external program started inherits as its default queue the queue in use 
  7022.     by the parent process. 
  7023.  
  7024. Detached Processes 
  7025.  
  7026.  1. Detached processes will access a detached session queue that is unique for 
  7027.     each detached process. Note, however, that this detached session queue is 
  7028.     not the same as the session queue of the starting session. 
  7029.  
  7030.  2. REXX programs that are to be run as detached processes cannot perform any 
  7031.     SAY instructions or any PULL or PARSE PULL instructions that involve 
  7032.     terminal I/O. However, PULL and PARSE PULL instructions that act on a queue 
  7033.     are permitted in detached processes. 
  7034.  
  7035. Multi-Programming Considerations 
  7036.  
  7037. This data queue mechanism differs from OS/2 standard API queueing in the 
  7038. following ways: 
  7039.  
  7040.  1. The queue is NOT owned by a specific process, and as such any process is 
  7041.     entitled to modify the queue at any time.  The operations that effect the 
  7042.     queue are atomic, in that the resource will be serialized by the subsystem 
  7043.     such that no data integrity problems can be encountered. 
  7044.  
  7045.     However, synchronization of requests such that two processes, accessing the 
  7046.     same queue, get the data in the order it was placed on the queue is a user 
  7047.     responsibility and will not be provided by the subsystem support code. This 
  7048.     selector is owned by the calling application code and must be freed by the 
  7049.     caller using DosFreeSeg. 
  7050.  
  7051.  2. A regular OS/2 IPC queue is owned (created) by a specific process. When 
  7052.     that process terminates, the queue is destroyed. Conversely, the queues 
  7053.     created by the RxQueue('Create', queuename) call will exist until 
  7054.     EXPLICITLY deleted. Termination of a program or procedure that created a 
  7055.     private queue does not force the deletion of the private queue. Any data on 
  7056.     the queue when the process creating it terminates will remain on the queue 
  7057.     until either the queue is deleted (by way of the REXX function call 
  7058.     RxQueue('Create', queuename) or until the data is read. 
  7059.  
  7060. Data queues must be explicitly deleted by some procedure or program (not 
  7061. necessarily the creator). Deletion of a queue with remaining items, destroys 
  7062. those items. If a queue is not deleted, it will be lost and cannot be recovered 
  7063. accept by randomly attempting to access each queue in the defined series. 
  7064.  
  7065.  
  7066. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  7067.  
  7068. A batch file contains a series of commands that you would enter, one at a time, 
  7069. at a command prompt for a particular process.  Instead, you simply type the 
  7070. name of the file.  Using a batch file shortens process time and reduces the 
  7071. possibility of typing errors.  Batch files in DOS sessions have a .BAT 
  7072. extension and in OS/2 sessions a .CMD extension.  For more information about 
  7073. batch files, see the Command Reference.