home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 14 / 14.iso / s / s005 / 16.ddi / REXXPUBS / OS2_BOOK_REXX.INF (.txt)
Encoding:
OS/2 Help File  |  1993-04-29  |  197.2 KB  |  7,144 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.1 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.       ABORTRETRYIGNORE      An Abort button, a Retry button and an Ignore 
  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. SysCreateObject ΓòÉΓòÉΓòÉ
  1781.  
  1782. Function: SysCreateObject 
  1783.  
  1784. Syntax:   result = SysCreateObject(classname, title, location <,setup> 
  1785.           <,option>) 
  1786.  
  1787.    classname         The name of the object class. 
  1788.  
  1789.    title             The object title. 
  1790.  
  1791.    location          The object location.  This can be specified as either an 
  1792.                      object ID (for example, <WP_DESKTOP>) or a file system 
  1793.                      path (for example, C:\bin\mytools). 
  1794.  
  1795.    setup             A WinCreateObject setup string. 
  1796.  
  1797.    option            The action taken if the object already exists.  Allowed 
  1798.                      options are: "fail", "replace" (delete existing object and 
  1799.                      create new object), and "update" (update the settings of 
  1800.                      the existing object).  Only the first letter of the option 
  1801.                      is needed; all others are ignored. 
  1802.  
  1803.    result            The return code from WinCreateObject.  This returns 1 
  1804.                      (TRUE) if the object was created and 0 (FALSE) if the 
  1805.                      object was not created. 
  1806.  
  1807.    Purpose:          Create a new instance of an object class. 
  1808.  
  1809.                     Examples:
  1810.  
  1811.                       /* Code   */
  1812.                        If  SysCreateObject("WPFolder","Mail Folder","<WP_DESKTOP>")
  1813.                          Say 'Mail Folder successfully created'
  1814.  
  1815.                       /* Create a folder object, and then create a program object */
  1816.                       /* in that folder.*/
  1817.                        If SysCreateObject("WPFolder", "MyFolder", "C:\",,
  1818.                                      "OBJECTID=<MYFOLDER>") Then Do
  1819.                        If SysCreateObject("WPProgram", "MyProgram", "<MYFOLDER>",,
  1820.                                      "EXENAME=C:\TOOLS\MYPRG.EXE")  Then
  1821.                               Say 'Folder "MyFolder" and Program "MyProgram" have been created'
  1822.                            Else Say 'Could not create program "MyProgram"'
  1823.                            End
  1824.                          Else Say 'Could not create folder "MyFolder"'
  1825.  
  1826.  
  1827. ΓòÉΓòÉΓòÉ 9.4. SysCurPos ΓòÉΓòÉΓòÉ
  1828.  
  1829. Function: SysCurPos 
  1830.  
  1831. Syntax:   pos = SysCurPos(row, col) 
  1832.  
  1833.    pos       The position of the cursor upon the calling of SysCurPos in the 
  1834.              form 'row col'. 
  1835.  
  1836.    row       The row on the screen to move to. 
  1837.  
  1838.    col       The column on the screen to move to. 
  1839.  
  1840.              Note:   Position (0,0) is at the upper left.  You may call 
  1841.              SysCurPos without parameters to check the current cursor position 
  1842.              without changing it. 
  1843.  
  1844. Purpose:  Move the cursor to the specified row and column and/or query the 
  1845.           current/previous cursor position. 
  1846.  
  1847.                     Example:
  1848.  
  1849.                      /* Code */
  1850.                      call SysCls
  1851.                      parse value SysCurPos() with row col
  1852.                      say 'Cursor position is 'row', 'col
  1853.  
  1854.                      /* Output */
  1855.                      Cursor position is 0, 0
  1856.  
  1857.  
  1858. ΓòÉΓòÉΓòÉ 9.5. SysCurState ΓòÉΓòÉΓòÉ
  1859.  
  1860. Function: SysCurState 
  1861.  
  1862. Syntax:   SysCurState state 
  1863.  
  1864.    state     The desired state which to set the cursor.  Should be one of the 
  1865.              following: 
  1866.  
  1867.       'ON'      Display the cursor. 
  1868.  
  1869.       'OFF'     Hide the cursor. 
  1870.  
  1871. Purpose:  Use this function to hide or display the cursor. 
  1872.  
  1873.  
  1874. ΓòÉΓòÉΓòÉ 9.6. SysDeregisterObjectClass ΓòÉΓòÉΓòÉ
  1875.  
  1876. Function: SysDeregisterObjectClass 
  1877.  
  1878. Syntax:   result = SysDeregisterObjectClass(classname) 
  1879.  
  1880.    classname         The name of the object class to deregister. 
  1881.  
  1882.    result            The return code from WinDeregisterObjectClass.  This 
  1883.                      returns 1 (TRUE) if the class was deregistered and 0 
  1884.                      (FALSE) if the class was not deregistered. 
  1885.  
  1886.    Purpose:          Deregister an object class definition from the system. 
  1887.  
  1888.                     Examples:
  1889.  
  1890.                       /* Code    */
  1891.                        Call SysDeregisterObjectClass "MyClass"
  1892.  
  1893.  
  1894. ΓòÉΓòÉΓòÉ 9.7. SysDestroyObject ΓòÉΓòÉΓòÉ
  1895.  
  1896. Function: SysDestroyObject 
  1897.  
  1898. Syntax:   result = SysDestroyObject(name) 
  1899.  
  1900.    name              The object name.  This can be specified as an object ID 
  1901.                      (for example <WP_DESKTOP>) or as a fully specified file 
  1902.                      name. 
  1903.  
  1904.    result            The return code from WinDestroyData. This will return 1 
  1905.                      (TRUE) if the object was destroyed and 0 (FALSE) if the 
  1906.                      object was not destroyed. 
  1907.  
  1908.    Purpose:          Destroy an existing Workplace Shell object. 
  1909.  
  1910.                     Examples:
  1911.  
  1912.                       /* Code   */
  1913.                       If SysDestroyObject("MyProgram") Then Do
  1914.                         Say "Myprogram object destroyed."
  1915.                         if SysDestroyObject("MyFolder") Then
  1916.                           Say "Myfolder object destroyed."
  1917.                         Else Say 'Could not destroy folder "MyFolder"'
  1918.                         End
  1919.                       Else Say 'Could not destroy program "MyProgram"'
  1920.  
  1921.  
  1922. ΓòÉΓòÉΓòÉ 9.8. SysDriveInfo ΓòÉΓòÉΓòÉ
  1923.  
  1924. Function: SysDriveInfo 
  1925.  
  1926. Syntax:   info = SysDriveInfo(drive) 
  1927.  
  1928.    info      Drive information returned in the following form: 'drive:  free 
  1929.              total label' If the drive is not accessible, then info will equal 
  1930.              ''. 
  1931.  
  1932.    drive     The drive of interest,  'C:'. 
  1933.  
  1934. Purpose:  Gives drive information. 
  1935.  
  1936.                     Example:
  1937.                      /* Code */
  1938.                      say 'Disk='SysDriveInfo('C:')
  1939.  
  1940.                      /* Output */
  1941.                      Disk=C: 33392640 83687424 TRIGGER_C
  1942.  
  1943. In the above Output example, the items have the following meaning: 
  1944.  
  1945. o The first item is the drive being queried. 
  1946. o The first number is the number of bytes that are free. 
  1947. o The second number is the total size of the drive. 
  1948. o The final item is the drive label. 
  1949.  
  1950.  
  1951. ΓòÉΓòÉΓòÉ 9.9. SysDriveMap ΓòÉΓòÉΓòÉ
  1952.  
  1953. Function: SysDriveMap 
  1954.  
  1955. Syntax:   map = SysDriveMap([drive], [opt]) 
  1956.  
  1957.    map       A string containing all accessible drives. 
  1958.  
  1959.    drive     Drive letter with which to start the drive map. The default is C. 
  1960.  
  1961.    opt       The drivemap report option.  May be any one of the following: 
  1962.  
  1963.       'USED'         Reports drives which are accessible or in use.  This is 
  1964.                      the default. This includes all local and remote drives. 
  1965.  
  1966.       'FREE'         Reports drives which are free or not in use. 
  1967.  
  1968.       'LOCAL'        Reports only those drives which are local drives. 
  1969.  
  1970.       'REMOTE'       Reports only those drives which are remote drives such as 
  1971.                      redirected LAN resources, IFS attached drives, and so on. 
  1972.  
  1973.       'DETACHED'     Reports drives which are detached LAN resources. 
  1974.  
  1975. Purpose:  Reports all accessible drives in the form 'C: D: E:...' 
  1976.  
  1977.                     Example:
  1978.                      /* Code */
  1979.                      say 'Used drives include:'
  1980.                      say SysDriveMap('C:', 'USED')
  1981.  
  1982.                      /* Output */
  1983.                      Used drives include:
  1984.                      C: D: E: F: W:
  1985.  
  1986.  
  1987. ΓòÉΓòÉΓòÉ 9.10. SysDropFuncs ΓòÉΓòÉΓòÉ
  1988.  
  1989. Function: SysDropFuncs 
  1990.  
  1991. Syntax:   call SysDropFuncs 
  1992.  
  1993. Purpose:  Use this function to drop all the loaded RexxUtil functions.  Once 
  1994.           this function is processed by a REXX program, the RexxUtil functions 
  1995.           are not accessible in any OS/2 sessions. 
  1996.  
  1997.  
  1998. ΓòÉΓòÉΓòÉ 9.11. SysFileDelete ΓòÉΓòÉΓòÉ
  1999.  
  2000. Function: SysFileDelete 
  2001.  
  2002. Syntax:   rc = SysFileDelete(file) 
  2003.  
  2004. Purpose:  Deletes the specified file.  Does not support wildcards. 
  2005.  
  2006. RC:       Return Codes 
  2007.  
  2008.    0         File deleted successfully. 
  2009.  
  2010.    2         Error.  File not found. 
  2011.  
  2012.    3         Error.  Path not found. 
  2013.  
  2014.    5         Error.  Access denied. 
  2015.  
  2016.    26        Error.  Not DOS disk. 
  2017.  
  2018.    32        Error.  Sharing violation. 
  2019.  
  2020.    36        Error.  Sharing buffer exceeded. 
  2021.  
  2022.    87        Error.  Invalid parameter 
  2023.  
  2024.    206       Error.  Filename exceeds range error 
  2025.  
  2026.  
  2027. ΓòÉΓòÉΓòÉ 9.12. SysFileTree ΓòÉΓòÉΓòÉ
  2028.  
  2029. Function: SysFileTree 
  2030.  
  2031. Syntax:   rc = SysFileTree(filespec, stem, [options], [tattrib], [nattrib]) 
  2032.  
  2033.    filespec  The filespec to search for. 
  2034.  
  2035.    stem      The name of the stem variable to place the results. 
  2036.  
  2037.              Note:   stem.0 contains the number of files and/or directories 
  2038.              found. 
  2039.  
  2040.    options   Any logical combination of the following: 
  2041.  
  2042.       F         Search for files only. 
  2043.  
  2044.       D         Search for directories only. 
  2045.  
  2046.       B         Search for both files and directories. (default) 
  2047.  
  2048.       S         Scan subdirectories recursively. (non-default). 
  2049.  
  2050.       T         Return time and date fields in the form: 
  2051.  
  2052.                                 YY/MM/DD/HH/MM
  2053.  
  2054.       O         Only report fully qualified file names.  The default is to 
  2055.                 report date, time, size, attributes and fully qualified file 
  2056.                 name for each file found. 
  2057.  
  2058.    tattrib   The target attribute mask used when searching for filespec 
  2059.              matches. Only filespecs which match the mask will be reported. 
  2060.              The default mask is '*****' which means the Archive, Directory, 
  2061.              Hidden, Read-Only, and System bits may be either set or clear. 
  2062.              The attributes in the mask are positional dependant and in the 
  2063.              alphabetical order 'ADHRS'. 
  2064.  
  2065.       Mask Options (Target Mask) 
  2066.  
  2067.          *         The specified attribute may be either set or clear. 
  2068.  
  2069.          +         The specified attribute must be set. 
  2070.  
  2071.          -         The specified attribute must be clear. 
  2072.  
  2073.          Examples: (Target Mask) 
  2074.  
  2075.             '***+*'   Find all files which have set Read-Only bits. 
  2076.  
  2077.             '+**+*'   Find all files which have set Read-Only and Archive bits. 
  2078.  
  2079.             '*++**'   Find all hidden subdirectories. 
  2080.  
  2081.             '---+-'   Find all files which have only the Read-Only bit set. 
  2082.  
  2083.    nattrib   The new attribute mask which will be used to set the attributes of 
  2084.              each filespec found to match the target mask.  The default mask is 
  2085.              '*****' which means the Archive, Directory, Hidden, Read-Only, and 
  2086.              System bits will not be changed.  The attributes in the mask are 
  2087.              positional dependant and in the alphabetical order 'ADHRS'. 
  2088.  
  2089.       Mask Options (New Atrribute Mask) 
  2090.  
  2091.          *         The specified attribute will not be changed. 
  2092.  
  2093.          +         The specified attribute will be set. 
  2094.  
  2095.          -         The specified attribute will be cleared. 
  2096.  
  2097.          Examples: (New Attribute Mask) 
  2098.  
  2099.             '***+*'   Set the Read-Only bit on all files. 
  2100.  
  2101.             '-**+*'   Set the Read-Only and clear the Archive bits of each 
  2102.                       file. 
  2103.  
  2104.             '+*+++'   Set all attributes on all files, excluding directory 
  2105.                       attribute. 
  2106.  
  2107.             '-----'   Clear all attribute on all files. 
  2108.  
  2109.                       Note:   You cannot set the directory bit on non-directory 
  2110.                       filespecs.  The attribute field which is displayed in the 
  2111.                       stem variable is that of the current attribute setting 
  2112.                       after any changes have been applied. 
  2113.  
  2114. Purpose:  Finds all files which are equal to the specified filespec, and places 
  2115.           their descriptions (date time size attr filespec) in a stem variable. 
  2116.  
  2117. RC:       Return Codes 
  2118.  
  2119.    0         Successful. 
  2120.  
  2121.    2         Error.  Not enough memory. 
  2122.  
  2123.                      Examples:
  2124.  
  2125.                       /****<< Syntax Examples.>>***********************/
  2126.  
  2127.                       /* Find all subdirectories on C: */
  2128.                        call SysFileTree 'c:\*.*', 'file', 'SD'
  2129.  
  2130.                       /* Find all Read-Only files */
  2131.                        call SysFileTree 'c:\*.*', 'file', 'S', '***+*'
  2132.  
  2133.                       /* Clear Archive and Read-Only bits of files which have them set */
  2134.                        call SysFileTree 'c:\*.*', 'file', 'S', '+**+*', '-**-*'
  2135.  
  2136.  
  2137.                       /****<< Sample Code and Output Example.>>********/
  2138.  
  2139.                       /* Code */
  2140.                        call SysFileTree 'c:\os2*.', 'file', 'B'
  2141.                        do i=1 to file.0
  2142.                          say file.i
  2143.                        end
  2144.  
  2145.                      /* Actual Output */
  2146.                     12:15:89  12:00a        4096  A-HRS  C:\OS2LDR
  2147.                     12:15:89  12:00a       29477  A-HRS  C:\OS2KRNL
  2148.                      5:24:89   4:59p           0  -D---  C:\OS2
  2149.  
  2150.  
  2151. ΓòÉΓòÉΓòÉ 9.13. SysFileSearch ΓòÉΓòÉΓòÉ
  2152.  
  2153. Function: SysFileSearch 
  2154.  
  2155. Syntax:   call SysFileSearch target, file, stem, [options] 
  2156.  
  2157.    target    The string to search for. 
  2158.  
  2159.    file      The file to search. 
  2160.  
  2161.    stem      The name of the stem variable to place the results. 
  2162.  
  2163.              Note:   stem.0 contains the number of lines found. 
  2164.  
  2165.    options   Any logical combination of the following: 
  2166.  
  2167.       C         Case sensitive search. 
  2168.  
  2169.       N         Give line numbers when reporting hits. 
  2170.  
  2171.                 Note:   Default is case insensitive without line numbers. 
  2172.  
  2173. Purpose:  Finds all lines in specified file which contain a specified target 
  2174.           string, and places said lines in a stem variable. 
  2175.  
  2176. RC:       Return Codes 
  2177.  
  2178.    0         Successful. 
  2179.  
  2180.    2         Error.  Not enough memory. 
  2181.  
  2182.    3         Error.  Error opening file. 
  2183.  
  2184.                     Examples:
  2185.  
  2186.                      /* Find DEVICE statements in CONFIG.SYS */
  2187.                      call SysFileSearch 'DEVICE', 'C:\CONFIG.SYS', 'file.'
  2188.                      do i=1 to file.0
  2189.                       say file.i
  2190.                      end
  2191.  
  2192.                      /* Output */
  2193.                      DEVICE=C:\OS2\DOS.SYS
  2194.                      DEVICE=C:\OS2\PMDD.SYS
  2195.                      DEVICE=C:\OS2\COM02.SYS
  2196.                      SET VIDEO_DEVICES=VIO_IBM8514A
  2197.                      SET VIO_IBM8514A=DEVICE(BVHVGA,BVH8514A)
  2198.                      DEVICE=C:\OS2\POINTDD.SYS
  2199.                      DEVICE=C:\OS2\MSPS202.SYS
  2200.                      DEVICE=C:\OS2\MOUSE.SYS TYPE=MSPS2$
  2201.  
  2202.  
  2203.                      /* Find DEVICE statements in CONFIG.SYS (along with */
  2204.                      /* line nums) */
  2205.                      call SysFileSearch 'DEVICE', 'C:\CONFIG.SYS', 'file.', 'N'
  2206.                      do i=1 to file.0
  2207.                       say file.i
  2208.                      end
  2209.  
  2210.                      /* Output */
  2211.                      20 DEVICE=C:\OS2\DOS.SYS
  2212.                      21 DEVICE=C:\OS2\PMDD.SYS
  2213.                      22 DEVICE=C:\OS2\COM02.SYS
  2214.                      33 SET VIDEO_DEVICES=VIO_IBM8514A
  2215.                      34 SET VIO_IBM8514A=DEVICE(BVHVGA,BVH8514A)
  2216.                      40 DEVICE=C:\OS2\POINTDD.SYS
  2217.                      41 DEVICE=C:\OS2\MSPS202.SYS
  2218.                      42 DEVICE=C:\OS2\MOUSE.SYS TYPE=MSPS2$
  2219.  
  2220.  
  2221. ΓòÉΓòÉΓòÉ 9.14. SysGetEA ΓòÉΓòÉΓòÉ
  2222.  
  2223. Function: SysGetEA 
  2224.  
  2225. Syntax:   result = SysGetEA(file, name, variable) 
  2226.  
  2227.    file      The file containing the extended attribute. 
  2228.  
  2229.    name      The name of the extended attribute. 
  2230.  
  2231.    variable  The name of a REXX variable in which the extended attribute value 
  2232.              is placed. 
  2233.  
  2234.    result    The function result. If the result is 0, the extended attribute 
  2235.              has been retrieved and placed in a variable.  A non-zero result is 
  2236.              the OS/2 return code of the failing function. 
  2237.  
  2238. Purpose:  Read a named extended attribute from a file. 
  2239.  
  2240. Examples:
  2241.  
  2242.   /* Code    */
  2243.   if SysGetEA("C:\CONFIG.SYS", ".type", "TYPEINFO") = 0 then do
  2244.     parse var typeinfo 11 type
  2245.     say type
  2246.     end
  2247.   /* Output */
  2248.   OS/2 Command File
  2249.  
  2250.  
  2251. ΓòÉΓòÉΓòÉ 9.15. SysGetKey ΓòÉΓòÉΓòÉ
  2252.  
  2253. Function: SysGetKey 
  2254.  
  2255. Syntax:   key = SysGetKey([opt]) 
  2256.  
  2257.    key       The key which was pressed. 
  2258.  
  2259.    opt        Any one of the following: 
  2260.  
  2261.       'ECHO'    Echo the typed character  (Default) 
  2262.  
  2263.       'NOECHO'  Do not echo the typed character 
  2264.  
  2265. Purpose:  Gets the next key from the keyboard buffer, or waits for one if none 
  2266.           exist.  Works like the C function getch().  Unlike the regular REXX 
  2267.           CHARIN() built-in function, SysGetKey() does not require the 
  2268.           character to be followed by the Enter key. 
  2269.  
  2270.  
  2271. ΓòÉΓòÉΓòÉ 9.16. SysGetMessage ΓòÉΓòÉΓòÉ
  2272.  
  2273. Function: SysGetMessage 
  2274.  
  2275. Syntax:   msg = SysGetMessage(num, [file] [str1],...[str9]) 
  2276.  
  2277.    msg       The message associated with the number given. 
  2278.  
  2279.    num       The message number. 
  2280.  
  2281.    file      The message file to be searched.  The default message file is 
  2282.              OSO001.MSG. Message files will be searched for in the system root 
  2283.              directory ( C:\), the current directory, and along the DPATH. 
  2284.  
  2285.    str1,...str9 Insertion text variables.  If the message contains insertion 
  2286.              fields designated by %x, in the range %1 to %9, then the optional 
  2287.              parameters str1 through str9 may be used to designate the 
  2288.              replacement strings. 
  2289.  
  2290. Purpose:  OS/2 applications commonly use message files to provide National 
  2291.           Language Support (NLS).  Message files contain text strings which any 
  2292.           application can reference by their associated number. 
  2293.  
  2294.           Note:   Use the MKMSGF utility contained in the OS/2 Programmer's 
  2295.                   Toolkit to create message files.  MKMSGF is documented in the 
  2296.                   Building Programs book included with the toolkit. 
  2297.  
  2298.                     /*** Sample code segment using SysGetMessage and insertion text vars ***/
  2299.                     msg =  SysGetMessage(34, , 'A:', 'diskette labeled "Disk 2"', 'SER0002')
  2300.                     say msg
  2301.  
  2302.                     /** Output **/
  2303.                     The wrong diskette is in the drive.
  2304.                     Insert diskette labeled "Disk 2" (Volume Serial Number: SER0002)
  2305.                     into drive A:.
  2306.  
  2307.  
  2308. ΓòÉΓòÉΓòÉ 9.17. SysIni ΓòÉΓòÉΓòÉ
  2309.  
  2310. Function: SysIni 
  2311.  
  2312.    Syntax - Mode 1: Setting single key value. 
  2313.  
  2314.              result = SysIni([inifile], app, key, val) 
  2315.  
  2316.    Syntax - Mode 2: Querying single key value. 
  2317.  
  2318.              result = SysIni([inifile], app, key) 
  2319.  
  2320.    Syntax - Mode 3: Deleting a single key. 
  2321.  
  2322.              result = SysIni([inifile], app, key, 'DELETE:') 
  2323.  
  2324.    Syntax - Mode 4: Deleting an application and all associated keys. 
  2325.  
  2326.              result = SysIni([inifile], app, ['DELETE:']) 
  2327.  
  2328.    Syntax - Mode 5: Querying names of all keys associated with a certain 
  2329.              application. 
  2330.  
  2331.              result = SysIni([inifile], app, 'ALL:', 'stem') 
  2332.  
  2333.    Syntax - Mode 6: Querying names of all applications. 
  2334.  
  2335.              result = SysIni([inifile], 'ALL:', 'stem') 
  2336.  
  2337.    result    For successful setting invocations, result will equal ''. For 
  2338.              successful querying invocations, result will be given the value of 
  2339.              the specified application keyword.  For successful deleting 
  2340.              invocations, result will equal ''. 
  2341.  
  2342.              The error string 'ERROR:' may be returned if an error occurs: 
  2343.  
  2344.              Possible error conditions: 
  2345.  
  2346.       o An attempt was made to query or delete an application/key pair which 
  2347.         does not exist. 
  2348.  
  2349.       o An error occurred opening the specified INI file. You may have 
  2350.         specified the current user or system INI file using a relative 
  2351.         filespec. Make sure to use the full filespec, specifying drive, path, 
  2352.         and file name. 
  2353.  
  2354.    inifile   The name of the INI file which you would like to work with.  This 
  2355.              parameter should be a file specification, or one of the following: 
  2356.  
  2357.       'USER'    The user INI file (usually C:\OS2\OS2.INI).  This is the 
  2358.                 default. 
  2359.  
  2360.       'SYSTEM'  The system INI file (usually C:\OS2\OS2SYS.INI). 
  2361.  
  2362.       'BOTH'    For querying invocations, both the user and system INI files 
  2363.                 will be searched. For setting invocations, the user INI file 
  2364.                 will be written to. 
  2365.  
  2366.    app       The application name or some other meaningful value with which you 
  2367.              would like to store keywords (some sort of data). 
  2368.  
  2369.    key       The name of a keyword which is used to hold data. 
  2370.  
  2371.    val       The value to associate with the keyword of the specified 
  2372.              application. 
  2373.  
  2374.    stem      The name of the stem variable to store the resultant information 
  2375.              in.  STEM.0 will be set equal to the number of elements. 
  2376.  
  2377. Purpose:  This function allows limited editing of INI file variables. Variables 
  2378.           are stored in the INI file under Application Names and their 
  2379.           associated Key Names or keywords.  SysIni can be used to share 
  2380.           variables between applications or as a way of implementing GLOBALV in 
  2381.           the OS/2 operating system. 
  2382.  
  2383.           Note:   This function works on all types of data stored in an INI 
  2384.           file (text, numeric, or binary). 
  2385.  
  2386.                     /* Sample code segments */
  2387.  
  2388.                      /***  Save the user entered name under the key 'NAME' of *****
  2389.                      ****  the application 'MYAPP'.                           ****/
  2390.                      pull name .
  2391.                      call SysIni , 'MYAPP', 'NAME', name /* Save the value        */
  2392.                      say  SysIni(, 'MYAPP', 'NAME')      /* Query the value       */
  2393.                      call SysIni , 'MYAPP'               /* Delete all MYAPP info */
  2394.                      exit
  2395.  
  2396.                      /****  Type all OS2.INI file information to the screen  *****/
  2397.                     call rxfuncadd sysloadfuncs, rexxutil, sysloadfuncs
  2398.                     call sysloadfuncs
  2399.                        call SysIni 'USER', 'All:', 'Apps.'
  2400.                        if Result \= 'ERROR:' then
  2401.                          do i = 1 to Apps.0
  2402.                            call SysIni 'USER', Apps.i, 'All:', 'Keys'
  2403.                            if Result \= 'ERROR:' then
  2404.                             do j=1 to Keys.0
  2405.                               val = SysIni('USER', Apps.i, Keys.j)
  2406.                               say left(Apps.i, 20) left(Keys.j, 20),
  2407.                                     'Len=x'''Left(d2x(length(val)),4) left(val, 20)
  2408.                             end
  2409.                          end
  2410.  
  2411.  
  2412. ΓòÉΓòÉΓòÉ 9.18. SysMkDir ΓòÉΓòÉΓòÉ
  2413.  
  2414. Function: SysMkDir 
  2415.  
  2416. Syntax:   rc = SysMkDir(dirspec) 
  2417.  
  2418.    dirspec   The directory that should be created. 
  2419.  
  2420. Purpose:  Creates a specified directory quickly.  In case of failure, one of 
  2421.           many return codes is given so that the exact reason for failure can 
  2422.           be determined. 
  2423.  
  2424. RC:       Return Codes 
  2425.  
  2426.    0         Directory creation was successful. 
  2427.  
  2428.    2         Error.  File not found. 
  2429.  
  2430.    3         Error.  Path not found. 
  2431.  
  2432.    5         Error.  Access denied. 
  2433.  
  2434.    26        Error.  Not a DOS disk. 
  2435.  
  2436.    87        Error.  Invalid parameter. 
  2437.  
  2438.    108       Error.  Drive locked. 
  2439.  
  2440.    206       Error.  Filename exceeds range. 
  2441.  
  2442. Example:  call SysMkDir 'c:\rexx' 
  2443.  
  2444.  
  2445. ΓòÉΓòÉΓòÉ 9.19. SysOS2Ver ΓòÉΓòÉΓòÉ
  2446.  
  2447. Function: SysOS2Ver 
  2448.  
  2449. Syntax:   ver = SysOS2Ver( ) 
  2450.  
  2451.    ver       String containing OS/2 version info in the form 'x.xx' 
  2452.  
  2453. Purpose:  Returns the OS/2 version information. 
  2454.  
  2455.  
  2456. ΓòÉΓòÉΓòÉ 9.20. SysPutEA ΓòÉΓòÉΓòÉ
  2457.  
  2458. Function: SysPutEA 
  2459.  
  2460. Syntax:   result = SysPutEA(file, name, value) 
  2461.  
  2462.    file      The file where the extended attribute will be written. 
  2463.  
  2464.    name      The name of the extended attribute. 
  2465.  
  2466.    value     The new value of the extended attribute. 
  2467.  
  2468.    result    The function result. If the result is 0, the extended attribute 
  2469.              has been written to the file. A non-zero result is the OS/2 return 
  2470.              code of the failing function. 
  2471.  
  2472. Purpose:  Write a named extended attribute to a file. 
  2473.  
  2474. Examples:
  2475.  
  2476.   /* Code    */
  2477.   type = "OS/2 Command File"
  2478.   typeinfo = "DFFF00000100FDFF'x || d2c(length(type)) || '00'x || type
  2479.   call SysPutEA "C:\CONFIG.SYS", "TYPE", typeinfo
  2480.  
  2481.  
  2482. ΓòÉΓòÉΓòÉ 9.21. SysQueryClassList ΓòÉΓòÉΓòÉ
  2483.  
  2484. Function: SysQueryClassList 
  2485.  
  2486. Syntax:   call  SysQueryClassList stem 
  2487.  
  2488.    stem      The name of a stem variable in which the entire set of registered 
  2489.              classes is placed. 
  2490.  
  2491.    Purpose:  Retrieve the complete list of registered object classes. 
  2492.  
  2493.                     Examples:
  2494.  
  2495.                       /* Code    */
  2496.                        call SysQueryClassList "list."
  2497.                        do i = 1 to list.0
  2498.                          say 'Class' i 'is' list.i
  2499.                        end
  2500.  
  2501.  
  2502. ΓòÉΓòÉΓòÉ 9.22. SysRegisterObjectClass ΓòÉΓòÉΓòÉ
  2503.  
  2504. Function: SysRegisterObjectClass 
  2505.  
  2506. Syntax:   result = SysRegisterObjectClass(classname, modulename) 
  2507.  
  2508.    classname         The name of the new object class. 
  2509.  
  2510.    modulename        The name of the module containing the object definition. 
  2511.  
  2512.    result            The return code from WinRegisterObjectClass.  This returns 
  2513.                      1 (TRUE) if the class was registered and 0 (FALSE) if the 
  2514.                      new class was not registered. 
  2515.  
  2516.    Purpose:          Register a new object class definition to the system. 
  2517.  
  2518.                     Examples:
  2519.  
  2520.                       /* Code    */
  2521.                        if SysRegisterObjectClass("NewObject","NEWDLL") then
  2522.                          say 'Install successfully completed for NewObject'
  2523.  
  2524.  
  2525. ΓòÉΓòÉΓòÉ 9.23. SysRmDir ΓòÉΓòÉΓòÉ
  2526.  
  2527. Function: SysRmDir 
  2528.  
  2529. Syntax:   rc = SysRmDir(dirspec) 
  2530.  
  2531.    dirspec   The directory that should be deleted. 
  2532.  
  2533. Purpose:  Deletes a specified directory quickly.  In case of failure, one of 
  2534.           many return codes is given so that the exact reason for failure can 
  2535.           be determined. 
  2536.  
  2537. RC:       Return Codes 
  2538.  
  2539.    0         Directory removal was successful. 
  2540.  
  2541.    2         Error.  File not found. 
  2542.  
  2543.    3         Error.  Path not found. 
  2544.  
  2545.    5         Error.  Access denied. 
  2546.  
  2547.    16        Error.  Current directory. 
  2548.  
  2549.    26        Error.  Not a DOS disk. 
  2550.  
  2551.    87        Error.  Invalid parameter. 
  2552.  
  2553.    108       Error.  Drive locked. 
  2554.  
  2555.    206       Error.  Filename exceeds range. 
  2556.  
  2557. Example:  call SysRmDir 'c:\rexx' 
  2558.  
  2559.  
  2560. ΓòÉΓòÉΓòÉ 9.24. SysSearchPath ΓòÉΓòÉΓòÉ
  2561.  
  2562. Function: SysSearchPath 
  2563.  
  2564. Syntax:   filespec = SysSearchPath(path, filename) 
  2565.  
  2566.    filespec  The complete filespec of the file found, or '' if the filename was 
  2567.              not located along the path. 
  2568.  
  2569.    path      Any environment variable that resembles a path, such as 'PATH', 
  2570.              'DPATH', and so on. 
  2571.  
  2572.    filename  The file to search the path for. 
  2573.  
  2574. Purpose:  Searches the specified path for the specified file and returns the 
  2575.           full filespec of the file if found, otherwise it returns. 
  2576.  
  2577.                     Example:
  2578.  
  2579.                      /* Code */
  2580.                      fspec = SysSearchPath('PATH', 'CMD.EXE')
  2581.                      say fspec
  2582.  
  2583.                      /* Output */
  2584.                      C:\OS2\CMD.EXE
  2585.  
  2586.  
  2587. ΓòÉΓòÉΓòÉ 9.25. SysSetIcon ΓòÉΓòÉΓòÉ
  2588.  
  2589. Function: SysSetIcon 
  2590.  
  2591. Syntax:   result = SysSetIcon(filename, iconfilename) 
  2592.  
  2593.    filename          The name of the file to have the icon set. 
  2594.  
  2595.    iconfilename      The name of a .ICO file containing icon data. 
  2596.  
  2597.    result            The return code from WinSetIcon. This returns 1 (TRUE) if 
  2598.                      the icon was set and 0 (FALSE) if the new icon was not 
  2599.                      set. 
  2600.  
  2601.    Purpose:          Associate an icon file with a specified file. 
  2602.  
  2603.                     Examples:
  2604.  
  2605.                       /* Code    */
  2606.                        if SysSetIcon(file, "NEW.ICO") then
  2607.                          say 'Icon "NEW.ICO" attached to' file'.'
  2608.  
  2609.  
  2610. ΓòÉΓòÉΓòÉ 9.26. SysSetObjectData ΓòÉΓòÉΓòÉ
  2611.  
  2612. Function: SysSetObjectData 
  2613.  
  2614. Syntax:   result = SysSetObjectData(name, setup) 
  2615.  
  2616.    name              The object name.  This can be specified as an object ID 
  2617.                      (for example <WP_DESKTOP>) or as a fully specified file 
  2618.                      name. 
  2619.  
  2620.    setup             A WinCreateObject setup string. 
  2621.  
  2622.    result            The return code from WinSetObjectData.  This will return 1 
  2623.                      (TRUE) if the object was updated and 0 (FALSE) if the 
  2624.                      object was not updated. 
  2625.  
  2626.    Purpose:          Change the settings of an existing object.  It can also be 
  2627.                      used to open an instance of an object. 
  2628.  
  2629.                     Examples:
  2630.  
  2631.                       /* Code   */
  2632.                       if SysSetObjectData("MyProgram","NOMOVE=YES") Then
  2633.                         Say "Myprogram object settings have been updated."
  2634.  
  2635.  
  2636. ΓòÉΓòÉΓòÉ 9.27. SysSleep ΓòÉΓòÉΓòÉ
  2637.  
  2638. Function: SysSleep 
  2639.  
  2640. Syntax:   call SysSleep secs 
  2641.  
  2642.    secs      The number of seconds to sleep. 
  2643.  
  2644. Purpose:  Sleep a specified number of seconds. 
  2645.  
  2646.  
  2647. ΓòÉΓòÉΓòÉ 9.28. SysTempFileName ΓòÉΓòÉΓòÉ
  2648.  
  2649. Function: SysTempFileName 
  2650.  
  2651. Syntax:   file = SysTempFileName(template, [filter]) 
  2652.  
  2653.    template  The template that describes the temporary file or directory name 
  2654.              to be returned.  The template should resemble a valid file or 
  2655.              directory specification with up to 5 filter characters. 
  2656.  
  2657.    filter    The filter character found in the template.  Each filter character 
  2658.              found in the template is replaced with a numeric value.  The 
  2659.              resulting string represents a file or directory that does not 
  2660.              exist.  The default filter character is ?. 
  2661.  
  2662.    file      A file or directory that does not currently exist.  If an error 
  2663.              occurred or if no unique file or directory exists given the 
  2664.              template provided, a null string is returned. 
  2665.  
  2666. Purpose:  Returns a unique file or directory name given a certain template. 
  2667.           Useful when a program requires a temporary file but is not to 
  2668.           overwrite an existing file. 
  2669.  
  2670.                     Examples:
  2671.  
  2672.                      /* Code */
  2673.                      say SysTempFileName('C:\TEMP\MYEXEC.???')
  2674.                      say SysTempFileName('C:\TEMP\??MYEXEC.???')
  2675.                      say SysTempFileName('C:\MYEXEC@.@@@', '@')
  2676.  
  2677.                      /* Output */
  2678.                      C:\TEMP\MYEXEC.251
  2679.                      C:\TEMP\10MYEXEC.392
  2680.                      C:\MYEXEC6.019
  2681.  
  2682.           Note: 
  2683.  
  2684.           Since it is not required that the filter characters be contiguous 
  2685.           within the template, it is impossible to quickly determine the number 
  2686.           of files already residing in the target directory that would fit the 
  2687.           template description. 
  2688.  
  2689.           SysTempFileName uses a random number algorithm to determine a number 
  2690.           to replace the filter characters with.  It then tests if the 
  2691.           resulting file exists.  If it does not, it increments the number, 
  2692.           replaces the filter characters, and tests for the existence of the 
  2693.           new file, and so on.  This continues until a free file is found or 
  2694.           all possibilities have been exhausted. 
  2695.  
  2696.  
  2697. ΓòÉΓòÉΓòÉ 9.29. SysTextScreenRead ΓòÉΓòÉΓòÉ
  2698.  
  2699. Function: SysTextScreenRead 
  2700.  
  2701. Syntax:   string = SysReadScreen(row, col, [len]) 
  2702.  
  2703.    row       The row from which to start reading. 
  2704.  
  2705.    col       The column from which to start reading. 
  2706.  
  2707.    len       The number of characters to read.  The default is to read up to 
  2708.              the end of the screen. 
  2709.  
  2710.    string    The character reads from the screen.  This includes carriage 
  2711.              return and linefeed characters which comprise the end of lines 
  2712.              should the number of character reads span multiple lines. 
  2713.  
  2714. Purpose:  Reads a specified number of characters from a specified location of 
  2715.           the screen. 
  2716.  
  2717. Limitations  This function only reads in characters and does not consider the 
  2718. color attributes of each character read.  When restoring the character string 
  2719. to the screen with say or charout, the previous color settings will be lost. 
  2720.  
  2721. /* Example which reads in the entire screen */
  2722.  screen = SysTextScreenRead( 0, 0 )
  2723.  
  2724. /* Example which reads in one line */
  2725.  line = SysTextScreenRead( 2, 0, 80 )
  2726.  
  2727.  
  2728. ΓòÉΓòÉΓòÉ 9.30. SysTextScreenSize ΓòÉΓòÉΓòÉ
  2729.  
  2730. Function: SysTextScreenSize 
  2731.  
  2732. Syntax:   result = SysTextScreenSize() 
  2733.  
  2734.    result    The size of the screen.  The format of the result string is 'row 
  2735.              col'. 
  2736.  
  2737. Purpose:  This function returns the size of the screen. 
  2738.  
  2739. /* Example */
  2740. call RxFuncAdd 'SysTextScreenSize', 'RexxUtil', 'SysTextScreenSize'
  2741. parse value SysTextScreenSize() with row col
  2742. say 'Rows='row', Columns='col
  2743.  
  2744.  
  2745. ΓòÉΓòÉΓòÉ 9.31. SysWaitNamedPipe ΓòÉΓòÉΓòÉ
  2746.  
  2747. Function: SysWaitNamedPipe 
  2748.  
  2749. Syntax:   result = SysWaitNamedPipe(name, [timeout]) 
  2750.  
  2751.    name      The name of the named pipe.  Named pipe names must be of the form 
  2752.              "\PIPE\pipename". 
  2753.  
  2754.    timeout   The number of microseconds to wait on the pipe.  If timeout is 
  2755.              omitted or is zero, the default timeout value is be used. A value 
  2756.              of -1 can be used to wait until the pipe is no longer busy. 
  2757.  
  2758.    result    The return code from DosWaitNmPipe. The following return codes are 
  2759.              of particular interest: 
  2760.  
  2761.       0         The named pipe is no longer busy. 
  2762.  
  2763.       2         The named pipe was not found. 
  2764.  
  2765.       231       The wait timed out before the pipe became available. 
  2766.  
  2767. Purpose:  Perform a timed wait on a named pipe. 
  2768.  
  2769. Examples:
  2770.  
  2771.   /* Code    */
  2772.    Parse value stream(PipeName,'C','OPEN') with PipeState ':' OS2RC
  2773.    If OS2RC=231 then call SysWaitNamedPipe(PipeName, -1)
  2774.  
  2775.  
  2776. ΓòÉΓòÉΓòÉ <hidden> Arithmetic Examples ΓòÉΓòÉΓòÉ
  2777.  
  2778. This sample procedure named MATH.CMD shows you how to perform four arithmetic 
  2779. operations on variables: 
  2780.  
  2781. /* Performing arithmetic operations on variables */
  2782. a = 4
  2783. b = 2
  2784. c = a + b
  2785. SAY 'The result of 'a '+' b 'is' c
  2786. SAY
  2787. c = a * b
  2788. SAY 'The result of ' a '*' b 'is' c
  2789. SAY
  2790. c = a - b
  2791. SAY 'The result of ' a '-' b 'is' c
  2792. SAY
  2793. c = a / b
  2794. SAY 'The result of 'a '/' b 'is' c
  2795. EXIT
  2796. Your screen looks like this: 
  2797.  
  2798. [C:\]MATH
  2799. The result of 4 + 2 is 6
  2800.  
  2801. The result of 4 * 2 is 8
  2802.  
  2803. The result of 4 - 2 is 2
  2804.  
  2805. The result of 4 / 2 is 2
  2806.  
  2807. [C:\]
  2808.  
  2809.  
  2810. ΓòÉΓòÉΓòÉ <hidden> Using Comparisons ΓòÉΓòÉΓòÉ
  2811.  
  2812. The following procedure, TF.CMD, uses comparisons and an equal expression to 
  2813. determine if numeric expressions are true or false. 
  2814.  
  2815. /* Determine if expression is true or false  */
  2816. /* 1 is true; 0 is false                     */
  2817. a = 4
  2818. b = 2
  2819. c = a > b
  2820. SAY 'The result of' a '>' b 'is' c
  2821. c = a < b
  2822. SAY 'The result of' a '<' b 'is' c
  2823. c = a = b
  2824. SAY 'The result of' a '=' b 'is' c
  2825. EXIT
  2826.  
  2827. When you run the procedure, it gives the following results: 
  2828.  
  2829.  
  2830. [C:\]TF
  2831. The result of 4 > 2 is 1
  2832. The result of 4 < 2 is 0
  2833. The result of 4 = 2 is 0
  2834.  
  2835. [C:\]
  2836.  
  2837.  
  2838. ΓòÉΓòÉΓòÉ <hidden> Logical Operators - Examples ΓòÉΓòÉΓòÉ
  2839.  
  2840. The following procedure, AND.CMD, shows the AND operator checking for two true 
  2841. statements. 
  2842.  
  2843. /* Using the AND (&) Operator   */
  2844. /* 0 is false; 1 is true        */
  2845. a = 4
  2846. b = 2
  2847. c = 5
  2848. d = (a > b) & (b > c)
  2849. SAY 'The result of (a > b) & (b > c) is' d
  2850. d = (a > b) & (b < c)
  2851. SAY 'The result of (a > b) & (b < c) is' d
  2852. EXIT
  2853.  
  2854. When run on your system, AND.CMD displays the following on your screen as: 
  2855.  
  2856.  
  2857.  
  2858. [C:\]AND
  2859. The result of (a > b) & (b > c) is 0
  2860. The result of (a > b) & (b < c) is 1
  2861.  
  2862. [C:\]
  2863.  
  2864. The following procedure, OR.CMD, shows the OR operator in a true statement 
  2865. unless both values are false: 
  2866.  
  2867. /* Using the OR (|) Operator    */
  2868. /* 0 is false; 1 is true        */
  2869. a = 4
  2870. b = 2
  2871. c = 5
  2872. d = (a > b) | (b > c)
  2873. SAY 'The result of (a > b) | (b > c) is' d
  2874. d = (a > b) | (b < c)
  2875. SAY 'The result of (a > b) | (b < c) is' d
  2876. EXIT
  2877.  
  2878. When run on your system, the procedure displays the following: 
  2879.  
  2880.  
  2881. [C:\]OR
  2882. The result of (a > b) | (b > c) is 1
  2883. The result of (a > b) | (b < c) is 1
  2884.  
  2885. [C:\]
  2886.  
  2887.  
  2888. ΓòÉΓòÉΓòÉ <hidden> DO WHILE Example ΓòÉΓòÉΓòÉ
  2889.  
  2890. A procedure using a DO WHILE loop is DOWHILE.CMD.  It tests for a true or false 
  2891. condition at the top of the loop. 
  2892.  
  2893. /* Using a DO WHILE loop */
  2894. SAY 'Enter the amount of money available'
  2895. PULL salary
  2896. spent = 0
  2897. DO WHILE spent < salary
  2898.    SAY 'Type in cost of item'
  2899.    PULL cost
  2900.    spent = spent + cost
  2901. END
  2902. SAY 'Empty pockets.'
  2903. EXIT
  2904.  
  2905. After running the DOWHILE procedure, you see this on your screen: 
  2906.  
  2907. [C:\]dowhile
  2908. Enter the amount of money available
  2909. 100
  2910. Type in cost of item
  2911. 57
  2912. Type in cost of item
  2913. 24
  2914. Type in cost of item
  2915. 33
  2916. Empty pockets.
  2917. [C:\]
  2918.  
  2919.  
  2920. ΓòÉΓòÉΓòÉ <hidden> DO UNTIL Example ΓòÉΓòÉΓòÉ
  2921.  
  2922. A procedure using a DO UNTIL loop is DOUNTIL.CMD.  It tests for a true or false 
  2923. condition at the bottom of the loop: 
  2924.  
  2925. /* Using a DO UNTIL loop */
  2926. SAY 'Enter the amount of money available'
  2927. PULL salary
  2928. spent = 0          /* Sets spent to a value of 0 */
  2929. DO UNTIL spent > salary
  2930.    SAY 'Type the cost of item'
  2931.    PULL cost
  2932.    spent = spent + cost
  2933. END
  2934. SAY 'Empty pockets.'
  2935. EXIT
  2936.  
  2937. When run, DOUNTIL.CMD displays on your screen as: 
  2938.  
  2939. [C:\] DOUNTIL
  2940. Enter the amount of money available
  2941. 50
  2942. Type the cost of item
  2943. 37
  2944. Type the cost of item
  2945. 14
  2946. Empty pockets.
  2947. [C:\]
  2948.  
  2949.  
  2950. ΓòÉΓòÉΓòÉ <hidden> OS/2 ΓòÉΓòÉΓòÉ
  2951.  
  2952. Trademark of the IBM Corporation. 
  2953.  
  2954.  
  2955. ΓòÉΓòÉΓòÉ <hidden> Systems Application Architecture ΓòÉΓòÉΓòÉ
  2956.  
  2957. Trademark of the IBM Corporation. 
  2958.  
  2959.  
  2960. ΓòÉΓòÉΓòÉ <hidden> Presentation Manager ΓòÉΓòÉΓòÉ
  2961.  
  2962. Trademark of the IBM Corporation. 
  2963.  
  2964.  
  2965. ΓòÉΓòÉΓòÉ 10. Keyword Instructions ΓòÉΓòÉΓòÉ
  2966.  
  2967. A keyword instruction is one or more clauses, the first of which starts with a 
  2968. keyword that identifies the instruction.  If the instruction has more than one 
  2969. clause, the clauses are separated by a delimiter, in this case a semicolon (;). 
  2970.  
  2971. Some keyword instructions, such as those starting with the keyword DO, can 
  2972. include nested instructions. 
  2973.  
  2974. In the syntax diagrams, symbols (words) in upper case letters denote keywords; 
  2975. other words (such as expression) denote a collection of symbols. Keywords are 
  2976. not case dependent: the symbols if, If, and iF would all invoke the instruction 
  2977. IF. Also, you usually omit most of the clause delimiters (;) shown because they 
  2978. are implied by the end of a line. 
  2979.  
  2980.  
  2981. ΓòÉΓòÉΓòÉ 10.1. ADDRESS ΓòÉΓòÉΓòÉ
  2982.  
  2983.  
  2984.  ΓöÇΓöÇADDRESSΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ;ΓöÇΓöÇΓöÇ
  2985.                  Γö£ΓöÇenvironmentΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ
  2986.                  Γöé             ΓööΓöÇexpressionΓöÇΓöÿ Γöé
  2987.                  ΓööΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇexpression1ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  2988.                   ΓööΓöÇVALUEΓöÇΓöÿ
  2989.  
  2990. Address is used to send a single command to a specified environment, code an 
  2991. environment, a literal string, or a single symbol, which is taken to be a 
  2992. constant, followed by an expression. The expression is evaluated, and the 
  2993. resulting command string is routed to environment. After the command is 
  2994. executed, environment is set back to whatever it was before, thus temporarily 
  2995. changing the destination for a single command. 
  2996.  
  2997. Example: 
  2998.  
  2999. ADDRESS CMD "DIR C:\STARTUP.CMD"   /*   OS/2   */
  3000.  
  3001. If only environment is specified, a lasting change of destination occurs: all 
  3002. commands that follow (clauses that are neither REXX instructions nor assignment 
  3003. instructions) will be routed to the given command environment, until the next 
  3004. ADDRESS instruction is executed. The previously selected environment is saved. 
  3005.  
  3006. Example: 
  3007.  
  3008. Suppose that the environment for a text editor is registered by the name EDIT: 
  3009.  
  3010. address CMD
  3011. 'DIR C:\STARTUP.CMD'
  3012. if rc=0 then 'COPY STARTUP.CMD *.TMP'
  3013. address EDIT
  3014.  
  3015. Subsequent commands are passed to the editor until the next ADDRESS 
  3016. instruction. 
  3017.  
  3018. Similarly, you can use the VALUE form to make a lasting change to the 
  3019. environment.  Here expression1 (which may be just a variable name) is 
  3020. evaluated, and the result forms the name of the environment.  The subkeyword 
  3021. VALUE can be omitted as long as expression1 starts with a special character (so 
  3022. that it cannot be mistaken for a symbol or string). 
  3023.  
  3024. Example: 
  3025.  
  3026. ADDRESS ('ENVIR'||number)
  3027.  
  3028. With no arguments, commands are routed back to the environment that was 
  3029. selected before the previous lasting change of environment was made, and the 
  3030. current environment name is saved. Repeated execution of ADDRESS alone, 
  3031. therefore, switches the command destination between two environments 
  3032. alternately. A null string for the environment name (" ") is the same as the 
  3033. default environment. 
  3034.  
  3035.  
  3036. ΓòÉΓòÉΓòÉ 10.2. ARG ΓòÉΓòÉΓòÉ
  3037.  
  3038.  
  3039.  ΓöÇΓöÇΓöÇΓöÇARGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3040.                  ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÿ
  3041.  
  3042. ARG is used to retrieve the argument strings provided to a program or internal 
  3043. routine and assign them to variables.  It is a short form of the following 
  3044. instruction: 
  3045.  
  3046.  ΓöÇΓöÇPARSE UPPER ARGΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ;ΓöÇΓöÇΓöÇ
  3047.                      ΓööΓöÇΓöÇΓöÇΓöÇtemplateΓöÇΓöÇΓöÇΓöÇΓöÿ
  3048.  
  3049. Template is a list of symbols separated by blanks or patterns. 
  3050.  
  3051. Unless a subroutine or internal function is being run, the interpreter reads 
  3052. the arguments given on the program invocation, translates them to uppercase 
  3053. (for example, a lowercase a-z to an uppercase A-Z), and then parses them into 
  3054. variables. Use the PARSE ARG instruction if you do not want uppercase 
  3055. translation. 
  3056.  
  3057. If a subroutine or internal function is being run, the data used will be the 
  3058. argument strings passed to the routine. 
  3059.  
  3060. The ARG (and PARSE ARG) instructions can be run as often as desired (typically 
  3061. with different templates) and always parse the same current input strings. 
  3062. There are no restrictions on the length or content of the data parsed except 
  3063. those imposed by the caller. 
  3064.  
  3065. Example: 
  3066.  
  3067. /* String passed is "Easy Rider"  */
  3068.  
  3069. Arg adjective noun
  3070.  
  3071. /* Now:  "ADJECTIVE"  contains 'EASY'           */
  3072. /*       "NOUN"       contains 'RIDER'          */
  3073.  
  3074. If more than one string is expected to be available to the program or routine, 
  3075. each can be selected in turn by using a comma in the parsing template. 
  3076.  
  3077. Example: 
  3078.  
  3079. /* function is invoked by  FRED('data X',1,5)   */
  3080.  
  3081. Fred:  Arg string, num1, num2
  3082.  
  3083. /* Now:  "STRING" contains 'DATA X'             */
  3084. /*       "NUM1"   contains '1'                  */
  3085. /*       "NUM2"   contains '5'                  */
  3086.  
  3087. Notes: 
  3088.  
  3089. o The argument strings to a REXX program or internal routine can also be 
  3090.   retrieved or checked by using the ARG built-in function. 
  3091.  
  3092. o The source of the data being processed is also made available on entry to the 
  3093.   program.  See the PARSE instruction (SOURCE option) for details. 
  3094.  
  3095.  
  3096. ΓòÉΓòÉΓòÉ 10.3. CALL ΓòÉΓòÉΓòÉ
  3097.  
  3098.  
  3099.  ΓöÇΓöÇΓöÇΓöÇCALLΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇnameΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇ
  3100.  
  3101.               Γöé           Γöé   ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ       Γöé
  3102.               Γöé           Γöé                 Γöé       Γöé
  3103.               Γöé           ΓööΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇexpressionΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3104.               Γöé                                      Γöé
  3105.               Γö£ΓöÇΓöÇΓöÇOFFΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇERRORΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3106.               Γöé           Γö£ΓöÇΓöÇFAILUREΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  3107.               Γöé           Γö£ΓöÇΓöÇHALTΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  3108.               Γöé           ΓööΓöÇΓöÇNOTREADYΓöÇΓöÇΓöÇΓöÿ            Γöé
  3109.               Γöé                                      Γöé
  3110.               ΓööΓöÇΓöÇONΓöÇΓöÇΓö¼ΓöÇERRORΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÿ
  3111.                      Γö£ΓöÇFAILUREΓöÇΓöÇΓöñ ΓööΓöÇNAMEΓöÇtrapnameΓöÇΓöÿ
  3112.                      Γö£ΓöÇHALTΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3113.                      ΓööΓöÇNOTREADYΓöÇΓöÿ
  3114.  
  3115. CALL is used to invoke a routine (if you specify name) or to control the 
  3116. trapping of certain conditions (if ON or OFF is specified) 
  3117.  
  3118. To control trapping, specify OFF or ON and the condition you want to trap.  OFF 
  3119. turns off the specified condition trap.  ON turns on the specified condition 
  3120. trap. 
  3121.  
  3122. To invoke a routine, specify name, which is a symbol or literal string that is 
  3123. taken as a constant.  The name must be a valid symbol. The routine invoked can 
  3124. be any of the following: 
  3125.  
  3126. o An internal routine 
  3127. o An external routine 
  3128. o A built-in function. 
  3129.  
  3130. If a string is used for name (that is, name is specified in quotation marks) 
  3131. the search for internal labels is bypassed, and only a built-in function or an 
  3132. external routine is invoked.  Note that the names of built-in functions (and 
  3133. generally the names of external routines too) are in uppercase; therefore, the 
  3134. name in the literal string should be in uppercase. 
  3135.  
  3136. The routine can optionally return a result and is functionally identical to the 
  3137. clause: 
  3138.  
  3139. ΓöÇresult=name(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ;ΓöÇΓöÇ
  3140.                 Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ  Γöé
  3141.                 Γöé                Γöé  Γöé
  3142.                 ΓööΓöÇΓö┤Γö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö┤ΓöÇΓöÇΓöÿ
  3143.                    ΓööΓöÇexpressionΓöÇΓöÿ
  3144.  
  3145. The exception is that the variable result becomes uninitialized if no result is 
  3146. returned by the routine invoked. 
  3147.  
  3148. The name given in the CALL instruction must be a valid symbol. 
  3149.  
  3150. The OS/2 interpreter supports the specification of up to 20 expressions, 
  3151. separated by commas. The expressions are evaluated in order from left to right, 
  3152. and form the argument strings during execution of the routine. Any ARG or PARSE 
  3153. ARG instructions or ARG built-in function in the called routine will access 
  3154. these strings rather than those previously active in the calling program.  You 
  3155. can omit expressions, if appropriate, by including extra commas. 
  3156.  
  3157. The CALL then causes a branch to the routine called name using the same 
  3158. mechanism as function calls. The order in which these are searched for is 
  3159. described in the section on functions.  A brief summary follows: 
  3160.  
  3161. Internal routines:  These are sequences of instructions inside the same 
  3162.                     program, starting at the label that matches name in the 
  3163.                     CALL instruction. If the routine name is specified in 
  3164.                     quotation marks, then an internal routine is not considered 
  3165.                     for that search order. 
  3166.  
  3167. Built-in routines:  These are routines built in to the language processor for 
  3168.                     providing various functions.  They always return a string 
  3169.                     containing the result of the function. 
  3170.  
  3171. External routines:  Users can write or make use of routines that are external 
  3172.                     to the language processor and the calling program. An 
  3173.                     external routine can be written in any language, including 
  3174.                     REXX, that supports the system-dependent interfaces.  If an 
  3175.                     external routine, written in REXX, is invoked as a 
  3176.                     subroutine by the CALL instruction, you can retrieve any 
  3177.                     argument strings with the ARG or PARSE ARG instructions or 
  3178.                     the ARG built-in function. 
  3179.  
  3180.  
  3181. ΓòÉΓòÉΓòÉ 10.4. DO ΓòÉΓòÉΓòÉ
  3182.  
  3183.  
  3184. ΓöÇDOΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ENDΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼;ΓöÇΓöÇ
  3185.       ΓööΓöÇrepetitorΓöÇΓöÿ ΓööΓöÇconditionalΓöÇΓöÿ   ΓöéΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé    ΓööΓöÇnameΓöÇΓöÿ
  3186.                                       Γöé             ΓöéΓöé
  3187.                                       ΓööΓö┤ΓöÇinstructionΓöÇΓö┤Γöÿ
  3188.  
  3189. repetitor:
  3190.  
  3191. ΓöÇΓö¼ΓöÇname=expriΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ
  3192.   Γöé            ΓööTOΓöÇexprtΓöÿ ΓööBYΓöÇexprbΓöÿ ΓööFORΓöÇexprfΓöÿ Γöé
  3193.   Γö£ΓöÇΓöÇFOREVERΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3194.   ΓööΓöÇΓöÇexprrΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3195.  
  3196.  
  3197. conditional:
  3198.  
  3199. ΓöÇΓöÇΓöÇΓö¼ΓöÇWHILEΓöÇexprwΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ
  3200.     ΓööΓöÇUNTILΓöÇexpruΓöÇΓöÇΓöÿ
  3201.  
  3202. DO is used to group instructions together and optionally to execute them 
  3203. repetitively. During repetitive execution, a control variable (name) can be 
  3204. stepped through some range of values. 
  3205.  
  3206. Syntax Notes: 
  3207.  
  3208. o The exprr, expri, exprb, exprt, and exprf options (if any are present) are 
  3209.   any expressions that evaluate to a number. The exprr and exprf options are 
  3210.   further restricted to result in a nonnegative whole number. If necessary, the 
  3211.   numbers will be rounded according to the setting of NUMERIC DIGITS. 
  3212.  
  3213. o The exprw or expru options (if present) can be any expression that evaluates 
  3214.   to 1 or 0. 
  3215.  
  3216. o The TO, BY, and FOR phrases can be in any order, if used. 
  3217.  
  3218. o The instructions can include assignments, commands, and keyword instructions 
  3219.   (including any of the more complex constructs such as IF, SELECT, and the DO 
  3220.   instruction itself). 
  3221.  
  3222. o The subkeywords TO, BY, FOR, WHILE, and UNTIL are reserved within a DO 
  3223.   instruction, in that they cannot name variables in the expressions but they 
  3224.   can be used as the name of the control variable. FOREVER is similarly 
  3225.   reserved, but only if it immediately follows the keyword DO. 
  3226.  
  3227. o The exprb option defaults to 1, if relevant. 
  3228.  
  3229. Simple DO Group: 
  3230.  
  3231. If neither repetitor nor conditional is given, the construct merely groups a 
  3232. number of instructions together.  These are executed once. Otherwise, the group 
  3233. of instructions is a repetitive DO loop, and they are executed according to the 
  3234. repetitor phrase, optionally modified by the conditional phrase. 
  3235.  
  3236. In the following example, the instructions are executed once. 
  3237.  
  3238. Example: 
  3239.  
  3240. /* The two instructions between DO and END will both */
  3241. /* be executed if A has the value 3.                 */
  3242. If a=3 then Do
  3243.             a=a+2
  3244.             Say 'Smile!'
  3245.             End
  3246.  
  3247. Simple Repetitive Loops: 
  3248.  
  3249. If repetitor is omitted but there is a conditional or the repetitor is FOREVER, 
  3250. the group of instructions will nominally be executed forever, that is, until 
  3251. the condition is satisfied or a REXX instruction is executed that ends the loop 
  3252. (for example, LEAVE). 
  3253.  
  3254. In the simple form of a repetitive loop, exprr is evaluated immediately (and 
  3255. must result in a nonnegative whole number), and the loop is then executed that 
  3256. many times. 
  3257.  
  3258. Example: 
  3259.  
  3260. /* This displays "Hello" five times */
  3261. Do 5
  3262.   say 'Hello'
  3263.   end
  3264.  
  3265. Note that, similar to the distinction between a command and an assignment, if 
  3266. the first character of exprr is a symbol and the second is an "=" character, 
  3267. the controlled form of repetitor is expected. 
  3268.  
  3269. Controlled Repetitive Loops: 
  3270.  
  3271. The controlled form specifies a control variable, name, which is assigned an 
  3272. initial value (the result of expri, formatted as though 0 had been added). The 
  3273. variable is then stepped (that is, the result of exprb is added at the bottom 
  3274. of the loop) each time the group of instructions is run. The group is run 
  3275. repeatedly while the end condition (determined by the result of exprt) is not 
  3276. met. If exprb is positive or zero, the loop will be terminated when name is 
  3277. greater than exprt. If negative, the loop is terminated when name is less than 
  3278. exprt. 
  3279.  
  3280. The expri, exprt, and exprb options must result in numbers.  They are evaluated 
  3281. once only, before the loop begins and before the control variable is set to its 
  3282. initial value. The default value for exprb is 1. If exprt is omitted, the loop 
  3283. is run indefinitely unless some other condition terminates it. 
  3284.  
  3285. Example: 
  3286.  
  3287. Do I=3 to -2 by -1        /* Would display:   */
  3288.   say i                   /*      3           */
  3289.   end                     /*      2           */
  3290.                           /*      1           */
  3291.                           /*      0           */
  3292.                           /*      -1          */
  3293.                           /*      -2          */
  3294.  
  3295. The numbers do not have to be whole numbers. 
  3296.  
  3297. Example: 
  3298.  
  3299. X=0.3                     /* Would display:   */
  3300. Do Y=X to X+4 by 0.7      /*     0.3          */
  3301.   say Y                   /*     1.0          */
  3302.   end                     /*     1.7          */
  3303.                           /*     2.4          */
  3304.                           /*     3.1          */
  3305.                           /*     3.8          */
  3306.  
  3307. The control variable can be altered within the loop, and this may affect the 
  3308. iteration of the loop. Altering the value of the control variable is not 
  3309. normally considered good programming practice, though it may be appropriate in 
  3310. certain circumstances. 
  3311.  
  3312. Note that the end condition is tested at the start of each iteration (and after 
  3313. the control variable is stepped, on the second and subsequent iterations). 
  3314. Therefore, the group of instructions can be skipped entirely if the end 
  3315. condition is met immediately. Note also that the control variable is referred 
  3316. to by name. If, for example, the compound name A.I is used for the control 
  3317. variable, altering I within the loop causes a change in the control variable. 
  3318.  
  3319. The processing of a controlled loop can be bounded further by a FOR phrase. In 
  3320. this case, exprf must be given and must evaluate to a nonnegative whole number. 
  3321. This acts just like the repetition count in a simple repetitive loop, and sets 
  3322. a limit to the number of iterations around the loop if no other condition 
  3323. terminates it. Similar to the TO and BY expressions, it is evaluated once 
  3324. only-when the DO instruction is first executed and before the control variable 
  3325. is given its initial value. Like the TO condition, the FOR condition is checked 
  3326. at the start of each iteration. 
  3327.  
  3328. Example: 
  3329.  
  3330. Do Y=0.3 to 4.3 by 0.7 for 3  /* Would display:    */
  3331.   say Y                       /*     0.3           */
  3332.   end                         /*     1.0           */
  3333.                               /*     1.7           */
  3334.  
  3335. In a controlled loop, the name describing the control variable can be specified 
  3336. on the END clause. This name must match name in the DO clause in all respects 
  3337. except case (note that no substitution for compound variables is carried out); 
  3338. a syntax error results if it does not. This enables the nesting of loops to be 
  3339. checked automatically, with minimal overhead. 
  3340.  
  3341. Example: 
  3342.  
  3343. Do K=1 to 10
  3344.   ...
  3345.   ...
  3346.   End k  /* Checks that this is the END for K loop */
  3347.  
  3348. Note:   The values taken by the control variable may be affected by the NUMERIC 
  3349.         settings, since normal REXX arithmetic rules apply to the computation 
  3350.         of stepping the control variable. 
  3351.  
  3352. Conditional Phrases (WHILE and UNTIL): 
  3353.  
  3354. Any of the forms of repetitor (none, FOREVER, simple, or controlled) can be 
  3355. followed by a conditional phrase, which may cause termination of the loop. If 
  3356. you specify WHILE or UNTIL, exprw or expru, respectively, is evaluated each 
  3357. time around the loop using the latest values of all variables (and must 
  3358. evaluate to either 0 or 1). The group of instructions is repeatedly processed 
  3359. either while the result is 1 or until the result is 1. 
  3360.  
  3361. For a WHILE loop, the condition is evaluated at the top of the group of 
  3362. instructions; for an UNTIL loop, the condition is evaluated at the bottom, 
  3363. before the control variable has been stepped. 
  3364.  
  3365. Example: 
  3366.  
  3367. Do I=1 to 10 by 2 until i>6
  3368.   say i
  3369.   end
  3370. /* Will display: 1, 3, 5, 7 */
  3371.  
  3372. Note:   The processing of repetitive loops can also be modified by using the 
  3373.         LEAVE or ITERATE instructions. 
  3374.  
  3375.  
  3376. ΓòÉΓòÉΓòÉ 10.5. DROP ΓòÉΓòÉΓòÉ
  3377.  
  3378.               ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  3379.                          Γöé
  3380.  ΓöÇΓöÇΓöÇΓöÇDROPΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇnameΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3381.  
  3382. Each name is a valid variable symbol, optionally enclosed in parentheses (to 
  3383. denote a subsidiary list), and separated from any other name by one or more 
  3384. blanks or comments. 
  3385.  
  3386. DROP is used to unassign variables; that is, to restore them to their original 
  3387. uninitialized state. 
  3388.  
  3389. Each variable specified is dropped from the list of known variables. If a 
  3390. single name is enclosed in parentheses, then its value is used as a subsidiary 
  3391. list of variables to drop. This stored list must follow the same rules as for 
  3392. the main list (that is, valid variable names, separated by blanks) but with no 
  3393. parentheses and no leading or trailing blanks. The variables are dropped in 
  3394. sequence from left to right. It is not an error to specify a name more than 
  3395. once, or to DROP a variable that is not known. If an exposed variable is named 
  3396. (see the PROCEDURE instruction), the variable itself in the older generation is 
  3397. dropped. 
  3398.  
  3399. Example: 
  3400.  
  3401. j=4
  3402. Drop  a x.3 x.j
  3403. /* would reset the variables: A, X.3, and X.4 */
  3404. /* so that reference to them returns their name.    */
  3405.  
  3406. Here, a variable name in parentheses is used as a subsidiary list. 
  3407.  
  3408. Example: 
  3409.  
  3410. x=4;y=5;z=6;
  3411. a='x y z'
  3412. DROP (a)    /* will drop x,y, and z */
  3413.  
  3414. If a stem is specified (that is, a symbol that contains only one period, as the 
  3415. last character), all variables starting with that stem are dropped. 
  3416.  
  3417. Example: 
  3418.  
  3419. Drop  x.
  3420. /* would reset all variables with names starting with X. */
  3421.  
  3422.  
  3423. ΓòÉΓòÉΓòÉ 10.6. EXIT ΓòÉΓòÉΓòÉ
  3424.  
  3425.  
  3426.  ΓöÇΓöÇΓöÇΓöÇEXITΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3427.               ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  3428.  
  3429. EXIT is used to leave a program unconditionally. Optionally, EXIT returns a 
  3430. data string to the caller. The program is terminated immediately, even if an 
  3431. internal routine is currently being run.  If no internal routine is active, 
  3432. RETURN and EXIT are identical in their effect on the program that is being run. 
  3433.  
  3434. If you specify expression, it is evaluated and the string resulting from the 
  3435. evaluation is then passed back to the caller when the program terminates. 
  3436.  
  3437. Example: 
  3438.  
  3439. j=3
  3440. Exit j*4
  3441. /* Would exit with the string '12' */
  3442.  
  3443. If you do not specify expression, no data is passed back to the caller. If the 
  3444. program was called as an external function, this is detected as an error, 
  3445. either immediately (if RETURN was used), or on return to the caller (if EXIT 
  3446. was used). 
  3447.  
  3448. "Running off the end" of the program is always equivalent to the EXIT 
  3449. instruction, in that it terminates the whole program and returns no result 
  3450. string. 
  3451.  
  3452. Note:   The language processor does not distinguish between invocation as a 
  3453.         command on the one hand, and invocation as a subroutine or function on 
  3454.         the other. If the program was invoked through a command interface, an 
  3455.         attempt is made to convert the returned value to a return code 
  3456.         acceptable by the REXX caller.  The returned string must be a whole 
  3457.         number whose value will fit in a 16-bit signed integer (within the 
  3458.         range -2**15 to 2**15-1). 
  3459.  
  3460.  
  3461. ΓòÉΓòÉΓòÉ 10.7. IF ΓòÉΓòÉΓòÉ
  3462.  
  3463.  ΓöÇΓöÇIFΓöÇexpressionΓöÇΓö¼ΓöÇΓö¼THENΓöÇΓö¼ΓöÇΓö¼instructionΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ
  3464.                    Γöö;Γöÿ     Γöö;Γöÿ            ΓööΓöÇELSEΓöÇΓö¼ΓöÇΓö¼instructionΓöÿ
  3465.                                                  Γöö;Γöÿ
  3466.  
  3467. IF is used to conditionally process an instruction or group of instructions 
  3468. depending on the evaluation of the expression. The expression must evaluate to 
  3469. 0 or 1. 
  3470.  
  3471. The instruction after the THEN is processed only if the result of the 
  3472. evaluation is 1. If you specify an ELSE clause, the instruction after ELSE is 
  3473. processed only if the result of the evaluation is 0. 
  3474.  
  3475. Example: 
  3476.  
  3477. if answer='YES' then say 'OK!'
  3478.                 else say 'Why not?'
  3479.  
  3480. Remember that if the ELSE clause is on the same line as the last clause of the 
  3481. THEN part, you need a semicolon to terminate that clause. 
  3482.  
  3483. Example: 
  3484.  
  3485. if answer='YES' then say 'OK!';  else say 'Why not?'
  3486.  
  3487. The ELSE binds to the nearest IF at the same level. The NOP instruction can be 
  3488. used to eliminate errors and possible confusion when IF constructs are nested, 
  3489. as in the following example. 
  3490.  
  3491. Example: 
  3492.  
  3493. If answer = 'YES' Then
  3494.    If name = 'FRED' Then
  3495.       say 'OK, Fred.'
  3496.    Else
  3497.       nop
  3498. Else
  3499.    say 'Why not?'
  3500.  
  3501. Notes: 
  3502.  
  3503.  1. The instruction can be any assignment, command, or keyword instruction, 
  3504.     including any of the more complex constructs such as DO, SELECT, or the IF 
  3505.     instruction itself. A null clause is not an instruction; so putting an 
  3506.     extra semicolon after the THEN or ELSE is not equivalent to putting a dummy 
  3507.     instruction (as it would be in C). The NOP instruction is provided for this 
  3508.     purpose. 
  3509.  
  3510.  2. The symbol THEN cannot be used within expression, because the keyword THEN 
  3511.     is treated differently, in that it need not start a clause.  This allows 
  3512.     the expression on the IF clause to be terminated by the THEN, without a 
  3513.     semicolon being required.  If this were not so, users of other computer 
  3514.     languages would experience considerable difficulties. 
  3515.  
  3516.  
  3517. ΓòÉΓòÉΓòÉ 10.8. INTERPRET ΓòÉΓòÉΓòÉ
  3518.  
  3519.  
  3520.  ΓöÇΓöÇΓöÇΓöÇINTERPRETΓöÇΓöÇΓöÇΓöÇexpressionΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3521.  
  3522. INTERPRET is used to process instructions that have been built dynamically by 
  3523. evaluating expression. 
  3524.  
  3525. The expression is evaluated, and is then processed (interpreted) as though the 
  3526. resulting string was a line inserted into the input file (and bracketed by a 
  3527. DO; and an END;). 
  3528.  
  3529. Any instructions (including INTERPRET instructions) are allowed, but note that 
  3530. constructions such as DO ... END and SELECT ... END must be complete. For 
  3531. example, a string of instructions being interpreted cannot contain a LEAVE or 
  3532. ITERATE instruction (valid only within a repetitive DO loop) unless it also 
  3533. contains the whole repetitive DO ... END construct. 
  3534.  
  3535. A semicolon is implied at the end of the expression during processing, as a 
  3536. service to the user. 
  3537.  
  3538. Example: 
  3539.  
  3540. data='FRED'
  3541. interpret data '= 4'
  3542. /* Will a) build the string  "FRED = 4"         */
  3543. /*      b) execute  FRED = 4;                   */
  3544. /* Thus the variable "FRED" will be set to "4"  */
  3545.  
  3546. Example: 
  3547.  
  3548. data='do 3; say "Hello there!"; end'
  3549. interpret data        /* Would display:         */
  3550.                       /*  Hello there!          */
  3551.                       /*  Hello there!          */
  3552.                       /*  Hello there!          */
  3553.  
  3554. Notes: 
  3555.  
  3556.  1. Labels within the interpreted string are not permanent and are therefore 
  3557.     ignored. Therefore, executing a SIGNAL instruction from within an 
  3558.     interpreted string causes immediate exit from that string before the label 
  3559.     search begins. 
  3560.  
  3561.  2. If you are new to the concept of the INTERPRET instruction and are getting 
  3562.     results that you do not understand, you might find that executing the 
  3563.     instruction with TRACE R or TRACE I set is helpful. 
  3564.  
  3565.     Example: 
  3566.  
  3567.         /* Here we have a small program. */
  3568.         Trace Int
  3569.         name='Kitty'
  3570.         indirect='name'
  3571.         interpret 'say "Hello"' indirect'"!"'
  3572.  
  3573.     when run, the following trace is displayed: 
  3574.  
  3575.         [C:\]kitty
  3576.         kitty
  3577.              3 *-* name='Kitty'
  3578.                >L>   "Kitty"
  3579.              4 *-* indirect='name'
  3580.                >L>   "name"
  3581.              5 *-* interpret 'say "Hello"' indirect'"!"'
  3582.                >L>   "say "Hello""
  3583.                >V>   "name"
  3584.                >O>   "say "Hello" name"
  3585.                >L>   ""!""
  3586.                >O>   "say "Hello" name"!""
  3587.                *-*  say "Hello" name"!"
  3588.                >L>    "Hello"
  3589.                >V>    "Kitty"
  3590.                >O>    "Hello Kitty"
  3591.                >L>    "!"
  3592.                >O>    "Hello Kitty!"
  3593.         Hello Kitty!
  3594.         [C:\]
  3595.  
  3596.     Lines 3 and 4 set the variables used in line 5. Execution of line 5 then 
  3597.     proceeds in two stages. First the string to be interpreted is built up, 
  3598.     using a literal string, a variable (INDIRECT), and another literal. The 
  3599.     resulting pure character string is then interpreted, as though it were 
  3600.     actually part of the original program. Since it is a new clause, it is 
  3601.     traced as such (the second *-* trace flag under line 5) and is then 
  3602.     executed. Again a literal string is concatenated to the value of a variable 
  3603.     (NAME) and another literal, and the final result is then displayed as 
  3604.     follows: 
  3605.  
  3606.         Hello Kitty!
  3607.  
  3608.  3. For many purposes, the VALUE function can be used instead of the INTERPRET 
  3609.     instruction.  Line 5 in the last example could therefore have been replaced 
  3610.     by: 
  3611.  
  3612.         say "Hello" value(indirect)"!"
  3613.  
  3614.     INTERPRET is usually only required in special cases, such as when more than 
  3615.     one statement is to be interpreted at once. 
  3616.  
  3617.  
  3618. ΓòÉΓòÉΓòÉ 10.9. ITERATE ΓòÉΓòÉΓòÉ
  3619.  
  3620.  ΓöÇΓöÇΓöÇΓöÇITERATEΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3621.                 ΓööΓöÇΓöÇnameΓöÇΓöÇΓöÿ
  3622.  
  3623. ITERATE is used to alter the flow within a repetitive DO loop (that is, any DO 
  3624. construct other than that with a simple DO loop). 
  3625.  
  3626. Processing of the group of instructions stops, and control is passed to the DO 
  3627. instruction just as though the END clause had been encountered. The control 
  3628. variable (if any) is incremented and tested, as normal, and the group of 
  3629. instructions is processed again, unless the loop is terminated by the DO 
  3630. instruction. 
  3631.  
  3632. If name is not specified, ITERATE steps the innermost active repetitive loop. 
  3633. If name is specified, it must be the name of the control variable of a 
  3634. currently active loop which may be the innermost loop; this is the loop that is 
  3635. stepped. Any active loops inside the one selected for iteration are terminated 
  3636. (as though by a LEAVE instruction). 
  3637.  
  3638. Example: 
  3639.  
  3640. do i=1 to 4
  3641.   if i=2 then iterate
  3642.   say i
  3643.   end
  3644. /* Would display the numbers:   1, 3, 4  */
  3645.  
  3646. Notes: 
  3647.  
  3648.  1. If specified, name must match the name on the DO instruction in all 
  3649.     respects except case. No substitution for compound variables is carried out 
  3650.     when the comparison is made. 
  3651.  
  3652.  2. A loop is active if it is currently being processed. If during execution of 
  3653.     a loop, a subroutine is called or an INTERPRET instruction is processed, 
  3654.     the loop becomes inactive until the subroutine has returned or the 
  3655.     INTERPRET instruction has completed. ITERATE cannot be used to step an 
  3656.     inactive loop. 
  3657.  
  3658.  3. If more than one active loop uses the same control variable, the innermost 
  3659.     loop is the one selected by ITERATE. 
  3660.  
  3661.  
  3662. ΓòÉΓòÉΓòÉ 10.10. LEAVE ΓòÉΓòÉΓòÉ
  3663.  
  3664.  ΓöÇΓöÇΓöÇΓöÇLEAVEΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3665.                 ΓööΓöÇΓöÇnameΓöÇΓöÇΓöÿ
  3666.  
  3667. LEAVE is used to cause an immediate exit from one or more repetitive DO loops 
  3668. (that is, any DO construct other than a simple DO loop). 
  3669.  
  3670. Processing of the group of instructions is terminated, and control is passed to 
  3671. the instruction following the END clause as though the END clause had been 
  3672. encountered and the termination condition had been met normally.  However, on 
  3673. exit, the control variable, if any, will contain the value it had when the 
  3674. LEAVE instruction was processed. 
  3675.  
  3676. If name is not specified, LEAVE terminates the innermost active repetitive 
  3677. loop. If name is specified, it must be the name of the control variable of a 
  3678. currently active loop which may be the innermost loop; that loop (and any 
  3679. active loops inside it) is then terminated. Control then passes to the clause 
  3680. following the END clause that matches the DO clause of the selected loop. 
  3681.  
  3682. Example: 
  3683.  
  3684. do i=1 to 5
  3685.   say i
  3686.   if i=3 then leave
  3687.   end
  3688. /* Would display the numbers:   1, 2, 3  */
  3689.  
  3690. Notes: 
  3691.  
  3692.  1. If specified, name must match the one on the DO instruction in all respects 
  3693.     except case. No substitution for compound variables is carried out when the 
  3694.     comparison is made. 
  3695.  
  3696.  2. A loop is active if it is currently being processed. If during execution of 
  3697.     a loop, a subroutine is called or an INTERPRET instruction is processed, 
  3698.     the loop becomes inactive until the subroutine has returned or the 
  3699.     INTERPRET instruction has completed. LEAVE cannot be used to terminate an 
  3700.     inactive loop. 
  3701.  
  3702.  3. If more than one active loop uses the same control variable, the innermost 
  3703.     one is the one selected by LEAVE. 
  3704.  
  3705.  
  3706. ΓòÉΓòÉΓòÉ 10.11. NOP ΓòÉΓòÉΓòÉ
  3707.  
  3708.  ΓöÇΓöÇΓöÇΓöÇNOPΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3709.  
  3710. NOP is a dummy instruction that has no effect.  It can be useful as the target 
  3711. of a THEN or ELSE clause. 
  3712.  
  3713. Example: 
  3714.  
  3715. Select
  3716.    when a=b then nop           /* Do nothing */
  3717.    when a>b then say 'A > B'
  3718.    otherwise     say 'A < B'
  3719. end
  3720.  
  3721. Note:   Using an extra semicolon instead of the NOP inserts a null clause, 
  3722.         which is ignored. The second WHEN clause is seen as the first 
  3723.         instruction expected after the THEN clause, and therefore is treated as 
  3724.         a syntax error. NOP is a true instruction, however, and is a valid 
  3725.         target for the THEN clause. 
  3726.  
  3727.  
  3728. ΓòÉΓòÉΓòÉ 10.12. NUMERIC ΓòÉΓòÉΓòÉ
  3729.  
  3730.  
  3731.  ΓöÇΓöÇNUMERICΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇDIGITSΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ;ΓöÇΓöÇ
  3732.                  Γöé         ΓööΓöÇexpressionΓöÇΓöÇΓöÿ         Γöé
  3733.                  Γö£ΓöÇΓöÇFORMΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöñ
  3734.                  Γöé        Γö£ΓöÇSCIENTIFICΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γöé
  3735.                  Γöé        Γö£ΓöÇENGINEERINGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ Γöé
  3736.                  Γöé        ΓööΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇexpressionΓöÇΓöÿ Γöé
  3737.                  Γöé          ΓööΓöÇVALUEΓöÇΓöÿ              Γöé
  3738.                  ΓööΓöÇΓöÇFUZZΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3739.                           ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  3740.  
  3741. The NUMERIC instruction is used to change the way in which arithmetic 
  3742. operations are carried out. The options of this instruction are described in 
  3743. detail in the OS/2 Procedures Language 2/REXX Reference. 
  3744.  
  3745. NUMERIC DIGITS controls the precision to which arithmetic operations and 
  3746. arithmetic built-in functions are evaluated. If expression is omitted, then the 
  3747. default value of 9 is used.  Otherwise the result of the expression is rounded, 
  3748. if necessary, according to the current setting of NUMERIC DIGITS. The value 
  3749. used must be a positive whole number that is larger than the current NUMERIC 
  3750. FUZZ setting. 
  3751.  
  3752. There is no limit to the value for DIGITS (except the amount of storage 
  3753. available), but note that high precisions are likely to require a good deal of 
  3754. processor time. It is recommended that you use the default value wherever 
  3755. possible. 
  3756.  
  3757. You can retrieve the current setting of NUMERIC DIGITS with the DIGITS built-in 
  3758. function 
  3759.  
  3760. NUMERIC FORM controls the form of exponential notation used by REXX for the 
  3761. result of arithmetic operations and arithmetic built-in functions. This may be 
  3762. either SCIENTIFIC (in which case only one, nonzero digit appears before the 
  3763. decimal point), or ENGINEERING (in which case the power of ten is always a 
  3764. multiple of three). The default is SCIENTIFIC. The FORM is set either directly 
  3765. by the subkeywords SCIENTIFIC or ENGINEERING or is taken from the result of 
  3766. evaluating the expression following VALUE. The result in this case must be 
  3767. either SCIENTIFIC or ENGINEERING. You can omit the subkeyword VALUE if the 
  3768. expression does not begin with a symbol or a literal string (for example, if it 
  3769. starts with a special character, such as an operator or parenthesis). 
  3770.  
  3771. You can retrieve the current setting of NUMERIC FORM with the FORM built-in 
  3772. function 
  3773.  
  3774. NUMERIC FUZZ controls how many digits, at full precision, are ignored during a 
  3775. numeric comparison operation. If expression is omitted, the default is 0 
  3776. digits.  Otherwise expression must evaluate to 0 or a positive whole number 
  3777. rounded, if necessary, according to the current setting of NUMERIC DIGITS 
  3778. before it is used. The value used must be a positive whole number that is 
  3779. smaller than the current NUMERIC DIGITS setting. 
  3780.  
  3781. FUZZ temporarily reduces the value of DIGITS by the FUZZ value before every 
  3782. numeric comparison operation. The numbers being compared are subtracted from 
  3783. each other under a precision of DIGITS minus FUZZ digits and this result is 
  3784. then compared with 0. 
  3785.  
  3786. You can retrieve the current NUMERIC FUZZ setting with the FUZZ built-in 
  3787. function 
  3788.  
  3789. Note:   The three numeric settings are automatically saved across subroutine 
  3790.         and internal function calls.  See the CALL instruction for more 
  3791.         details. 
  3792.  
  3793.  
  3794. ΓòÉΓòÉΓòÉ 10.13. OPTIONS ΓòÉΓòÉΓòÉ
  3795.  
  3796.  ΓöÇΓöÇΓöÇΓöÇOPTIONSΓöÇΓöÇΓöÇΓöÇΓöÇexpressionΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3797.  
  3798. OPTIONS is used to pass special requests or parameters to the language 
  3799. processor.  For example, they can be language processor options or they can 
  3800. define a special character set. 
  3801.  
  3802. The expression is evaluated, and the result is examined one word at a time.  If 
  3803. the words are recognized by the language processor, then they are obeyed. 
  3804. Words that are not recognized are ignored and assumed to be instructions to a 
  3805. different processor. 
  3806.  
  3807. The following words are recognized by the language processors: 
  3808.  
  3809. ETMODE            Specifies that literal strings containing double-byte 
  3810.                   character set (DBCS) characters can be used in the program. 
  3811.  
  3812. NOETMODE          Specifies that literal strings containing DBCS characters 
  3813.                   cannot be used in the program. NOETMODE is the default. 
  3814.  
  3815. EXMODE            Specifies that DBCS data in mixed strings is handled on a 
  3816.                   logical character basis by instructions, operators and 
  3817.                   functions. DBCS data integrity is maintained. 
  3818.  
  3819. NOEXMODE          Specifies that any data in strings is handled on a byte 
  3820.                   basis. The integrity of any DBCS characters might be lost. 
  3821.                   NOEXMODE is the default. 
  3822. Notes: 
  3823.  
  3824.  1. Because of the scanning procedures of the language processor, you are 
  3825.     advised to place an OPTIONS ETMODE instruction as the first instruction of 
  3826.     a program containing DBCS literal strings. 
  3827.  
  3828.  2. To ensure proper scanning of a program containing DBCS literals, type the 
  3829.     words ETMODE, NOETMODE, EXMODE, and NOEXMODE as literal strings (that is, 
  3830.     enclosed in quotation marks) in the OPTIONS instruction. 
  3831.  
  3832.  3. The OPTIONS ETMODE and OPTIONS EXMODE settings are saved and restored 
  3833.     across subroutine and function calls. 
  3834.  
  3835.  4. The words ETMODE, EXMODE, NOEXMODE, and NOETMODE can occur several times 
  3836.     within the result. The word that takes effect is determined by the last 
  3837.     valid one specified between the pairs ETMODE/NOETMODE and EXMODE/NOEXMODE. 
  3838.  
  3839.  
  3840. ΓòÉΓòÉΓòÉ 10.14. PARSE ΓòÉΓòÉΓòÉ
  3841.  
  3842.  
  3843.  ΓöÇΓöÇPARSEΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇARGΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇ
  3844.            ΓööΓöÇUPPERΓöÇΓöÿ Γö£ΓöÇΓöÇPULLΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÿ
  3845.                      Γö£ΓöÇΓöÇSOURCEΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ      list
  3846.                      Γö£ΓöÇΓöÇVALUEΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇWITHΓöÇΓöñ
  3847.                      Γöé        ΓööΓöÇexpressionΓöÇΓöÿ      Γöé
  3848.                      Γö£ΓöÇΓöÇVARΓöÇΓöÇnameΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  3849.                      ΓööΓöÇΓöÇVERSIONΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  3850.  
  3851. PARSE is used to assign data from various sources to one or more variables 
  3852. according to the rules and templates described in the section on parsing in the 
  3853. OS/2 Procedures Language 2/REXX Reference. 
  3854.  
  3855. If specified, a template is a list of symbols separated by blanks or patterns. 
  3856.  
  3857. If template is not specified, no variables are set but action is taken to get 
  3858. the data ready for parsing if necessary. Thus, for PARSE PULL, a data string is 
  3859. removed from the current data queue; for PARSE LINEIN (and PARSE PULL if the 
  3860. current queue is empty), a line is taken from the default character input 
  3861. stream; and for PARSE VALUE, expression is evaluated. For PARSE VAR, the 
  3862. specified variable is accessed. If it does not have a value, the NOVALUE 
  3863. condition is raised, if it is enabled. 
  3864.  
  3865. If the UPPER option is specified, the data to be parsed is first translated to 
  3866. uppercase (for example, a lowercase a-z to an uppercase A-Z). Otherwise, no 
  3867. uppercase translation takes place during the parsing. 
  3868.  
  3869. The data used for each variant of the PARSE instruction is as follows: 
  3870.  
  3871. PARSE ARG - The strings passed to the program, subroutine, or function as the 
  3872. input argument list, are parsed. See the ARG instruction for details and 
  3873. examples. 
  3874.  
  3875. Note:   The argument strings to a REXX program or internal routine can also be 
  3876.         retrieved or checked by using the ARG built-in function. 
  3877.  
  3878. PARSE LINEIN - The next line from the default character input stream is parsed. 
  3879. (See the OS/2 Procedures Language 2/REXX Reference for a discussion of the REXX 
  3880. input model.) PARSE LINEIN is a shorter form of the following instruction: 
  3881.  
  3882.  
  3883.  ΓöÇΓöÇPARSEΓöÇVALUEΓöÇLINEIN()ΓöÇWITHΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇ
  3884.                                ΓööΓöÇtemplateΓöÇΓöÿ
  3885.  
  3886. If no line is available, program execution will normally pause until a line is 
  3887. complete. Note that PARSE LINEIN should only be used when direct access to the 
  3888. character input stream is necessary. Normal line-by-line dialogue with the user 
  3889. should be carried out with the PULL or PARSE PULL instructions, to maintain 
  3890. generality and programmability. 
  3891.  
  3892. To check if any lines are available in the default character input stream, use 
  3893. the built-in function LINES. 
  3894.  
  3895. PARSE PULL - The next string from the queue is parsed.  If the queue is empty, 
  3896. lines will be read from the default input, typically the user's keyboard.  You 
  3897. can add data to the head or tail of the queue by using the PUSH and QUEUE 
  3898. instructions respectively.  You can find the number of lines currently in the 
  3899. queue by using the QUEUED built-in function. The queue remains active as long 
  3900. as the language processor is active. The queue can be altered by other programs 
  3901. in the system and can be used as a means of communication between these 
  3902. programs and programs written in REXX. 
  3903.  
  3904. Note:   PULL and PARSE PULL read first from the current data queue; if the 
  3905.         queue is empty, they read from the default input stream, STDIN 
  3906.         (typically, the keyboard). 
  3907.  
  3908. PARSE SOURCE - The data parsed describes the source of the program being run. 
  3909.  
  3910. The source string contains the characters OS/2, followed by either COMMAND, 
  3911. FUNCTION, or SUBROUTINE, depending on whether the program was invoked as a host 
  3912. command or from a function call in an expression or using the CALL instruction. 
  3913. These two tokens are followed by the complete path specification of the program 
  3914. file. 
  3915.  
  3916. The string parsed might, therefore, be displayed as: 
  3917.  
  3918. OS/2 COMMAND C:\OS2\REXTRY.CMD
  3919.  
  3920. PARSE VALUE - The expression is evaluated, and the result is the data that is 
  3921. parsed. Note that WITH is a subkeyword in this context and so cannot be used as 
  3922. a symbol within expression.  For example: 
  3923.  
  3924. PARSE VALUE time() WITH  hours ':' mins ':' secs
  3925.  
  3926. gets the current time and splits it up into its constituent parts. 
  3927.  
  3928. PARSE VAR name - The value of the variable specified by name is parsed.  The 
  3929. name must be a symbol that is valid as a variable name; that is, it can not 
  3930. start with a period or a digit.  Note that the variable name is not changed 
  3931. unless it appears in the template. For example: 
  3932.  
  3933. PARSE VAR string word1 string
  3934.  
  3935. removes the first word from string and puts it in the variable word1, and 
  3936. assigns the remainder back to string.  Similarly: 
  3937.  
  3938. PARSE UPPER VAR string word1 string
  3939.  
  3940. also translates the data from string to uppercase before it is parsed. 
  3941.  
  3942. PARSE VERSION - Information describing the language level and the date of the 
  3943. language processor is parsed.  This consists of five words (delimited by 
  3944. blanks): first the string "REXXSAA", then the language level description 
  3945. ("4.00"), and finally the release date ("13 June 1989"). 
  3946.  
  3947. Note:   PARSE VERSION information should be parsed on a word basis rather than 
  3948.         on an absolute column position basis. 
  3949.  
  3950.  
  3951. ΓòÉΓòÉΓòÉ 10.15. PROCEDURE ΓòÉΓòÉΓòÉ
  3952.  
  3953.  
  3954.  ΓöÇΓöÇΓöÇPROCEDUREΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  3955.                  Γöé          ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ Γöé
  3956.                  Γöé                 Γöé Γöé
  3957.                  ΓööΓöÇΓöÇEXPOSEΓöÇΓöÇΓö┤ΓöÇnameΓöÇΓöÇΓö┤ΓöÇΓöÿ
  3958.  
  3959. The PROCEDURE instruction can be used within an internal routine (subroutine or 
  3960. function) to protect all the existing variables by making them unknown to the 
  3961. instructions that follow. On executing a RETURN instruction, the original 
  3962. variables environment is restored and any variables used in the routine (which 
  3963. were not exposed) are dropped. 
  3964.  
  3965. The EXPOSE option modifies this.  Any variable specified by name is exposed, so 
  3966. that any reference to it (including setting and dropping) is made to the 
  3967. environment of the variables that the caller owns. With the EXPOSE option, you 
  3968. must specify at least one name, a symbol separated from any other name with one 
  3969. or more blanks. Optionally, you can enclose a single name in parentheses to 
  3970. denote a subsidiary variable list. Any variables not specified by name on a 
  3971. PROCEDURE EXPOSE instruction are still protected.  Hence, some limited set of 
  3972. the caller's variables can be made accessible, and these variables can be 
  3973. changed (or new variables in this set can be created).  All these changes will 
  3974. be visible to the caller upon RETURN from the routine. 
  3975.  
  3976. The variables are exposed in sequence from left to right. It is not an error to 
  3977. specify a name more than once, or to specify a name that has not been used as a 
  3978. variable by the caller. 
  3979.  
  3980. Example: 
  3981.  
  3982. /* This is the main program */
  3983. j=1; x.1='a'
  3984. call toft
  3985. say j k m       /* would display "1 7 M" */
  3986. exit
  3987.  
  3988. toft: procedure expose j k x.j
  3989.    say j k x.j  /* would display "1 K a"   */
  3990.    k=7; m=3     /* note "M" is not exposed */
  3991.    return
  3992.  
  3993. Note that if X.J in the EXPOSE list had been placed before J, the caller's 
  3994. value of J would not have been visible at that time, so X.1 would not have been 
  3995. exposed. 
  3996.  
  3997. If name is enclosed in parentheses (blanks are not necessary either inside or 
  3998. outside the parentheses but can be added if desired) then, after that variable 
  3999. is exposed, the value of the variable is immediately used as a subsidiary list 
  4000. of variables.  This list of variables must follow the same rules as the main 
  4001. list except that no parentheses or leading or trailing blanks are allowed. The 
  4002. variables named in a subsidiary list are also exposed from left to right. 
  4003.  
  4004. Example: 
  4005.  
  4006. j=1;k=6;m=9
  4007. a ='j k m'
  4008. test:procedure expose (a)   /* will expose j, k, and x */
  4009.  
  4010. If a stem is specified in names, all possible compound variables whose names 
  4011. begin with that stem are exposed. (A stem is a symbol containing only one 
  4012. period, which is the last character. 
  4013.  
  4014. Example: 
  4015.  
  4016. lucky7:Procedure Expose i j a. b.
  4017. /* This exposes "I", "J", and all variables whose */
  4018. /* names start with "A." or "B."                  */
  4019. A.1='7'  /* This will set "A.1" in the caller's   */
  4020.          /* environment, even if it did not       */
  4021.          /* previously exist.                     */
  4022.  
  4023. Variables can be exposed through several generations of routines, if desired, 
  4024. by ensuring that they are included on all intermediate PROCEDURE instructions. 
  4025.  
  4026. Only one PROCEDURE instruction in each level of routine call is allowed; all 
  4027. others (and those met outside of internal routines) are in error. 
  4028.  
  4029. Notes: 
  4030.  
  4031.  1. An internal routine need not include a PROCEDURE instruction, in which case 
  4032.     the variables it is manipulating are those the caller owns. 
  4033.  
  4034.  2. The PROCEDURE instruction must be the first instruction executed after the 
  4035.     CALL or function invocation, that is, it must be the first instruction 
  4036.     following the label. 
  4037.  
  4038. See the CALL instruction for details and examples of how routines are invoked. 
  4039.  
  4040.  
  4041. ΓòÉΓòÉΓòÉ 10.16. PULL ΓòÉΓòÉΓòÉ
  4042.  
  4043.  
  4044.  ΓöÇΓöÇΓöÇΓöÇPULLΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4045.                  ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÿ
  4046.  
  4047. PULL is used to read a string from the head of the currently active REXX data 
  4048. queue. It is a short form of the instruction: 
  4049.  
  4050.  ΓöÇΓöÇPARSE UPPER PULLΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇΓöÇΓöÇΓöÇ
  4051.                        ΓööΓöÇΓöÇtemplateΓöÇΓöÇΓöÇΓöÿ
  4052.  
  4053. The current head-of-queue is read as one string.  If no template is specified, 
  4054. no further action is taken, and the string is effectively discarded.  If 
  4055. specified, a template is a list of symbols separated by blanks or patterns. The 
  4056. string is translated to uppercase (for example, a lowercase a-z to an uppercase 
  4057. A-Z), and then parsed into variables according to the rules described in the 
  4058. section on parsing in the OS/2 Procedures Language 2/REXX Reference.  Use the 
  4059. PARSE PULL instruction if you do not want uppercase translation. 
  4060.  
  4061. Note:   If the current data queue is empty, PULL reads instead from STDIN 
  4062.         (typically, the keyboard). The length of data read by the PULL 
  4063.         instruction is restricted to the length of strings contained by 
  4064.         variables. 
  4065.  
  4066. Example: 
  4067.  
  4068. Say 'Do you want to erase the file?  Answer Yes or No:'
  4069. Pull answer .
  4070. if answer='NO' then Say 'The file will not be erased.'
  4071.  
  4072. Here the dummy placeholder "." is used on the template to isolate the first 
  4073. word the user enters. 
  4074.  
  4075. The number of lines currently in the queue can be found with the QUEUED 
  4076. built-in function. 
  4077.  
  4078.  
  4079. ΓòÉΓòÉΓòÉ 10.17. PUSH ΓòÉΓòÉΓòÉ
  4080.  
  4081.  
  4082.  ΓöÇΓöÇΓöÇΓöÇPUSHΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4083.                  ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4084.  
  4085. PUSH is used to stack the string resulting from the evaluation of expression in 
  4086. LIFO (last in, first out) format onto the currently active REXX data queue. If 
  4087. you do not specify expression, a null string is stacked. 
  4088.  
  4089. Example: 
  4090.  
  4091. a='Fred'
  4092. push       /* Puts a null line onto the queue */
  4093. push a 2   /* Puts "Fred 2"    onto the queue */
  4094.  
  4095. The number of lines currently in the queue can be found with the QUEUED 
  4096. built-in function. 
  4097.  
  4098.  
  4099. ΓòÉΓòÉΓòÉ 10.18. QUEUE ΓòÉΓòÉΓòÉ
  4100.  
  4101.  ΓöÇΓöÇΓöÇΓöÇQUEUEΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4102.                  ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4103.  
  4104. QUEUE is used to append the string resulting from expression to the tail of the 
  4105. currently active REXX data queue. That is, it is added in FIFO (first in, first 
  4106. out) format. 
  4107.  
  4108. If you do not specify expression, a null string is queued. 
  4109.  
  4110. Example: 
  4111.  
  4112. a='Toft'
  4113. queue a 2  /* Enqueues "Toft 2" */
  4114. queue      /* Enqueues a null line behind the last */
  4115.  
  4116. The number of lines currently in the queue can be found with the QUEUED 
  4117. built-in function. 
  4118.  
  4119.  
  4120. ΓòÉΓòÉΓòÉ 10.19. RETURN ΓòÉΓòÉΓòÉ
  4121.  
  4122.  ΓöÇΓöÇΓöÇΓöÇRETURNΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4123.                  ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4124.  
  4125. RETURN is used to return control (and possibly a result) from a REXX program or 
  4126. internal routine to the point of its invocation. 
  4127.  
  4128. If no internal routine (subroutine or function) is active, RETURN and EXIT are 
  4129. identical in their effect on the program that is being run. 
  4130.  
  4131. If a subroutine is being processed (see the CALL instruction), expression (if 
  4132. any) is evaluated, control passes back to the caller, and the REXX special 
  4133. variable RESULT is set to the value of expression. If expression is omitted, 
  4134. the special variable RESULT is dropped (becomes uninitialized). The various 
  4135. settings saved at the time of the CALL (tracing, addresses, and so on) are also 
  4136. restored. 
  4137.  
  4138. If a function is being processed, the action taken is identical, except that 
  4139. expression must be specified on the RETURN instruction. The result of 
  4140. expression is then used in the original expression at the point where the 
  4141. function was invoked. 
  4142.  
  4143. If a PROCEDURE instruction was processed within the routine (subroutine or 
  4144. internal function), all variables of the current generation are dropped (and 
  4145. those of the previous generation are exposed) after expression is evaluated and 
  4146. before the result is used or assigned to RESULT. 
  4147.  
  4148.  
  4149. ΓòÉΓòÉΓòÉ 10.20. SAY ΓòÉΓòÉΓòÉ
  4150.  
  4151.  ΓöÇΓöÇΓöÇΓöÇSAYΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4152.                 ΓööΓöÇΓöÇexpressionΓöÇΓöÇΓöÿ
  4153.  
  4154. SAY is used to write to the output stream the result of evaluating expression. 
  4155. The result is usually displayed to the user, but the output destination can 
  4156. depend on the implementation. The result of expression can be of any length. 
  4157.  
  4158. Notes: 
  4159.  
  4160.  1. Data from the SAY instruction is sent to the default output stream 
  4161.     (STDOUT:) However, the standard OS/2 rules for redirecting output apply to 
  4162.     SAY output. 
  4163.  
  4164.  2. The SAY instruction does not format data; line wrapping is handled by the 
  4165.     operating system and the hardware. However formatting is accomplished, the 
  4166.     output data remains a single logical line. 
  4167.  
  4168. Example: 
  4169.  
  4170. data=100
  4171. Say data 'divided by 4 =>' data/4
  4172. /* Would display: "100 divided by 4 => 25"  */
  4173.  
  4174.  
  4175. ΓòÉΓòÉΓòÉ 10.21. SELECT ΓòÉΓòÉΓòÉ
  4176.  
  4177.  
  4178.              ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
  4179.                                                        Γöé
  4180.  ΓöÇΓöÇSELECT;ΓöÇΓö┤WHENΓöÇexpressionΓöÇΓö¼ΓöÇΓö¼ΓöÇTHENΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇinstructionΓö┤ΓöÇΓöÇ
  4181.                               Γöö;Γöÿ      Γöö;Γöÿ
  4182.  
  4183.   ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇEND;ΓöÇΓöÇΓöÇΓöÇΓöÇ
  4184.         ΓööΓöÇOTHERWISEΓöÇΓö¼ΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  4185.                     Γöö;Γöÿ Γöé  ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ  Γöé
  4186.                         Γöé               Γöé  Γöé
  4187.                         ΓööΓöÇΓöÇΓö┤ΓöÇinstructionΓöÇΓö┤ΓöÇΓöÇΓöÿ
  4188.  
  4189. SELECT is used to conditionally process one of several alternative 
  4190. instructions. 
  4191.  
  4192. Each expression after a WHEN clause is evaluated in turn and must result in 0 
  4193. or 1. If the result is 1, the instruction following the THEN clause, which can 
  4194. be a complex instruction such as IF, DO, or SELECT, is processed and control 
  4195. then passes to the END clause. If the result is 0, control passes to the next 
  4196. WHEN clause. 
  4197.  
  4198. If none of the WHEN expressions evaluate to 1, control passes to the 
  4199. instructions, if any, after OTHERWISE. In this situation, the absence of 
  4200. OTHERWISE causes an error. 
  4201.  
  4202. Example: 
  4203.  
  4204.   balance = balance - check
  4205.   Select
  4206.     when balance > 0 then
  4207.       say 'Congratulations! You still have' balance 'dollars left.'
  4208.     when balance = 0 then do
  4209.       say 'Warning, Balance is now zero!  STOP all spending.'
  4210.       say "You cut it close this month! Hope you don't have any"
  4211.       say "checks left outstanding."
  4212.       end
  4213.     Otherwise
  4214.       say "You have just overdrawn your account."
  4215.       say "Your balance now shows" balance "dollars."
  4216.       say "Oops!  Hope the bank doesn't close your account."
  4217.   end  /* Select */
  4218.  
  4219. Notes: 
  4220.  
  4221.  1. The instruction can be any assignment, command, or keyword instruction, 
  4222.     including any of the more complex constructs such as DO, IF, or the SELECT 
  4223.     instruction itself. 
  4224.  
  4225.  2. A null clause is not an instruction, so putting an extra semicolon after a 
  4226.     WHEN clause is not equivalent to putting a dummy instruction. The NOP 
  4227.     instruction is provided for this purpose. 
  4228.  
  4229.  3. The symbol THEN cannot be used within expression, because the keyword THEN 
  4230.     is treated differently, in that it need not start a clause.  This allows 
  4231.     the expression on the WHEN clause to be terminated by the THEN without a ; 
  4232.     (delimiter) being required. 
  4233.  
  4234.  
  4235. ΓòÉΓòÉΓòÉ 10.22. SIGNAL ΓòÉΓòÉΓòÉ
  4236.  
  4237.  
  4238.  ΓöÇΓöÇSIGNALΓöÇΓöÇΓöÇΓö¼ΓöÇ labelname ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇ;ΓöÇ
  4239.               Γö£ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ expression ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4240.               Γöé Γöö VALUE Γöÿ                            Γöé
  4241.               Γö£ΓöÇΓöÇ OFF ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ ERROR ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4242.               Γöé           Γö£ΓöÇ FAILURE ΓöÇΓöÇΓöÇΓöñ            Γöé
  4243.               Γöé           Γö£ΓöÇ HALT ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  4244.               Γöé           Γö£ΓöÇ NOVALUE ΓöÇΓöÇΓöÇΓöñ            Γöé
  4245.               Γöé           Γö£ΓöÇ SYNTAX ΓöÇΓöÇΓöÇΓöÇΓöñ            Γöé
  4246.               Γöé           ΓööΓöÇ NOTREADY ΓöÇΓöÇΓöÿ            Γöé
  4247.               Γöé                                      Γöé
  4248.               ΓööΓöÇ ON ΓöÇΓö¼ΓöÇ ERROR ΓöÇΓöÇΓöÇΓö¼Γö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  4249.                      Γö£ΓöÇ FAILURE ΓöÇΓöñΓöö NAME ΓöÇ trapname Γöÿ
  4250.                      Γö£ΓöÇ HALT ΓöÇΓöÇΓöÇΓöÇΓöñ
  4251.                      Γö£ΓöÇ NOVALUE ΓöÇΓöñ
  4252.                      Γö£ΓöÇ SYNTAX ΓöÇΓöÇΓöñ
  4253.                      ΓööΓöÇ NOTREADY Γöÿ
  4254.  
  4255. SIGNAL is used to cause an abnormal change in the flow of control, or, if ON or 
  4256. OFF is specified, controls the trapping of certain conditions. 
  4257.  
  4258. To control trapping, you specify OFF or ON and the condition you want to trap. 
  4259. OFF turns off the specified condition trap.  ON turns on the specified 
  4260. condition trap. 
  4261.  
  4262. Note:   For information on condition traps, see the OS/2 Procedures Language 
  4263.         2/REXX Reference. 
  4264.  
  4265. To change the flow of control, a label name is derived from labelname or taken 
  4266. from the result of evaluating the expression after VALUE. The labelname you 
  4267. specify must be a symbol, treated literally, or a literal string that is taken 
  4268. as a constant. The subkeyword VALUE can be omitted if expression does not begin 
  4269. with a symbol or literal string (for example, if it starts with a special 
  4270. character, such as an operator or parenthesis).  All active pending DO, IF, 
  4271. SELECT, and INTERPRET instructions in the current routine are then terminated; 
  4272. that is, they cannot be reactivated. Control then passes to the first label in 
  4273. the program that matches the required string, as though the search had started 
  4274. from the top of the program. 
  4275.  
  4276. Example: 
  4277.  
  4278. Signal fred;  /* Jump to label "FRED" below */
  4279.   ....
  4280.   ....
  4281. Fred: say 'Hi!'
  4282.  
  4283. Because the search effectively starts at the top of the program, if duplicates 
  4284. are present, control always passes to the first occurrence of the label in the 
  4285. program 
  4286.  
  4287. When control reaches the specified label, the line number of the SIGNAL 
  4288. instruction is assigned to the special variable SIGL. This can aid debugging 
  4289. because SIGNAL can determine the source of a jump to a label. 
  4290.  
  4291. Using SIGNAL with the INTERPRET Instruction 
  4292.  
  4293. If, as the result of an INTERPRET instruction, a SIGNAL instruction is issued 
  4294. or a trapped event occurs, the remainder of the strings being interpreted are 
  4295. not searched for the given label. In effect, labels within interpreted strings 
  4296. are ignored. 
  4297.  
  4298.  
  4299. ΓòÉΓòÉΓòÉ 10.23. TRACE ΓòÉΓòÉΓòÉ
  4300.  
  4301.  
  4302. ΓöÇ TRACE ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ;ΓöÇ
  4303.            Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ    ΓööΓöÇ number ΓöÇΓöÿ        Γöé
  4304.            Γöé            Γöé                        Γöé
  4305.            ΓööΓöÇΓö┤ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö┤ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4306.                ΓööΓöÇΓöÇΓöÇ?ΓöÇΓöÇΓöÇΓöÿ   Γö£ΓöÇΓöÇ All ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4307.                            Γö£ΓöÇΓöÇ Commands ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4308.                            Γö£ΓöÇΓöÇ Error ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4309.                            Γö£ΓöÇΓöÇ Failure ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4310.                            Γö£ΓöÇΓöÇ Intermediates ΓöÇΓöÇΓöÇΓöñ
  4311.                            Γö£ΓöÇΓöÇ Labels ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4312.                            Γö£ΓöÇΓöÇ Normal ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4313.                            Γö£ΓöÇΓöÇ Off ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4314.                            ΓööΓöÇΓöÇ Results ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  4315.  
  4316. Or, alternatively: 
  4317.  
  4318.  
  4319. ΓöÇΓöÇTRACEΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ;ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4320.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇstringΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4321.             Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇsymbolΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4322.             ΓööΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇexpressionΓöÇΓöÇΓöÇΓöÿ
  4323.                ΓööΓöÇVALUEΓöÇΓöÿ
  4324.  
  4325. TRACE is used for debugging.  It controls the tracing action taken (that is, 
  4326. how much is displayed to the user) during execution of a REXX program.  The 
  4327. syntax of TRACE is more concise than other REXX instructions.  The economy of 
  4328. key strokes for this instruction is especially convenient since TRACE is 
  4329. usually entered manually during interactive debugging. 
  4330.  
  4331. The number is a whole number. 
  4332.  
  4333. The string or expression evaluates to: 
  4334.  
  4335. o A number option 
  4336. o One of the valid prefix, alphabetic character (word) options, or both, shown 
  4337.   in this panel 
  4338. o Null. 
  4339.  
  4340. The symbol is taken as a constant and is: 
  4341.  
  4342. o A number option 
  4343. o One of the valid prefix, alphabetic character (word) options, or both, shown 
  4344.   in this panel. 
  4345.  
  4346. The tracing action is determined from the option specified following TRACE or 
  4347. from the result of evaluating expression. If expression is used, you can omit 
  4348. the subkeyword VALUE as long as expression starts with a special character or 
  4349. operator (so it is not mistaken for a symbol or string). 
  4350.  
  4351. Alphabetic Character (Word) Options 
  4352.  
  4353. Although it is acceptable to enter the word in full, only the uppercase letter 
  4354. is significant; all other letters are ignored. That is why these are referred 
  4355. to as alphabetic character options. 
  4356.  
  4357. TRACE actions correspond to the alphabetic character options as follows: 
  4358.  
  4359. All                   All clauses are traced (that is, displayed) before 
  4360.                       execution. 
  4361.  
  4362. Commands              All host commands are traced before execution, and any 
  4363.                       error return code is displayed. 
  4364.  
  4365. Error                 Any host command resulting in an error return code is 
  4366.                       traced after execution. 
  4367.  
  4368. Failure               Any host command resulting in a failure is traced after 
  4369.                       execution. This is the same as the Normal option. 
  4370.  
  4371. Intermediates         All clauses are traced before execution. Intermediate 
  4372.                       results during evaluation of expressions and substituted 
  4373.                       names are also traced. 
  4374.  
  4375. Labels                Labels passed during execution are traced. This is 
  4376.                       especially useful with debug mode, when the language 
  4377.                       processor pauses after each label.  It is also convenient 
  4378.                       for the user to make note of all subroutine calls and 
  4379.                       signals. 
  4380.  
  4381. Normal                Any failing host command is traced after execution. This 
  4382.                       is the default setting. 
  4383.  
  4384.                       For the default CMD processor in the OS/2 operating 
  4385.                       system, an attempt to issue an unknown command raises a 
  4386.                       FAILURE condition. An attempt to issue a command to an 
  4387.                       unknown subcommand environment also raises a FAILURE 
  4388.                       condition; in such a case, the variable RC is set to 2, 
  4389.                       the OS/2 return code for "file not found". 
  4390.  
  4391. Off                   Nothing is traced, and the special prefix actions (see 
  4392.                       below) are reset to OFF. 
  4393.  
  4394. Results               All clauses are traced before execution.  Final results 
  4395.                       (contrast with Intermediates, above) of evaluating an 
  4396.                       expression are traced.  Values assigned during PULL, ARG, 
  4397.                       and PARSE instructions are also displayed.  This setting 
  4398.                       is recommended for general debugging. 
  4399.  
  4400. Prefix Option 
  4401.  
  4402. The prefix ? is valid either alone or with one of the alphabetic character 
  4403. options. You can specify the prefix more than once, if desired.  Each 
  4404. occurrence of a prefix on an instruction reverses the action of the previous 
  4405. prefix. The prefix must immediately precede the option (no intervening blanks). 
  4406.  
  4407. The prefix ? modifies tracing and execution.  ? is used to control interactive 
  4408. debug. During normal execution, a TRACE instruction prefixed with ? causes 
  4409. interactive debug to be switched on. 
  4410.  
  4411. When interactive debug is in effect, you can switch it off by issuing a TRACE 
  4412. instruction with a prefix ?.  Repeated use of the ? prefix, therefore, switchs 
  4413. you alternately in and out of interactive debug. Or, interactive debug can be 
  4414. turned off at any time by issuing TRACE O or TRACE with no options. 
  4415.  
  4416. Numeric Options 
  4417.  
  4418. If interactive debug is active and if the option specified is a positive whole 
  4419. number (or an expression that evaluates to a positive whole number), that 
  4420. number indicates the number of debug pauses to be skipped over. However, if the 
  4421. option is a negative whole number (or an expression that evaluates to a 
  4422. negative whole number), all tracing, including debug pauses, is temporarily 
  4423. inhibited for the specified number of clauses. 
  4424.  
  4425. If interactive debug is not active, numeric options are ignored. 
  4426.  
  4427. Format of TRACE Output 
  4428.  
  4429. Every clause traced will be displayed with automatic formatting (indentation) 
  4430. according to its logical depth of nesting and so on, and the results (if 
  4431. requested) are indented an extra two spaces and are enclosed in double 
  4432. quotation marks so that leading and trailing blanks are apparent. 
  4433.  
  4434. All lines displayed during tracing have a three-character prefix to identify 
  4435. the type of data being traced.  The prefixes and their definitions are the 
  4436. following: 
  4437.  
  4438. *-*       Identifies the source of a single clause, that is, the data actually 
  4439.           in the program. 
  4440.  
  4441. +++       Identifies a trace message.  This can be the nonzero return code from 
  4442.           a command, the prompt message when interactive debug is entered, an 
  4443.           indication of a syntax error when in interactive debug, or the 
  4444.           traceback clauses after a syntax error in the program. 
  4445.  
  4446. >>>       Identifies the result of an expression (for TRACE R) or the value 
  4447.           assigned to a variable during parsing, or the value returned from a 
  4448.           subroutine call. 
  4449.  
  4450. >.>       Identifies the value assigned to a placeholder during parsing. 
  4451.  
  4452. The following prefixes are only used if Intermediates (TRACE I) are being 
  4453. traced: 
  4454.  
  4455. >C>       The data traced is the name of a compound variable, traced after 
  4456.           substitution and before use, provided that the name had the value of 
  4457.           a variable substituted into it. 
  4458.  
  4459. >F>       The data traced is the result of a function call. 
  4460.  
  4461. >L>       The data traced is a literal (string, uninitialized variable, or 
  4462.           constant symbol). 
  4463.  
  4464. >O>       The data traced is the result of an operation on two terms. 
  4465.  
  4466. >P>       The data traced is the result of a prefix operation. 
  4467.  
  4468. >V>       The data traced is the contents of a variable. 
  4469.  
  4470.  
  4471. ΓòÉΓòÉΓòÉ 11. Functions ΓòÉΓòÉΓòÉ
  4472.  
  4473. Syntax 
  4474.  
  4475. You can include function calls to internal and external routines in an 
  4476. expression anywhere that a data term (such as a string) would be valid, using 
  4477. the notation: 
  4478.  
  4479.  ΓöÇΓöÇfunctionΓöÇname(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  4480.  
  4481.                     Γöé ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ Γöé
  4482.                     Γöé               Γöé Γöé
  4483.                     ΓööΓöÇΓö┤Γö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γö┤ΓöÇΓöÿ
  4484.                        ΓööΓöÇexpressionΓöÇΓöÿ
  4485.  
  4486. function-name is a literal string or a single symbol, that is taken to be a 
  4487. constant. 
  4488.  
  4489. There can be up to a maximum of 20 expressions, separated by commas, between 
  4490. the parentheses. These expressions are called the arguments to the function. 
  4491. Each argument expression may include further function calls. 
  4492.  
  4493. The ( must be adjacent to the name of the function, with no blank in between, 
  4494. or the construct is not recognized as a function call. (A blank operator is 
  4495. assumed at this point instead.) 
  4496.  
  4497. The arguments are evaluated in turn from left to right and they are all then 
  4498. passed to the function. This then executes some operation (usually dependent on 
  4499. the argument strings passed, though arguments are not mandatory) and eventually 
  4500. returns a single character string. This string is then included in the original 
  4501. expression as though the entire function reference had been replaced by the 
  4502. name of a variable that contained that data. 
  4503.  
  4504. For example, the function SUBSTR is built-in to the language processor and 
  4505. could be used as: 
  4506.  
  4507. N1='abcdefghijk'
  4508. Z1='Part of N1 is: 'Substr(N1,2,7)
  4509. /* would set Z1 to 'Part of N1 is: bcdefgh' */
  4510.  
  4511. A function call without any arguments must always include the parentheses to be 
  4512. recognized as a function call. 
  4513.  
  4514. date()  /* returns the date in the default format dd mon yyyy */
  4515.  
  4516. Calls to Functions and Subroutines 
  4517.  
  4518. The mechanism for calling functions and subroutines is the same. The only 
  4519. difference is that functions must return data, whereas subroutines need not. 
  4520. The following types of routines can be called as functions: 
  4521.  
  4522. Internal  If the routine name exists as a label in the program, the current 
  4523.           processing status is saved, so that it will later be possible to 
  4524.           return to the point of invocation to resume processing. Control is 
  4525.           then passed to the first label in the program that matches the name. 
  4526.           As with a routine invoked by the CALL instruction, various other 
  4527.           pieces of status information (TRACE and NUMERIC settings and so on) 
  4528.           are also saved. See the CALL instruction for details of this. If an 
  4529.           internal routine is to be called as a function, you must specify an 
  4530.           expression in any RETURN instruction to return from the function. 
  4531.           This is not necessary if the function is called only as a subroutine. 
  4532.  
  4533.           Example: 
  4534.  
  4535.                     /* Recursive internal function execution... */
  4536.                     arg x
  4537.                     say x'! =' factorial(x)
  4538.                     exit
  4539.  
  4540.                     factorial: procedure   /* calculate factorial by..  */
  4541.                       arg n                /*  .. recursive invocation. */
  4542.                       if n=0 then return 1
  4543.                       return  factorial(n-1) * n
  4544.  
  4545.           FACTORIAL is unusual in that it invokes itself (this is known as 
  4546.           recursive invocation).  The PROCEDURE instruction ensures that a new 
  4547.           variable n is created for each invocation). 
  4548.  
  4549. Built-in  These functions are always available and are defined later in this 
  4550.           section. 
  4551.  
  4552. External  You can write or make use of functions that are external to a program 
  4553.           and to the language processor. An external function can be written in 
  4554.           any language, including REXX, that supports the system-dependent 
  4555.           interfaces used by the language processor to invoke it. Again, when 
  4556.           called as a function, it must return data to the caller. 
  4557.  
  4558. Notes: 
  4559.  
  4560.  1. Calling an external REXX program as a function is similar to calling an 
  4561.     internal routine.  The external routine is, however, an implicit PROCEDURE 
  4562.     in that all the caller variables are always hidden and the status of 
  4563.     internal values (NUMERIC settings and so on) start with their defaults 
  4564.     (rather than inheriting those of the caller). 
  4565.  
  4566.  2. Other REXX programs can be called as functions. You can use either EXIT or 
  4567.     RETURN to leave the invoked REXX program; in either case, you must specify 
  4568.     an expression. 
  4569.  
  4570. Search Order 
  4571.  
  4572. The search order for functions is the same as in the preceding list. That is, 
  4573. internal labels take first precedence, then built-in functions, and finally 
  4574. external functions. 
  4575.  
  4576. Internal labels are not used if the function name is given as a string (that 
  4577. is, is specified in quotation marks); in this case the function must be 
  4578. built-in or external. This lets you usurp the name of, for example, a built-in 
  4579. function to extend its capabilities, but still be able to invoke the built-in 
  4580. function when needed. 
  4581.  
  4582. Example: 
  4583.  
  4584. /* Modified DATE to return sorted date by default */
  4585. date: procedure
  4586.       arg in
  4587.       if in='' then in='Sorted'
  4588.       return 'DATE'(in)
  4589.  
  4590. Built-in functions have names in uppercase letters.  The name in the literal 
  4591. string must be in uppercase for the search to succeed, as in the example.  The 
  4592. same is usually true of external functions. 
  4593.  
  4594. External functions and subroutines have a system-defined search order. 
  4595.  
  4596. REXX searches for external functions in the following order: 
  4597.  
  4598.  1. Functions that have been loaded into the macrospace for pre-order execution 
  4599.  2. Functions that are part of a function package. 
  4600.  3. REXX functions in the current directory, with the current extension 
  4601.  4. REXX functions along environment PATH, with the current extension 
  4602.  5. REXX functions in the current directory, with the default extension 
  4603.  6. REXX functions along environment PATH, with the default extension 
  4604.  7. Functions that have been loaded into the macrospace for post-order 
  4605.     execution. 
  4606.  
  4607. Errors during Execution 
  4608.  
  4609. If an external or built-in function detects an error of any kind, the language 
  4610. processor is informed, and a syntax error results.  Processing of the clause 
  4611. that included the function call is therefore terminated. Similarly, if an 
  4612. external function fails to return data correctly, this is detected by the 
  4613. language processor and reported as an error. 
  4614.  
  4615. If a syntax error occurs during the processing of an internal function, it can 
  4616. be trapped (using SIGNAL ON SYNTAX) and recovery may then be possible. If the 
  4617. error is not trapped, the program is terminated. 
  4618.  
  4619. Return Values 
  4620.  
  4621. A function normally returns a value that is substituted for the function call 
  4622. when the expression is evaluated. 
  4623.  
  4624. How the value returned by a function (or any REXX routine) is handled depends 
  4625. on whether it is called by a function call or called as a subroutine with the 
  4626. CALL instruction. 
  4627.  
  4628. A routine called as a subroutine: If the routine returns a value, that value is 
  4629. stored in the special variable named RESULT. Otherwise, the RESULT variable is 
  4630. dropped, and its value is the string "RESULT". 
  4631.  
  4632. A routine called as a function: If the function returns a value, that value is 
  4633. substituted into the expression at the position where the function was called. 
  4634. Otherwise, REXX stops with an error message. 
  4635.  
  4636. Examples: 
  4637.  
  4638.  
  4639. /* Different ways to call a REXX procedure */
  4640. call Beep 500, 100         /* Example 1: a subroutine call */
  4641. bc = Beep(500, 100)        /* Example 2: a function call   */
  4642. Beep(500, 100)             /* Example 3: result passed as  */
  4643.                            /*            a command         */
  4644.  
  4645. o In Example 1, the built-in function BEEP is called as a REXX subroutine. The 
  4646.   return value from BEEP is placed in the REXX special variable RESULT. 
  4647.  
  4648. o Example 2 shows BEEP called as a REXX function. The return value from the 
  4649.   function is substituted for the function call. The clause itself is an 
  4650.   assignment instruction; the return value from the BEEP function is placed in 
  4651.   the variable bc. 
  4652.  
  4653. o In Example 3, the BEEP function is processed and its return value is 
  4654.   substituted in the expression for the function call, just as in Example 2. In 
  4655.   this case, however, the clause as a whole evaluates to a single expression; 
  4656.   therefore the evaluated expression is passed to the current default 
  4657.   environment as a command. 
  4658.  
  4659.   Note:   Many other languages (such as C) throw away the return value of a 
  4660.           function if it is not assigned to a variable. In REXX, however, a 
  4661.           value returned as in Example 3 is passed on to the current 
  4662.           environment or subcommand handler. If that environment is CMD (the 
  4663.           default), then this action will result in the operating system 
  4664.           performing a disk search for what seems to be a command. 
  4665.  
  4666.  
  4667. Built-in Functions 
  4668.  
  4669. REXX provides a rich set of built-in functions. These include character 
  4670. manipulation, conversion, and information functions. 
  4671.  
  4672. Here are some general notes on the built-in functions: 
  4673.  
  4674. o The parentheses in a function are always needed, even if no arguments are 
  4675.   required. The first parenthesis must follow the name of the function with no 
  4676.   space in between. 
  4677.  
  4678. o The built-in functions work internally with NUMERIC DIGITS 9 and NUMERIC FUZZ 
  4679.   0 and are unaffected by changes to the NUMERIC settings, except where stated. 
  4680.  
  4681. o You can supply a null string where a string is referenced. 
  4682.  
  4683. o If an argument specifies a length, it must be a nonnegative whole number. If 
  4684.   it specifies a start character or word in a string, it must be a positive 
  4685.   whole number, unless otherwise stated. 
  4686.  
  4687. o Where the last argument is optional, you can always include a comma to 
  4688.   indicate that you have omitted it; for example, DATATYPE(1,), like 
  4689.   DATATYPE(1), would return NUM. 
  4690.  
  4691. o If you specify a pad character, it must be exactly one character long. 
  4692.  
  4693. o If a function has a suboption you can select by specifying the first 
  4694.   character of a string, that character can be in uppercase or lowercase 
  4695.   letters. 
  4696.  
  4697. o Conversion between characters and hexadecimal involves the machine 
  4698.   representation of character strings, and hence returns appropriately 
  4699.   different results for ASCII and EBCDIC machines. 
  4700.  
  4701. o A number of the functions described in this chapter support the 
  4702.   double-byte-character-set (DBCS).  A complete list and description of these 
  4703.   functions is given in the OS/2 Procedures Language 2/REXX Reference. 
  4704.  
  4705.  
  4706. ΓòÉΓòÉΓòÉ 11.1. ABBREV ΓòÉΓòÉΓòÉ
  4707.  
  4708.  ΓöÇΓöÇABBREV(information,info ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4709.                               ΓööΓöÇ,lengthΓöÇΓöÇΓöÿ
  4710.  
  4711. ABBREV returns 1 if info is equal to the leading characters of information and 
  4712. the length of info is not less than length. ABBREV returns 0 if neither of 
  4713. these conditions is met. 
  4714.  
  4715. If specified, length must be a nonnegative whole number. The default for length 
  4716. is the number of characters in info. 
  4717.  
  4718. Here are some examples: 
  4719.  
  4720. ABBREV('Print','Pri')      ->    1
  4721. ABBREV('PRINT','Pri')      ->    0
  4722. ABBREV('PRINT','PRI',4)    ->    0
  4723. ABBREV('PRINT','PRY')      ->    0
  4724. ABBREV('PRINT','')         ->    1
  4725. ABBREV('PRINT','',1)       ->    0
  4726.  
  4727. Note:   A null string will always match if a length of 0 (or the default) is 
  4728.         used. This allows a default keyword to be selected automatically if 
  4729.         desired. For example: 
  4730.  
  4731.                 say 'Enter option:';   pull option .
  4732.                 select  /* keyword1 is to be the default */
  4733.                   when abbrev('keyword1',option) then ...
  4734.                   when abbrev('keyword2',option) then ...
  4735.                   ...
  4736.                   otherwise nop;
  4737.                 end;
  4738.  
  4739.  
  4740. ΓòÉΓòÉΓòÉ 11.2. ABS (Absolute Value) ΓòÉΓòÉΓòÉ
  4741.  
  4742.  ΓöÇΓöÇABS(number)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4743.  
  4744. ABS returns the absolute value of number. The result has no sign and is 
  4745. formatted according to the current NUMERIC settings. 
  4746.  
  4747. Here are some examples: 
  4748.  
  4749. ABS('12.3')       ->    12.3
  4750. ABS(' -0.307')    ->    0.307
  4751.  
  4752.  
  4753. ΓòÉΓòÉΓòÉ 11.3. ADDRESS ΓòÉΓòÉΓòÉ
  4754.  
  4755.  ΓöÇΓöÇADDRESS()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4756.  
  4757. ADDRESS returns the name of the environment to which host commands are 
  4758. currently being submitted.  Trailing blanks are removed from the result. 
  4759.  
  4760. Here are some examples: 
  4761.  
  4762. ADDRESS( )    ->    'CMD'        /* OS/2 environment */
  4763. ADDRESS( )    ->    'EDIT'      /* possible editor */
  4764.  
  4765.  
  4766. ΓòÉΓòÉΓòÉ 11.4. API Functions ΓòÉΓòÉΓòÉ
  4767.  
  4768. The following built-in REXX functions can be used in a REXX program to 
  4769. register, drop, or query external function packages and to create and 
  4770. manipulate external data queues. 
  4771.  
  4772. RXFUNCADD 
  4773.  
  4774.  ΓöÇRXFUNCADD(name,module,procedure)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4775.  
  4776. RXFUNCADD registers the function name, making it available to REXX procedures. 
  4777. A zero return value signifies successful registration. 
  4778.  
  4779. RXFUNCDROP 
  4780.  
  4781.  ΓöÇRXFUNCDROP(name)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4782.  
  4783. RXFUNCDROP removes (deregisters) the function name from the list of available 
  4784. functions. A zero return value signifies successful removal. 
  4785.  
  4786. RXFUNCQUERY 
  4787.  
  4788.  ΓöÇRXFUNCQUERY(name)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4789.  
  4790. RXFUNCQUERY queries the list of available functions for a registration of the 
  4791. name function. The function returns a value of 0 if the function is registered, 
  4792. and a value of 1 if it is not. 
  4793.  
  4794. RXQUEUE 
  4795.  
  4796.  ΓöÇΓöÇRXQUEUE(ΓöÇΓö¼ΓöÇΓöÇ"Get"ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  4797.               Γö£ΓöÇΓöÇ"Set"ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇnewqueuenameΓöÇΓöñ
  4798.               Γö£ΓöÇΓöÇ"Delete"ΓöÇΓöÇΓöÇqueuenameΓöÇΓöÇΓöÇΓöÇΓöñ
  4799.               ΓööΓöÇΓöÇ"Create"ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  4800.                           ΓööΓöÇ,queuenameΓöÇΓöÇΓöÇΓöÿ
  4801.  
  4802. RXQUEUE is used in a REXX program to create and delete external data queues and 
  4803. to set and query their names. 
  4804.  
  4805.  
  4806. ΓòÉΓòÉΓòÉ 11.5. ARG ΓòÉΓòÉΓòÉ
  4807.  
  4808.  ΓöÇΓöÇARG(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4809.           ΓööΓöÇnΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÿ
  4810.                ΓööΓöÇ,optionΓöÇΓöÇΓöÇΓöÿ
  4811.  
  4812. ARG returns an argument string, or information about the argument strings to a 
  4813. program or internal routine. 
  4814.  
  4815. If you do not specify a parameter, the number of arguments passed to the 
  4816. program or internal routine is returned. 
  4817.  
  4818. If only n is specified, the n th argument string is returned. If the argument 
  4819. string does not exist, the null string is returned. n must be a positive whole 
  4820. number. 
  4821.  
  4822. If you specify option, ARG tests for the existence of the n th argument string. 
  4823. Valid options (of which only the capitalized letter is significant and all 
  4824. others are ignored) are: 
  4825.  
  4826. Exists      Returns 1 if the n th argument exists; that is, if it was 
  4827.             explicitly specified when the routine was called. Returns 0 
  4828.             otherwise. 
  4829.  
  4830. Omitted     Returns 1 if the nth argument was omitted; that is, if it was not 
  4831.             explicitly specified when the routine was called. Returns 0 
  4832.             otherwise. 
  4833.  
  4834. Here are some examples: 
  4835.  
  4836. /*  following "Call name;" (no arguments) */
  4837. ARG( )        ->    0
  4838. ARG(1)        ->    ''
  4839. ARG(2)        ->    ''
  4840. ARG(1,'e')    ->    0
  4841. ARG(1,'O')    ->    1
  4842.  
  4843. /*  following "Call name 'a',,'b';" */
  4844. ARG( )        ->    3
  4845. ARG(1)        ->    'a'
  4846. ARG(2)        ->    ''
  4847. ARG(3)        ->    'b'
  4848. ARG(n)        ->    ''    /* for n>=4 */
  4849. ARG(1,'e')    ->    1
  4850. ARG(2,'E')    ->    0
  4851. ARG(2,'O')    ->    1
  4852. ARG(3,'o')    ->    0
  4853. ARG(4,'o')    ->    1
  4854.  
  4855. Notes: 
  4856.  
  4857.  1. You can retrieve and directly parse the argument strings to a program or 
  4858.     internal routine using the ARG or PARSE ARG instructions. 
  4859.  2. Programs called as commands can have only 0 or 1 argument strings. The 
  4860.     program has no argument strings if it is called with the name only and has 
  4861.     1 argument string if anything else (including blanks) is included with the 
  4862.     command. 
  4863.  3. Programs called by the REXXSTART entry point can have multiple argument 
  4864.     strings. 
  4865.  
  4866.  
  4867. ΓòÉΓòÉΓòÉ 11.6. BEEP ΓòÉΓòÉΓòÉ
  4868.  
  4869.  ΓöÇΓöÇBEEP(frequency,duration)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4870.  
  4871. BEEP sounds the speaker at frequency (Hertz) for duration milliseconds. The 
  4872. frequency can be any number in the range 37 to 32767 Hertz. The duration can be 
  4873. any number in the range 1 to 60000 milliseconds. 
  4874.  
  4875. This routine is most useful when called as a subroutine. A null string is 
  4876. returned if the routine is successful. 
  4877.  
  4878. Here is an example: 
  4879.  
  4880. /* C scale */
  4881. note.1 = 262    /* middle C */
  4882. note.2 = 294    /*    D     */
  4883. note.3 = 330    /*    E     */
  4884. note.4 = 349    /*    F     */
  4885. note.5 = 392    /*    G     */
  4886. note.6 = 440    /*    A     */
  4887. note.7 = 494    /*    B     */
  4888. note.8 = 524    /*    C     */
  4889.  
  4890. do i=1 to 8
  4891.   call beep note.i,250    /* hold each note for */
  4892.                           /* one-quarter second */
  4893. end
  4894.  
  4895.  
  4896. ΓòÉΓòÉΓòÉ 11.7. BITAND ΓòÉΓòÉΓòÉ
  4897.  
  4898.  ΓöÇΓöÇBITAND(string1ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4899.                     ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4900.                         ΓööΓöÇstring2Γöÿ ΓööΓöÇ,padΓöÇΓöÿ
  4901.  
  4902. BITAND returns a string composed of the two input strings logically compared, 
  4903. bit by bit, using the AND operator. The length of the result is the length of 
  4904. the longer of the two strings. If no pad character is provided, the AND 
  4905. operation terminates when the shorter of the two strings is exhausted, and the 
  4906. unprocessed portion of the longer string is appended to the partial result.  If 
  4907. pad is provided, it is used to extend the shorter of the two strings on the 
  4908. right, before carrying out the logical operation. The default for string2 is 
  4909. the zero length (null) string. 
  4910.  
  4911. Here are some examples: 
  4912.  
  4913. BITAND('73'x,'27'x)            ->    '23'x
  4914. BITAND('13'x,'5555'x)          ->    '1155'x
  4915. BITAND('13'x,'5555'x,'74'x)    ->    '1154'x
  4916. BITAND('pQrS',,'DF'x)          ->    'PQRS' /* ASCII only  */
  4917.  
  4918.  
  4919. ΓòÉΓòÉΓòÉ 11.8. BITOR ΓòÉΓòÉΓòÉ
  4920.  
  4921.  ΓöÇΓöÇBITOR(string1ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4922.                    ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4923.                        ΓööΓöÇstring2Γöÿ ΓööΓöÇ,padΓöÇΓöÿ
  4924.  
  4925. BITOR returns a string composed of the two input strings logically compared, 
  4926. bit by bit, using the OR operator. The length of the result is the length of 
  4927. the longer of the two strings. If no pad character is provided, the OR 
  4928. operation terminates when the shorter of the two strings is exhausted, and the 
  4929. unprocessed portion of the longer string is appended to the partial result.  If 
  4930. pad is provided, it is used to extend the shorter of the two strings on the 
  4931. right, before carrying out the logical operation. The default for string2 is 
  4932. the zero length (null) string. 
  4933.  
  4934. Here are some examples: 
  4935.  
  4936. BITOR('15'x,'24'x)            ->    '35'x
  4937. BITOR('15'x,'2456'x)          ->    '3556'x
  4938. BITOR('15'x,'2456'x,'F0'x)    ->    '35F6'x
  4939. BITOR('1111'x,,'4D'x)         ->    '5D5D'x
  4940. BITOR('pQrS',,'20'x)          ->    'pqrs' /* ASCII only  */
  4941.  
  4942.  
  4943. ΓòÉΓòÉΓòÉ 11.9. BITXOR ΓòÉΓòÉΓòÉ
  4944.  
  4945.  ΓöÇΓöÇBITXOR(string1ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4946.                     ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  4947.                         ΓööΓöÇstring2Γöÿ ΓööΓöÇ,padΓöÇΓöÿ
  4948.  
  4949. BITXOR returns a string composed of the two input strings logically compared 
  4950. bit by bit using the exclusive OR operator. The length of the result is the 
  4951. length of the longer of the two strings. If no pad character is provided, the 
  4952. XOR operation terminates when the shorter of the two strings is exhausted, and 
  4953. the unprocessed portion of the longer string is appended to the partial result. 
  4954. If pad is provided, it is used to extend the shorter of the two strings on the 
  4955. right, before carrying out the logical operation. The default for string2 is 
  4956. the zero length (null) string. 
  4957.  
  4958. Here are some examples: 
  4959.  
  4960. BITXOR('12'x,'22'x)               ->  '30'x
  4961. BITXOR('1211'x,'22'x)             ->  '3011'x
  4962. BITXOR('C711'x,'222222'x,' ')     ->  'E53302'x  /* ASCII  */
  4963. BITXOR('1111'x,'444444'x)         ->  '555544'x
  4964. BITXOR('1111'x,'444444'x,'40'x)   ->  '555504'x
  4965. BITXOR('1111'x,,'4D'x)            ->  '5C5C'x
  4966.  
  4967.  
  4968. ΓòÉΓòÉΓòÉ 11.10. B2X (Binary to Hexadecimal) ΓòÉΓòÉΓòÉ
  4969.  
  4970.  ΓöÇΓöÇΓöÇB2X(binary_string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  4971.  
  4972. Converts binary_string, a string of binary (0 or 1) digits, to an equivalent 
  4973. string of hexadecimal characters. You can optionally include blanks in 
  4974. binary_string (at four-digit boundaries only, not leading or trailing) to aid 
  4975. readability; they are ignored. 
  4976.  
  4977. The returned string uses uppercase letters for the values A-F, and does not 
  4978. include blanks. 
  4979.  
  4980. binary_string can be of any length; if it is the null string, then a null 
  4981. string is returned. If the number of binary digits in the string is not a 
  4982. multiple of four, then up to three 0 digits will be added on the left before 
  4983. the conversion to make a total that is a multiple of four. 
  4984.  
  4985. Here are some examples: 
  4986.  
  4987. B2X('11000011')    ==   'C3'
  4988. B2X('10111')       ==   '17'
  4989. B2X('101')         ==   '5'
  4990. B2X('1 1111 0000') ==   '1F0'
  4991.  
  4992. B2X( ) can be combined with the functions X2D( ) and X2C( ) to convert a binary 
  4993. number into other forms. For example: 
  4994.  
  4995. X2D(B2X('10111'))  ==   '23'   /* decimal 23 */
  4996.  
  4997.  
  4998. ΓòÉΓòÉΓòÉ 11.11. CENTER/CENTRE ΓòÉΓòÉΓòÉ
  4999.  
  5000.      ΓöîΓöÇCENTER(ΓöÇΓöÉ
  5001.  ΓöÇΓöÇΓöñ         Γö£ΓöÇΓöÇstring,length ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5002.      ΓööΓöÇCENTRE(ΓöÇΓöÿ                 ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  5003.  
  5004. CENTER or CENTRE returns a string of length length with string centered in it, 
  5005. with pad characters added as necessary to make up length. The default pad 
  5006. character is blank. If the string is longer than length, it will be truncated 
  5007. at both ends to fit. If an odd number of characters are truncated or added, the 
  5008. right-hand end loses or gains one more character than the left-hand end. 
  5009.  
  5010. Here are some examples: 
  5011.  
  5012. CENTER(abc,7)               ->    '  ABC  '
  5013. CENTER(abc,8,'-')           ->    '--ABC---'
  5014. CENTRE('The blue sky',8)    ->    'e blue s'
  5015. CENTRE('The blue sky',7)    ->    'e blue '
  5016.  
  5017. Note:   This function can be called either CENTRE or CENTER, which avoids 
  5018. errors due to the difference between the British and American spellings. 
  5019.  
  5020.  
  5021. ΓòÉΓòÉΓòÉ 11.12. CHARIN ΓòÉΓòÉΓòÉ
  5022.  
  5023.  ΓöÇΓöÇCHARIN(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5024.              ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  5025.                            ΓööΓöÇstartΓöÇΓöÿ  ΓööΓöÇ,lengthΓöÇΓöÿ
  5026.  
  5027. CHARIN returns a string of up to length characters read from the character 
  5028. input stream name. The form of the name is implementation dependent. If name is 
  5029. omitted, characters are read from the default input stream, STDIN:. The default 
  5030. length is 1. 
  5031.  
  5032. For persistent streams, a read position is maintained for each stream. In the 
  5033. OS/2 operating system, this is the same as the write position. Any read from 
  5034. the stream will by default start at the current read position.  When the read 
  5035. is completed, the read position is increased by the number of characters read. 
  5036. A start value can be given to specify an explicit read position.  This read 
  5037. position must be positive and within the bounds of the stream, and must not be 
  5038. specified for a transient stream ( a port or other serial device).  A value of 
  5039. 1 for start refers to the first character in the stream. 
  5040.  
  5041. If you specify a length of 0, then the read position will be set to the value 
  5042. of start, but no characters are read and the null string is returned. 
  5043.  
  5044. In a transient stream, if there are fewer then length characters available, 
  5045. then execution of the program will normally stop until sufficient characters do 
  5046. become available.  If, however, it is impossible for those characters to become 
  5047. available due to an error or other problem, the NOTREADY condition is raised 
  5048. and CHARIN will return with fewer than the requested number of characters. 
  5049.  
  5050. Here are some examples: 
  5051.  
  5052. CHARIN(myfile,1,3)   ->   'MFC'   /* the first 3     */
  5053.                                    /* characters      */
  5054. CHARIN(myfile,1,0)   ->   ''      /* now at start    */
  5055. CHARIN(myfile)       ->   'M'     /* after last call */
  5056. CHARIN(myfile,,2)    ->   'FC'    /* after last call */
  5057.  
  5058. /* Reading from the default input (here, the keyboard) */
  5059. /* User types 'abcd efg' */
  5060. CHARIN( )            ->   'a'      /* default is  */
  5061.                                              /* 1 character */
  5062. CHARIN(,,5)          ->   'bcd e'
  5063.  
  5064. Note 1: 
  5065.  
  5066. CHARIN returns all characters that appear in the stream including control 
  5067. characters such as line feed, carriage return, and end of file. 
  5068.  
  5069. Note 2: 
  5070.  
  5071. When CHARIN is used to read from the keyboard, program execution stops until 
  5072. you press the Enter key. 
  5073.  
  5074.  
  5075. ΓòÉΓòÉΓòÉ 11.13. CHAROUT ΓòÉΓòÉΓòÉ
  5076.  
  5077.  ΓöÇΓöÇCHAROUT(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5078.               ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  5079.                             ΓööΓöÇstringΓöÇΓöÿ  ΓööΓöÇ,startΓöÇΓöÿ
  5080.  
  5081. CHAROUT returns the count of characters remaining after attempting to write 
  5082. string to the character output stream name. The form of the name is 
  5083. implementation dependent. If name is omitted, characters in string will be 
  5084. written to the default output stream, STDOUT: (normally the display) in the 
  5085. OS/2 operating system. string can be the null string, in which case no 
  5086. characters are written to the stream and 0 is always returned. 
  5087.  
  5088. For persistent streams, a write position is maintained for each stream. In the 
  5089. OS/2 implementation, this is the same as the read position. Any write to the 
  5090. stream starts at the current write position by default.  When the write is 
  5091. completed the write position is increased by the number of characters written. 
  5092. The initial write position is the end of the stream, so that calls to CHAROUT 
  5093. normally append to the end of the stream. 
  5094.  
  5095. A start value can be given to specify an explicit write position for a 
  5096. persistent stream. This write position must be a positive whole number within 
  5097. the bounds of the stream (though it can specify the character position 
  5098. immediately after the end of the stream). A value of 1 for start refers to the 
  5099. first character in the stream. 
  5100.  
  5101. Note:   In some environments, overwriting a stream with CHAROUT or LINEOUT can 
  5102.         erase (destroy) all existing data in the stream. However, this is not 
  5103.         the case in the OS/2 environment. 
  5104.  
  5105. The string can be omitted for persistent streams. In this case, the write 
  5106. position is set to the value of start that was given, no characters are written 
  5107. to the stream, and 0 is returned. If neither start nor string are given, the 
  5108. write position is set to the end of the stream. This use of CHAROUT can also 
  5109. have the side effect of closing or fixing the file in environments which 
  5110. support this concept.  Again, 0 is returned. If you do not specify start or 
  5111. string, the stream is closed. Again, 0 is returned. 
  5112.  
  5113. Processing of the program normally stops until the output operation is 
  5114. effectively complete. If, however, it is impossible for all the characters to 
  5115. be written, the NOTREADY condition is raised and CHAROUT returns with the 
  5116. number of characters that could not be written (the residual count). 
  5117.  
  5118. Here are some examples: 
  5119.  
  5120. CHAROUT(myfile,'Hi')     ->   0   /* normally */
  5121. CHAROUT(myfile,'Hi',5)   ->   0   /* normally */
  5122. CHAROUT(myfile,,6)       ->   0   /* now at char 6 */
  5123. CHAROUT(myfile)          ->   0   /* at end of stream */
  5124. CHAROUT(,'Hi')           ->   0   /* normally */
  5125. CHAROUT(,'Hello')        ->   2   /* maybe */
  5126.  
  5127. Note:   This routine is often best called as a subroutine. The residual count 
  5128.         is then available in the variable RESULT. 
  5129.  
  5130. For example: 
  5131.  
  5132. Call CHAROUT myfile,'Hello'
  5133. Call CHAROUT myfile,'Hi',6
  5134. Call CHAROUT myfile
  5135.  
  5136.  
  5137. ΓòÉΓòÉΓòÉ 11.14. CHARS ΓòÉΓòÉΓòÉ
  5138.  
  5139.  ΓöÇΓöÇCHARS(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5140.             ΓööΓöÇnameΓöÇΓöÿ
  5141.  
  5142. CHARS returns the total number of characters remaining in the character input 
  5143. stream name. The count includes any line separator characters, if these are 
  5144. defined for the stream, and in the case of persistent streams, is the count of 
  5145. characters from the current read position to the end of the stream. If name is 
  5146. omitted, OS/2 will use STDIN: as the default. 
  5147.  
  5148. The total number of characters remaining cannot be determined for some streams 
  5149. (for example, STDIN:).  For these streams, the CHARS function returns 1 to 
  5150. indicate that data is present, or 0 if no data is present. For OS/2 devices, 
  5151. CHARS always returns 1. 
  5152.  
  5153. Here are some examples: 
  5154.  
  5155. CHARS(myfile)     ->   42   /* perhaps */
  5156. CHARS(nonfile)    ->   0    /* perhaps */
  5157. CHARS()           ->   1    /* perhaps */
  5158.  
  5159.  
  5160. ΓòÉΓòÉΓòÉ 11.15. COMPARE ΓòÉΓòÉΓòÉ
  5161.  
  5162.  ΓöÇΓöÇΓöÇCOMPARE(string1,string2 ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5163.                                ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  5164.  
  5165. COMPARE returns 0 if the strings, string1 and string2, are identical. 
  5166. Otherwise, COMPARE returns the position of the first character that does not 
  5167. match. The shorter string is padded on the right with pad if necessary.  The 
  5168. default pad character is a blank. 
  5169.  
  5170. Here are some examples: 
  5171.  
  5172. COMPARE('abc','abc')         ->    0
  5173. COMPARE('abc','ak')          ->    2
  5174. COMPARE('ab ','ab')          ->    0
  5175. COMPARE('ab ','ab',' ')      ->    0
  5176. COMPARE('ab ','ab','x')      ->    3
  5177. COMPARE('ab-- ','ab','-')    ->    5
  5178.  
  5179.  
  5180. ΓòÉΓòÉΓòÉ 11.16. CONDITION ΓòÉΓòÉΓòÉ
  5181.  
  5182.  ΓöÇΓöÇΓöÇCONDITION(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5183.                  ΓööΓöÇoptionΓöÇΓöÿ
  5184.  
  5185. CONDITION returns the condition information associated with the current trapped 
  5186. condition.  You can request four pieces of information: 
  5187.  
  5188. o The name of the current trapped condition 
  5189. o Any descriptive string associated with that condition 
  5190. o The instruction executed as a result of the condition trap (CALL or SIGNAL) 
  5191. o The status of the trapped condition. 
  5192.  
  5193. The following options (of which only the capitalized letter is needed, all 
  5194. others are ignored) can be used to obtain the following information: 
  5195.  
  5196. Condition name    Returns the name of the current trapped condition. 
  5197.  
  5198. Description       Returns any descriptive string associated with the current 
  5199.                   trapped condition. If no description is available, a null 
  5200.                   string is returned. 
  5201.  
  5202. Instruction       Returns the keyword for the instruction executed when the 
  5203.                   current condition was trapped.  The keywords are CALL or 
  5204.                   SIGNAL. This is the default if you omit option. 
  5205.  
  5206. Status            Returns the status of the current trapped condition.  This 
  5207.                   can change during execution, and is either: 
  5208.  
  5209.    ON - the condition is enabled 
  5210.  
  5211.    OFF - the condition is disabled 
  5212.  
  5213.    DELAY - any new occurrence of the condition is delayed. 
  5214.  
  5215. If no condition has been trapped (that is, there is no current trapped 
  5216. condition) then the CONDITION function returns a null string in all four cases. 
  5217.  
  5218. Here are some examples: 
  5219.  
  5220. CONDITION()            ->    'CALL'        /* perhaps */
  5221. CONDITION('C')         ->    'FAILURE'
  5222. CONDITION('I')         ->    'CALL'
  5223. CONDITION('D')         ->    'FailureTest'
  5224. CONDITION('S')         ->    'OFF'        /* perhaps */
  5225.  
  5226. Note:   The condition information returned by the CONDITION function is saved 
  5227.         and restored across subroutine calls (including those caused by a CALL 
  5228.         ON condition trap). Therefore, once a subroutine invoked due to a CALL 
  5229.         ON trap has returned, the current trapped condition reverts to the 
  5230.         current condition before the CALL took place. CONDITION returns the 
  5231.         values it returned before the condition was trapped. 
  5232.  
  5233.  
  5234. ΓòÉΓòÉΓòÉ 11.17. COPIES ΓòÉΓòÉΓòÉ
  5235.  
  5236.  ΓöÇΓöÇΓöÇCOPIES(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5237.  
  5238. COPIES returns n concatenated copies of string. n must be a nonnegative whole 
  5239. number. 
  5240.  
  5241. Here are some examples: 
  5242.  
  5243. COPIES('abc',3)    ->    'abcabcabc'
  5244. COPIES('abc',0)    ->    ''
  5245.  
  5246.  
  5247. ΓòÉΓòÉΓòÉ 11.18. C2D (Character to Decimal) ΓòÉΓòÉΓòÉ
  5248.  
  5249.  ΓöÇΓöÇΓöÇC2D(string ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5250.                   ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  5251.  
  5252. C2D returns the decimal value of the binary representation of string. If the 
  5253. result cannot be expressed as a whole number, an error results. That is, the 
  5254. result must not have more digits than the current setting of NUMERIC DIGITS. 
  5255.  
  5256. If string is the null string, then 0 is returned. 
  5257.  
  5258. If n is not specified, string is processed as an unsigned binary number. 
  5259.  
  5260. Here are some examples: 
  5261.  
  5262. C2D('09'X)      ->        9
  5263. C2D('81'X)      ->      129
  5264. C2D('FF81'X)    ->    65409
  5265. C2D('a')        ->       97     /* ASCII */
  5266.  
  5267. If n is specified, the given string is padded on the left with 00x characters 
  5268. (note, not sign-extended), or truncated on the left to n characters. The 
  5269. resulting string of n hexadecimal digits is taken to be a signed binary number: 
  5270. positive if the leftmost bit is OFF, and negative, in two's complement 
  5271. notation, if the leftmost bit is ON. If n is 0, then 0 is always returned. 
  5272.  
  5273. Here are some examples: 
  5274.  
  5275. C2D('81'X,1)      ->     -127
  5276. C2D('81'X,2)      ->      129
  5277. C2D('FF81'X,2)    ->     -127
  5278. C2D('FF81'X,1)    ->     -127
  5279. C2D('FF7F'X,1)    ->      127
  5280. C2D('F081'X,2)    ->    -3967
  5281. C2D('F081'X,1)    ->     -127
  5282. C2D('0031'X,0)    ->        0
  5283.  
  5284. Implementation maximum: The input string cannot have more than 250 characters 
  5285. that will be significant in forming the final result.  Leading sign characters 
  5286. (00x and ffx) do not count toward this total. 
  5287.  
  5288.  
  5289. ΓòÉΓòÉΓòÉ 11.19. C2X (Character to Hexadecimal) ΓòÉΓòÉΓòÉ
  5290.  
  5291.  ΓöÇΓöÇΓöÇC2X(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5292.  
  5293. C2X converts a character string to its hexadecimal representation. The data to 
  5294. be converted can be of any length. The returned string contains twice as many 
  5295. bytes as the input string because it is in literal string notation. 
  5296.  
  5297. Here are some examples: 
  5298.  
  5299. C2X('0123'X)    ->    '0123'
  5300. C2X('ZD8')      ->    '5A4438'     /*   ASCII    */
  5301.  
  5302.  
  5303. ΓòÉΓòÉΓòÉ 11.20. DATATYPE ΓòÉΓòÉΓòÉ
  5304.  
  5305.  ΓöÇΓöÇΓöÇDATATYPE(string ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5306.                        ΓööΓöÇΓöÇ,typeΓöÇΓöÇΓöÿ
  5307.  
  5308. DATATYPE determines whether 'data' is numeric or alphabetic and returns a 
  5309. result of NUM or CHAR. If only string is specified, the returned result is NUM 
  5310. if string is a valid REXX number (any format); otherwise CHAR will be the 
  5311. returned result. 
  5312.  
  5313. If type is specified, the returned result is 1 if string matches the type; 
  5314. otherwise, a 0 is returned. If string is null, 0 is returned (except when type 
  5315. is X, which returns 1). The following is a list of valid types. Only the 
  5316. capitalized letter is significant (all others are ignored). 
  5317.  
  5318. Alphanumeric      Returns 1 if string contains only characters from the ranges 
  5319.                   a-z, A-Z, and 0-9. 
  5320.  
  5321. Bits              Returns 1 if string contains only the characters 0 and/or 1. 
  5322.  
  5323. C                 Returns 1 if string is a mixed SBCS/DBCS string. 
  5324.  
  5325. Dbcs              Returns 1 if string is a pure DBCS string. 
  5326.  
  5327. Lowercase         Returns 1 if string contains only characters from the range 
  5328.                   a-z. 
  5329.  
  5330. Mixed case        Returns 1 if string contains only characters from the ranges 
  5331.                   a-z and A-Z. 
  5332.  
  5333. Number            Returns 1 if string is a valid REXX number. 
  5334.  
  5335. Symbol            Returns 1 if string contains only characters that are valid 
  5336.                   in REXX symbols. Note that both uppercase and lowercase 
  5337.                   letters are permitted. 
  5338.  
  5339. Uppercase         Returns 1 if string contains only characters from the range 
  5340.                   A-Z. 
  5341.  
  5342. Whole number      Returns 1 if string is a REXX whole number under the current 
  5343.                   setting of NUMERIC DIGITS. 
  5344.  
  5345. heXadecimal       Returns 1 if string contains only characters from the ranges 
  5346.                   a-f, A-F, 0-9, and blank (so long as blanks only appear 
  5347.                   between pairs of hexadecimal characters). Also returns 1 if 
  5348.                   string is a null string. 
  5349.  
  5350. DATATYPE(' 12 ')         ->   'NUM'
  5351. DATATYPE('')             ->   'CHAR'
  5352. DATATYPE('123*')         ->   'CHAR'
  5353. DATATYPE('12.3','N')     ->    1
  5354. DATATYPE('12.3','W')     ->    0
  5355. DATATYPE('Fred','M')     ->    1
  5356. DATATYPE('','M')         ->    0
  5357. DATATYPE('Fred','L')     ->    0
  5358. DATATYPE('?20K','S')     ->    1
  5359. DATATYPE('BCd3','X')     ->    1
  5360. DATATYPE('BC d3','X')    ->    1
  5361.  
  5362.  
  5363. ΓòÉΓòÉΓòÉ 11.21. DATE ΓòÉΓòÉΓòÉ
  5364.  
  5365.  ΓöÇΓöÇΓöÇDATE(ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5366.              ΓööΓöÇoptionΓöÇΓöÇΓöÿ
  5367.  
  5368. DATE returns, by default, the local date in the format: dd mon yyyy (for 
  5369. example, 27 Aug 1988), with no leading zero or blank on the day. For mon, the 
  5370. first three characters of the English name of the month will be used. 
  5371.  
  5372. The following options (of which only the capitalized letter is needed, all 
  5373. others are ignored) can be used to obtain alternative formats: 
  5374.  
  5375. Basedate        Returns the number of complete days (that is, not including the 
  5376.                 current day) since and including the base date, January 1, 
  5377.                 0001, in the format: dddddd (no leading zeros). The expression 
  5378.                 DATE(B)//7  returns a number in the range 0-6, where 0 is 
  5379.                 Monday and 6 is Sunday. 
  5380.  
  5381.                 Note:   The origin of January 1, 0001 is based on the Gregorian 
  5382.                         calendar. Though this calendar did not exist prior to 
  5383.                         1582, Basedate is calculated as if it did: 365 days per 
  5384.                         year, an extra day every four years except century 
  5385.                         years, and leap centuries if the century is divisible 
  5386.                         by 400. It does not take into account any errors in the 
  5387.                         calendar system that created the Gregorian calendar 
  5388.                         originally. 
  5389.  
  5390. Days            Returns the number of days, including the current day, so far 
  5391.                 in this year in the format: ddd (no leading zeros) 
  5392.  
  5393. European        Returns date in the format: dd/mm/yy. 
  5394.  
  5395. Language        Returns date in an implementation and language dependent or 
  5396.                 local date format. In the OS/2 operating system, the Language 
  5397.                 format is dd Month yyyy. If no local format is available, the 
  5398.                 default format is returned. 
  5399.  
  5400.                 Note:   This format is intended to be used as a whole; REXX 
  5401.                         programs should not make any assumptions about the form 
  5402.                         or content of the returned string. 
  5403.  
  5404. Month           Returns full English name of the current month, for example, 
  5405.                 August 
  5406.  
  5407. Normal          Returns date in the default format: dd mon yyyy 
  5408.  
  5409. Ordered         Returns date in the format: yy/mm/dd (suitable for sorting, and 
  5410.                 so on.) 
  5411.  
  5412. Sorted          Returns date in the format: yyyymmdd (suitable for sorting, and 
  5413.                 so on.) 
  5414.  
  5415. Usa             Returns date in the format: mm/dd/yy 
  5416.  
  5417. Weekday         Returns the English name for the day of the week, in mixed 
  5418.                 case. For example, Tuesday. 
  5419.  
  5420. Here are some examples: 
  5421.  
  5422. DATE( )        ->    '27 Aug 1988'  /*  perhaps  */
  5423. DATE('B')      ->    725975
  5424. DATE('D')      ->    240
  5425. DATE('E')      ->    '27/08/88'
  5426. DATE('L')      ->    '27 August 1988'
  5427. DATE('M')      ->    'August'
  5428. DATE('N')      ->    '27 Aug 1988'
  5429. DATE('O')      ->    '88/08/27'
  5430. DATE('S')      ->    '19880827'
  5431. DATE('U')      ->    '08/27/88'
  5432. DATE('W')      ->    'Saturday'
  5433.  
  5434. Note:   The first call to DATE or TIME in one expression causes a time stamp to 
  5435.         be made which is then used for all calls to these functions in that 
  5436.         expression. Therefore, if multiple calls to any of the DATE and/or TIME 
  5437.         functions are made in a single expression, they are guaranteed to be 
  5438.         consistent with each other. 
  5439.  
  5440.  
  5441. ΓòÉΓòÉΓòÉ 11.22. DELSTR (Delete String) ΓòÉΓòÉΓòÉ
  5442.  
  5443.  ΓöÇΓöÇΓöÇDELSTR(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5444.                        ΓööΓöÇΓöÇ,lengthΓöÇΓöÇΓöÿ
  5445.  
  5446. DELSTR deletes the substring of string that begins at the nth character, and is 
  5447. of length length. If length is not specified, the rest of string is deleted. If 
  5448. n is greater than the length of string, the string is returned unchanged. n 
  5449. must be a positive whole number. 
  5450.  
  5451. Here are some examples: 
  5452.  
  5453. DELSTR('abcd',3)       ->    'ab'
  5454. DELSTR('abcde',3,2)    ->    'abe'
  5455. DELSTR('abcde',6)      ->    'abcde'
  5456.  
  5457.  
  5458. ΓòÉΓòÉΓòÉ 11.23. DELWORD ΓòÉΓòÉΓòÉ
  5459.  
  5460.  ΓöÇΓöÇΓöÇDELWORD(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5461.                         ΓööΓöÇΓöÇ,lengthΓöÇΓöÇΓöÿ
  5462.  
  5463. DELWORD deletes the substring of string that starts at the n th word. The 
  5464. length option refers to the number of blank-delimited words. If length is 
  5465. omitted, it defaults to be the remaining words in string. n must be a positive 
  5466. whole number. If n is greater than the number of words in string, string is 
  5467. returned unchanged. The string deleted includes any blanks following the final 
  5468. word involved. 
  5469.  
  5470. Here are some examples: 
  5471.  
  5472. DELWORD('Now is the  time',2,2)  ->  'Now time'
  5473. DELWORD('Now is the time ',3)    ->  'Now is '
  5474. DELWORD('Now is the  time',5)    ->  'Now is the  time'
  5475.  
  5476.  
  5477. ΓòÉΓòÉΓòÉ 11.24. DIGITS ΓòÉΓòÉΓòÉ
  5478.  
  5479.  ΓöÇΓöÇDIGITS()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5480.  
  5481. DIGITS returns the current setting of NUMERIC DIGITS. 
  5482.  
  5483. Here is an example: 
  5484.  
  5485. DIGITS()    ->    9      /* by default */
  5486.  
  5487.  
  5488. ΓòÉΓòÉΓòÉ 11.25. D2C (Decimal to Character) ΓòÉΓòÉΓòÉ
  5489.  
  5490.  ΓöÇΓöÇΓöÇD2C(wholenumber ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5491.                        ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  5492.  
  5493. D2C returns a character string that is the ASCII representation of the decimal 
  5494. number. If you specify n, it is the length of the final result in characters 
  5495. and leading blanks are added to the output character. 
  5496.  
  5497. If n is not specified, wholenumber must be a nonnegative number and the 
  5498. resulting length is as needed; therefore, the returned result has no leading 
  5499. 00x characters. 
  5500.  
  5501. Here are some examples: 
  5502.  
  5503. D2C(65)      ->   'A'      /* '41'x is an ASCII 'A'    */
  5504. D2C(65,1)    ->   'A'
  5505. D2C(65,2)    ->   ' A'
  5506. D2C(65,5)    ->   '    A'
  5507. D2C(109)     ->   'm'      /* '6D'x  is an ASCII 'm'   */
  5508. D2C(-109,1)  ->   '╨ú'      /* '147'x is an ASCII '╨ú'   */
  5509. D2C(76,2)    ->   ' L'     /* '76'x  is an ASCII ' L'  */
  5510. D2C(-180,2)  ->   ' L'
  5511.  
  5512.  
  5513. ΓòÉΓòÉΓòÉ 11.26. D2X (Decimal to Hexadecimal) ΓòÉΓòÉΓòÉ
  5514.  
  5515.  ΓöÇΓöÇΓöÇD2X(wholenumber ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5516.                        ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  5517.  
  5518. D2X returns a string of hexadecimal characters that is the hexadecimal 
  5519. representation of the decimal number. 
  5520.  
  5521. If n is not specified, wholenumber must be a nonnegative number and the 
  5522. returned result has no leading 0 characters. 
  5523.  
  5524. If n is specified, it is the length of the final result in characters; that is, 
  5525. after conversion the input string is sign-extended to the required length. If 
  5526. the number is too big to fit into n characters, it is shortened on the left. 
  5527.  
  5528. Here are some examples: 
  5529.  
  5530. D2X(9)         ->    '9'
  5531. D2X(129)       ->    '81'
  5532. D2X(129,1)     ->    '1'
  5533. D2X(129,2)     ->    '81'
  5534. D2X(129,4)     ->    '0081'
  5535. D2X(257,2)     ->    '01'
  5536. D2X(-127,2)    ->    '81'
  5537. D2X(-127,4)    ->    'FF81'
  5538. D2X(12,0)      ->    ''
  5539.  
  5540. Implementation maximum: The output string cannot have more than 250 significant 
  5541. hexadecimal characters, though a longer result is possible if it has additional 
  5542. leading sign characters (0 and F). 
  5543.  
  5544.  
  5545. ΓòÉΓòÉΓòÉ 11.27. DIRECTORY ΓòÉΓòÉΓòÉ
  5546.  
  5547.  ΓöÇΓöÇDIRECTORY(ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5548.                  ΓööΓöÇnewdirectoryΓöÇΓöÿ
  5549.  
  5550. DIRECTORY returns the current directory, first changing it to newdirectory if 
  5551. an argument is supplied and the named directory exists. 
  5552.  
  5553. The return string includes a drive letter prefix as the first two characters of 
  5554. the directory name. Specifying a drive letter prefix as part of newdirectory 
  5555. causes the specified drive to become the current drive. If a drive letter is 
  5556. not specified, then the current drive remains unchanged. 
  5557.  
  5558. For example, the following program fragment saves the current directory and 
  5559. switches to a new directory; it performs an operation there, and then returns 
  5560. to the former directory. 
  5561.  
  5562. /* get current directory */
  5563. curdir = directory()
  5564. /* go play a game */
  5565. newdir = directory("d:/usr/games")
  5566. if newdir = "d:/usr/games" then
  5567.    do
  5568.    fortune  /* tell a fortune */
  5569. /* return to former directory */
  5570.    call directory curdir
  5571.    end
  5572. else
  5573.    say 'Can't find /usr/games'
  5574.  
  5575.  
  5576. ΓòÉΓòÉΓòÉ 11.28. ERRORTEXT ΓòÉΓòÉΓòÉ
  5577.  
  5578.  ΓöÇΓöÇΓöÇERRORTEXT(n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5579.  
  5580. ERRORTEXT returns the error message associated with error number n. n must be 
  5581. in the range 0-99, and any other value is an error. If n is in the allowed 
  5582. range, but is not a defined REXX error number, the null string is returned. 
  5583.  
  5584. Here are some examples: 
  5585.  
  5586. ERRORTEXT(16)    ->    'Label not found'
  5587. ERRORTEXT(60)    ->    ''
  5588.  
  5589.  
  5590. ΓòÉΓòÉΓòÉ 11.29. ENDLOCAL ΓòÉΓòÉΓòÉ
  5591.  
  5592.  ΓöÇENDLOCAL()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5593.  
  5594. ENDLOCAL restores the drive directory and environment variables in effect 
  5595. before the last SETLOCAL function was executed. If ENDLOCAL is not included in 
  5596. a procedure, then the initial environment saved by SETLOCAL will be restored 
  5597. upon exiting the procedure. 
  5598.  
  5599. ENDLOCAL returns a value of 1 if the initial environment is successfully 
  5600. restored, and a value of 0 if no SETLOCAL has been issued or if the actions is 
  5601. otherwise unsuccessful. 
  5602.  
  5603. Note:   Unlike their counterparts in the OS/2 Batch language (the Setlocal and 
  5604.         Endlocal statements), the REXX SETLOCAL and ENDLOCAL functions can be 
  5605.         nested. 
  5606.  
  5607. Here is an example: 
  5608.  
  5609. n = SETLOCAL()          /* saves the current environment    */
  5610.  
  5611.          /* The program can now change environment   */
  5612.          /* variables (with the VALUE function) and  */
  5613.          /* then work in that changed envirnonment.  */
  5614.  
  5615. n = ENDLOCAL()          /* restores the initial environment */
  5616.  
  5617. For additional examples, view the SETLOCAL function. 
  5618.  
  5619.  
  5620. ΓòÉΓòÉΓòÉ 11.30. FILESPEC ΓòÉΓòÉΓòÉ
  5621.  
  5622.  ΓöÇΓöÇFILESPEC(option,filespec)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5623.  
  5624. FILESPEC returns a selected element of filespec, a given file specification, 
  5625. identified by one of the following strings for option: 
  5626.  
  5627. Drive       The drive letter of the given filespec. 
  5628.  
  5629. Path        The directory path of the given filespec. 
  5630.  
  5631. Name        The filename of the given filespec. 
  5632.  
  5633. If the requested string is not found, then FILESPEC returns a null string (" 
  5634. "). 
  5635.  
  5636. Note:   Only the the initial letter of option is needed. 
  5637.  
  5638. Here are some examples: 
  5639.  
  5640. thisfile = "C:\OS2\UTIL\EXAMPLE.EXE"
  5641. say FILESPEC("drive",thisfile)     /* says "C:"          */
  5642. say FILESPEC("path",thisfile)      /* says "\OS2\UTIL\"  */
  5643. say FILESPEC("name",thisfile)      /* says "EXAMPLE.EXE" */
  5644.  
  5645. part = "name"
  5646. say FILESPEC(part,thisfile)        /* says "EXAMPLE.EXE" */
  5647.  
  5648.  
  5649. ΓòÉΓòÉΓòÉ 11.31. FORM ΓòÉΓòÉΓòÉ
  5650.  
  5651.  ΓöÇΓöÇFORM()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5652. FORM returns the current setting of NUMERIC FORM. 
  5653.  
  5654. Here is an example: 
  5655.  
  5656. FORM()    ->    'SCIENTIFIC'  /* by default */
  5657.  
  5658.  
  5659. ΓòÉΓòÉΓòÉ 11.32. FORMAT ΓòÉΓòÉΓòÉ
  5660.  
  5661.  ΓöÇΓöÇFORMAT(numberΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ
  5662.                    ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5663.                        ΓööbeforeΓöÿ Γöö,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5664.                                    ΓööafterΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5665.                                                ΓööexppΓöÿ Γöö,exptΓöÿ
  5666.  
  5667. FORMAT returns number rounded and formatted. 
  5668.  
  5669. The number is first rounded and formatted to standard REXX rules, just as 
  5670. though the operation number+0 had been carried out. If only number is given, 
  5671. the result is precisely that of this operation. If any other options are 
  5672. specified, the number is formatted as follows. 
  5673.  
  5674. The before and after options describe how many characters are to be used for 
  5675. the integer part and decimal part of the result respectively. If either or both 
  5676. of these are omitted, the number of characters used for that part is as needed. 
  5677.  
  5678. If before is not large enough to contain the integer part of the number, an 
  5679. error results. If before is too large, the number is padded on the left with 
  5680. blanks. If after is not the same size as the decimal part of the number, the 
  5681. number will be rounded (or extended with zeros) to fit. Specifying 0 will cause 
  5682. the number to be rounded to an integer. 
  5683.  
  5684. Here are some examples: 
  5685.  
  5686. FORMAT('3',4)            ->    '   3'
  5687. FORMAT('1.73',4,0)       ->    '   2'
  5688. FORMAT('1.73',4,3)       ->    '   1.730'
  5689. FORMAT('-.76',4,1)       ->    '  -0.8'
  5690. FORMAT('3.03',4)         ->    '   3.03'
  5691. FORMAT(' - 12.73',,4)    ->    '-12.7300'
  5692. FORMAT(' - 12.73')       ->    '-12.73'
  5693. FORMAT('0.000')          ->    '0'
  5694.  
  5695. The first three arguments are as previously described.  In addition, expp and 
  5696. expt control the exponent part of the result: expp sets the number of places to 
  5697. be used for the exponent part; the default is to use as many as needed. The 
  5698. expt sets the trigger point for use of exponential notation. If the number of 
  5699. places needed for the integer part exceeds expt, exponential notation is used. 
  5700. Likewise, exponential notation is used if the number of places needed for the 
  5701. decimal part exceeds twice expt. The default is the current setting of NUMERIC 
  5702. DIGITS. If 0 is specified for expt, exponential notation is always used unless 
  5703. the exponent would be 0. The expp must be less than 10, but there is no limit 
  5704. on the other arguments. If 0 is specified for the expp field, no exponent is 
  5705. supplied, and the number is expressed in simple form with added zeros as 
  5706. necessary (this overrides a 0 value of expt). Otherwise, if expp is not large 
  5707. enough to contain the exponent, an error results. If the exponent is 0, in this 
  5708. case (a non-zero expp), then expp+2 blanks are supplied for the exponent part 
  5709. of the result. 
  5710.  
  5711. Here are some examples: 
  5712.  
  5713. FORMAT('12345.73',,,2,2)    ->    '1.234573E+04'
  5714. FORMAT('12345.73',,3,,0)    ->    '1.235E+4'
  5715. FORMAT('1.234573',,3,,0)    ->    '1.235'
  5716. FORMAT('12345.73',,,3,6)    ->    '12345.73'
  5717. FORMAT('1234567e5',,3,0)    ->    '123456700000.000'
  5718.  
  5719.  
  5720. ΓòÉΓòÉΓòÉ 11.33. FUZZ ΓòÉΓòÉΓòÉ
  5721.  
  5722.  ΓöÇΓöÇFUZZ()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5723.  
  5724. FUZZ returns the current setting of NUMERIC FUZZ. 
  5725.  
  5726. Here is an example: 
  5727.  
  5728. FUZZ()    ->    0     /* by default */
  5729.  
  5730.  
  5731. ΓòÉΓòÉΓòÉ 11.34. INSERT ΓòÉΓòÉΓòÉ
  5732.  
  5733.  ΓöÇΓöÇINSERT(new,targetΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5734.                        ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5735.                            ΓööΓöÇnΓöÇΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  5736.                                      ΓöölengthΓöÿ Γöö,padΓöÿ
  5737.  
  5738. INSERT inserts the string new, padded to length length, into the string target 
  5739. after the n th character. If specified, n must be a nonnegative whole number. 
  5740. If n is greater than the length of the target string, padding is added there 
  5741. also. The default pad character is a blank. The default value for n is 0, which 
  5742. means insert before the beginning of the string. 
  5743.  
  5744. Here are some examples: 
  5745.  
  5746. INSERT(' ','abcdef',3)         ->    'abc def'
  5747. INSERT('123','abc',5,6)        ->    'abc  123   '
  5748. INSERT('123','abc',5,6,'+')    ->    'abc++123+++'
  5749. INSERT('123','abc')            ->    '123abc'
  5750. INSERT('123','abc',,5,'-')     ->    '123--abc'
  5751.  
  5752.  
  5753. ΓòÉΓòÉΓòÉ 11.35. LASTPOS ΓòÉΓòÉΓòÉ
  5754.  
  5755.  ΓöÇΓöÇLASTPOS(needle,haystackΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5756.                               ΓööΓöÇ,startΓöÇΓöÇΓöÿ
  5757.  
  5758. LASTPOS returns the position of the last occurrence of one string, needle, in 
  5759. another, haystack. If the string needle is not found, 0 is returned. By default 
  5760. the search starts at the last character of haystack (that is, 
  5761. start=LENGTH(string)) and scans backwards. You can override this by specifying 
  5762. start, as the point at which the backward scan starts. start must be a positive 
  5763. whole number, and defaults to LENGTH(string) if larger than that value. 
  5764.  
  5765. Here are some examples: 
  5766.  
  5767. LASTPOS(' ','abc def ghi')      ->    8
  5768. LASTPOS(' ','abcdefghi')        ->    0
  5769. LASTPOS(' ','abc def ghi',7)    ->    4
  5770.  
  5771.  
  5772. ΓòÉΓòÉΓòÉ 11.36. LEFT ΓòÉΓòÉΓòÉ
  5773.  
  5774.  ΓöÇΓöÇLEFT(string,lengthΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5775.                          ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  5776.  
  5777. LEFT returns a string of length length, containing the leftmost length 
  5778. characters of string. The string returned is padded with pad characters (or 
  5779. truncated) on the right as needed. The default pad character is a blank. length 
  5780. must be nonnegative. The LEFT function is exactly equivalent to 
  5781. SUBSTR(string,1,length[,pad]). 
  5782.  
  5783. Here are some examples: 
  5784.  
  5785. LEFT('abc d',8)        ->    'abc d   '
  5786. LEFT('abc d',8,'.')    ->    'abc d...'
  5787. LEFT('abc  def',7)     ->    'abc  de'
  5788.  
  5789.  
  5790. ΓòÉΓòÉΓòÉ 11.37. LENGTH ΓòÉΓòÉΓòÉ
  5791.  
  5792.  ΓöÇΓöÇLENGTH(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5793.  
  5794. LENGTH returns the length of string. 
  5795.  
  5796. Here are some examples: 
  5797.  
  5798. LENGTH('abcdefgh')    ->    8
  5799. LENGTH('abc defg')    ->    8
  5800. LENGTH('')            ->    0
  5801.  
  5802.  
  5803. ΓòÉΓòÉΓòÉ 11.38. LINEIN ΓòÉΓòÉΓòÉ
  5804.  
  5805.  ΓöÇΓöÇLINEIN(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5806.              ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  5807.                            ΓööΓöÇlineΓöÇΓöÿ  ΓööΓöÇ,countΓöÇΓöÿ
  5808.  
  5809. LINEIN returns count (0 or 1) lines read from the character input stream name. 
  5810. The form of the name is implementation dependent. If name is omitted, the line 
  5811. is read from the default input stream, STDIN: in OS/2. The default count is 1. 
  5812.  
  5813. For persistent streams, a read position is maintained for each stream. In the 
  5814. OS/2 operating system, this is the same as the write position. Any read from 
  5815. the stream starts at the current read position by default. A call to LINEIN 
  5816. will return a partial line if the current read position is not at the start of 
  5817. a line. When the read is completed, the read position is moved to the beginning 
  5818. of the next line. The read position may be set to the beginning of the stream 
  5819. by giving line a value of 1- the only valid value for line in OS/2. 
  5820.  
  5821. If a count of 0 is given, then no characters are read and the null string is 
  5822. returned. 
  5823.  
  5824. For transient streams, if a complete line is not available in the stream, then 
  5825. execution of the program will normally stop until the line is complete. If, 
  5826. however, it is impossible for a line to be completed due to an error or other 
  5827. problem, the NOTREADY condition is raised and LINEIN returns whatever 
  5828. characters are available. 
  5829.  
  5830. Here are some examples: 
  5831.  
  5832. LINEIN()                      /* Reads one line from the    */
  5833.                               /* default input stream;      */
  5834.                               /* normally this is an entry  */
  5835.                               /* typed at the keyboard      */
  5836.  
  5837. myfile = 'ANYFILE.TXT'
  5838. LINEIN(myfile)     -> 'Current line' /* Reads one line from  */
  5839.                              /* ANYFILE.TXT, beginning     */
  5840.                              /* at the current read        */
  5841.                              /* position. (If first call,  */
  5842.                              /* file is opened and the     */
  5843.                              /* first line is read.)       */
  5844.  
  5845. LINEIN(myfile,1,1) ->'first line'  /* Opens and reads the first */
  5846.                              /* line of ANYFILE.TXT (if    */
  5847.                              /* the file is already open,  */
  5848.                              /* reads first line); sets    */
  5849.                              /* read position on the       */
  5850.                              /* second line.               */
  5851.  
  5852. LINEIN(myfile,1,0) ->  ''    /* No read; opens ANYFILE.TXT */
  5853.                               /* (if file is already open,  */
  5854.                               /* sets the read position to  */
  5855.                               /* the first line).           */
  5856.  
  5857. LINEIN(myfile,,0)  ->  ''  /* No read; opens ANYFILE.TXT */
  5858.                               /* (no action if the file is  */
  5859.                               /* already open).             */
  5860.  
  5861. LINEIN("QUEUE:") -> 'Queue line' /* Read a line from the queue; */
  5862.                               /* If the queue is empty, the  */
  5863.                               /* program waits until a line  */
  5864.                               /* is put on the queue.        */
  5865.  
  5866. Note:   If the intention is to read complete lines from the default character 
  5867.         stream, as in a simple dialogue with a user, use the PULL or PARSE PULL 
  5868.         instructions instead for simplicity and for improved programmability. 
  5869.         The PARSE LINEIN instruction is also useful in certain cases. 
  5870.  
  5871.  
  5872. ΓòÉΓòÉΓòÉ 11.39. LINEOUT ΓòÉΓòÉΓòÉ
  5873.  
  5874.  ΓöÇΓöÇLINEOUT(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5875.               ΓööΓöÇnameΓöÇΓöÿ  ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  5876.                             ΓööΓöÇstringΓöÇΓöÿ  ΓööΓöÇ,lineΓöÇΓöÿ
  5877.  
  5878. LINEOUT returns the count of lines remaining after attempting to write string 
  5879. to the character output stream name. The count is either 0 (meaning the line 
  5880. was successfully written) or 1 (meaning that an error occurred while writing 
  5881. the line). string can be the null string, in which case only the action 
  5882. associated with completing a line is taken. LINEOUT adds a line-feed and a 
  5883. carriage-return character to the end of string. 
  5884.  
  5885. The form of the name is implementation dependent. If name is omitted, the line 
  5886. is written to the default output stream, STDOUT: (normally the display) in 
  5887. OS/2. 
  5888.  
  5889. For persistent streams, a write position is maintained for each stream. In the 
  5890. OS/2 operating system, this is the same as the read position. Any write to the 
  5891. stream starts at the current write position by default. Characters written by a 
  5892. call to LINEOUT can be added to a partial line. LINEOUT conceptually terminates 
  5893. a line at the end of each call. When the write is completed, the write position 
  5894. is set to the beginning of the line following the one just written. The initial 
  5895. write position is the end of the stream, so that calls to LINEOUT normally 
  5896. append lines to the end of the stream. 
  5897.  
  5898. You can set the write position to the first character of a persistent stream by 
  5899. giving a value of 1 (the only valid value) for line. 
  5900.  
  5901. Note:   In some environments, overwriting a stream using CHAROUT or LINEOUT can 
  5902.         erase (destroy) all existing data in the stream. This is not, however, 
  5903.         the case in the OS/2 environment. 
  5904.  
  5905. You can omit the string for persistent streams. If you specify line, the write 
  5906. position is set to the beginning of the stream, but nothing is written to the 
  5907. stream, and 0 is returned.  If you specify neither line nor string, the write 
  5908. position is set to the end of the stream. This use of LINEOUT has the effect of 
  5909. closing the stream in environments (such as the OS/2 environment) that support 
  5910. this concept. 
  5911.  
  5912. Execution of the program normally stops until the output operation is 
  5913. effectively completed. If, however, it is impossible for a line to be written, 
  5914. the NOTREADY condition is raised and LINEOUT returns with a result of 1 (that 
  5915. is, the residual count of lines written). 
  5916.  
  5917. Here are some examples: 
  5918.  
  5919. LINEOUT(,'Display this')    /* Writes string to the default   */
  5920.                             /* output stream (normally, the   */
  5921.                             /* display); returns 0 if         */
  5922.                             /* successful                     */
  5923.  
  5924. myfile = 'ANYFILE.TXT'
  5925. LINEOUT(myfile,'A new line')  /* Opens the file ANYFILE.TXT and */
  5926.                               /* appends the string to the end. */
  5927.                               /* If the file is already open,   */
  5928.                               /* the string is written at the   */
  5929.                               /* current write position.        */
  5930.                               /* Returns 0 if successful.       */
  5931.  
  5932. LINEOUT(myfile,'A new start',1)/* Opens the file (if not already */
  5933.                                /* open); overwrites first line   */
  5934.                                /* with a new line.               */
  5935.                                /* Returns 0 if successful.       */
  5936.  
  5937. LINEOUT(myfile,,1)            /* Opens the file (if not already */
  5938.                               /* open). No write; sets write    */
  5939.                               /* position at first character.   */
  5940.  
  5941. LINEOUT(myfile)               /* Closes ANYFILE.TXT             */
  5942.  
  5943. LINEOUT is often most useful when called as a subroutine. The return value is 
  5944. then available in the variable RESULT. For example: 
  5945.  
  5946. Call LINEOUT 'A:rexx.bat','Shell',1
  5947. Call LINEOUT ,'Hello'
  5948.  
  5949. Note:   If the lines are to be written to the default output stream without the 
  5950.         possibility of error, use the SAY instruction instead. 
  5951.  
  5952.  
  5953. ΓòÉΓòÉΓòÉ 11.40. LINES ΓòÉΓòÉΓòÉ
  5954.  
  5955.  ΓöÇΓöÇLINES(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  5956.             ΓööΓöÇnameΓöÇΓöÿ
  5957.  
  5958. LINES returns 1 if any data remains between the current read position and the 
  5959. end of the character input stream name, and returns 0 if no data remains. In 
  5960. effect, LINES reports whether a read action performed by CHARIN or LINEIN will 
  5961. succeed. 
  5962.  
  5963. The form of the name is implementation dependent. If you omit name, then the 
  5964. presence or absence of data in the default input stream (STDIN:) is returned. 
  5965. For OS/2 devices, LINES always returns 1. 
  5966.  
  5967. Here are some examples: 
  5968.  
  5969. LINES(myfile)    ->    0    /* at end of the file   */
  5970.  
  5971. LINES()          ->    1    /* data remains in the  */
  5972.                             /* default input stream */
  5973.                             /* STDIN:         */
  5974.  
  5975. LINES("COM1:")   ->    1     /* An OS/2 device name  */
  5976.                             /* always returns '1'   */
  5977.  
  5978. Note:   The CHARS function returns the number of characters in a persistent 
  5979.         stream or the presence of data in a transient stream. 
  5980.  
  5981.  
  5982. ΓòÉΓòÉΓòÉ 11.41. MAX ΓòÉΓòÉΓòÉ
  5983.  
  5984.  ΓöÇΓöÇMAX(numberΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  5985.                 ΓöéΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé
  5986.                 Γöé         ΓöéΓöé
  5987.                 ΓööΓö┤ΓöÇ,numberΓöÇΓö┤Γöÿ
  5988.  
  5989. MAX returns the largest number from the list specified, formatted according to 
  5990. the current setting of NUMERIC DIGITS. You can specify up to 20 numbers and can 
  5991. nest calls to MAX if more arguments are needed. 
  5992.  
  5993. Here are some examples: 
  5994.  
  5995. MAX(12,6,7,9)                              ->    12
  5996. MAX(17.3,19,17.03)                         ->    19
  5997. MAX(-7,-3,-4.3)                            ->    -3
  5998. MAX(1,2,3,4,5,6,7,8,9,MAX(10,11,12,13))    ->    13
  5999.  
  6000.  
  6001. ΓòÉΓòÉΓòÉ 11.42. MIN ΓòÉΓòÉΓòÉ
  6002.  
  6003.  ΓöÇΓöÇMIN(numberΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6004.                 ΓöéΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉΓöé
  6005.                 Γöé         ΓöéΓöé
  6006.                 ΓööΓö┤ΓöÇ,numberΓöÇΓö┤Γöÿ
  6007.  
  6008. MIN returns the smallest number from the list specified, formatted according to 
  6009. the current setting of NUMERIC DIGITS. Up to 20 numbers can be specified, 
  6010. although calls to MIN can be nested if more arguments are needed. 
  6011.  
  6012. Here are some examples: 
  6013.  
  6014. MIN(12,6,7,9)         ->     6
  6015. MIN(17.3,19,17.03)    ->    17.03
  6016. MIN(-7,-3,-4.3)       ->    -7
  6017.  
  6018.  
  6019. ΓòÉΓòÉΓòÉ 11.43. OVERLAY ΓòÉΓòÉΓòÉ
  6020.  
  6021.  ΓöÇΓöÇOVERLAY(new,target ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ
  6022.                          ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  6023.                              ΓööΓöÇnΓöÇΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  6024.                                        ΓöölengthΓöÿ Γöö,padΓöÿ
  6025.  
  6026. OVERLAY returns the string target, which, starting at the nth character, is 
  6027. overlaid with the string new, padded or truncated to length length. If length 
  6028. is specified, it must be positive or zero. If n is greater than the length of 
  6029. the target string, padding is added before the new string. The default pad 
  6030. character is a blank, and the default value for n is 1. If you specify n, it 
  6031. must be a positive whole number. 
  6032.  
  6033. Here are some examples: 
  6034.  
  6035. OVERLAY(' ','abcdef',3)         ->    'ab def'
  6036. OVERLAY('.','abcdef',3,2)       ->    'ab. ef'
  6037. OVERLAY('qq','abcd')            ->    'qqcd'
  6038. OVERLAY('qq','abcd',4)          ->    'abcqq'
  6039. OVERLAY('123','abc',5,6,'+')    ->    'abc+123+++'
  6040.  
  6041.  
  6042. ΓòÉΓòÉΓòÉ 11.44. POS ΓòÉΓòÉΓòÉ
  6043.  
  6044.  ΓöÇΓöÇPOS(needle,haystackΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6045.                           ΓööΓöÇ,startΓöÇΓöÇΓöÿ
  6046.  
  6047. POS returns the position of one string, needle, in another, haystack. (See also 
  6048. the LASTPOS function.) If the string needle is not found, 0 is returned. By 
  6049. default, the search starts at the first character of haystack (that is, the 
  6050. value of start is 1). You can override this by specifying start (which must be 
  6051. a positive whole number) as the point at which the search starts. 
  6052.  
  6053. Here are some examples: 
  6054.  
  6055. POS('day','Saturday')       ->    6
  6056. POS('x','abc def ghi')      ->    0
  6057. POS(' ','abc def ghi')      ->    4
  6058. POS(' ','abc def ghi',5)    ->    8
  6059.  
  6060.  
  6061. ΓòÉΓòÉΓòÉ 11.45. QUEUED ΓòÉΓòÉΓòÉ
  6062.  
  6063.  ΓöÇΓöÇQUEUED()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6064.  
  6065. QUEUED returns the number of lines remaining in the currently active REXX data 
  6066. queue at the time the function is invoked. 
  6067.  
  6068. Here is an example: 
  6069.  
  6070. QUEUED()    ->    5    /* Perhaps */
  6071.  
  6072.  
  6073. ΓòÉΓòÉΓòÉ 11.46. RANDOM ΓòÉΓòÉΓòÉ
  6074.  
  6075.  ΓöÇΓöÇRANDOM(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  6076.              Γö£ΓöÇmaxΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  6077.              Γö£ΓöÇmin,ΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6078.              ΓööΓöÇ,ΓöÇΓöÇΓöÇΓöÇΓöÿ ΓööΓöÇmaxΓöÇΓöÿ ΓööΓöÇ,seedΓöÇΓöÿ
  6079.  
  6080. RANDOM returns a quasi-random, nonnegative whole number in the range min to max 
  6081. inclusive. If only one argument is specified, the range will be from 0 to that 
  6082. number. Otherwise, the default values for min and max are 0 and 999, 
  6083. respectively. A specific seed (which must be a whole number) for the random 
  6084. number can be specified as the third argument if repeatable results are 
  6085. desired. 
  6086.  
  6087. The magnitude of the range (that is, max minus min) must not exceed 100000. 
  6088.  
  6089. Here are some examples: 
  6090.  
  6091. RANDOM()          ->    305
  6092. RANDOM(5,8)       ->      7
  6093. RANDOM(,,1983)    ->    123  /* reproducible */
  6094. RANDOM(2)         ->      0
  6095.  
  6096. Notes: 
  6097.  
  6098.  1. To obtain a predictable sequence of quasi-random numbers, use RANDOM a 
  6099.     number of times, but specify a seed only the first time. For example, to 
  6100.     simulate 40 throws of a six-sided, unbiased die, use: 
  6101.  
  6102.         sequence = RANDOM(1,6,12345)  /* any number would */
  6103.                                       /* do for a seed    */
  6104.         do 39
  6105.            sequence = sequence RANDOM(1,6)
  6106.            end
  6107.         say sequence
  6108.  
  6109.     The numbers are generated mathematically, using the initial seed, so that 
  6110.     as far as possible they appear to be random. Running the program again will 
  6111.     produce the same sequence; using a different initial seed almost certainly 
  6112.     produces a different sequence. 
  6113.  2. The random number generator is global for an entire program; the current 
  6114.     seed is not saved across internal routine calls. 
  6115.  3. The actual random number generator used may differ from implementation to 
  6116.     implementation. 
  6117.  
  6118.  
  6119. ΓòÉΓòÉΓòÉ 11.47. REVERSE ΓòÉΓòÉΓòÉ
  6120.  
  6121.  ΓöÇΓöÇREVERSE(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6122.  
  6123. REVERSE returns string, swapped end for end. 
  6124.  
  6125. Here are some examples: 
  6126.  
  6127. REVERSE('ABc.')    ->    '.cBA'
  6128. REVERSE('XYZ ')    ->    ' ZYX'
  6129.  
  6130.  
  6131. ΓòÉΓòÉΓòÉ 11.48. RIGHT ΓòÉΓòÉΓòÉ
  6132.  
  6133.  ΓöÇΓöÇRIGHT(string,lengthΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6134.                           ΓööΓöÇ,padΓöÇΓöÇΓöÿ
  6135.  
  6136. RIGHT returns a string of length length containing the rightmost length 
  6137. characters of string. The string returned is padded with pad characters (or 
  6138. truncated) on the left as needed. The default pad character is a blank. length 
  6139. must be nonnegative. 
  6140.  
  6141. Here are some examples: 
  6142.  
  6143. RIGHT('abc  d',8)     ->    '  abc  d'
  6144. RIGHT('abc def',5)    ->    'c def'
  6145. RIGHT('12',5,'0')     ->    '00012'
  6146.  
  6147.  
  6148. ΓòÉΓòÉΓòÉ 11.49. SETLOCAL ΓòÉΓòÉΓòÉ
  6149.  
  6150.   ΓöÇΓöÇSETLOCAL()ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6151.  
  6152. SETLOCAL saves the current working drive and directory, and the current values 
  6153. of the OS/2 environment variables that are local to the current process. 
  6154.  
  6155. For example, SETLOCAL can be used to save the current environment before 
  6156. changing selected settings with the VALUE function. To restore the drive, 
  6157. directory, and environment, use the ENDLOCAL function. 
  6158.  
  6159. SETLOCAL returns a value of 1 if the initial drive, directory, and environment 
  6160. are successfully saved, and a value of 0 if unsuccessful. If SETLOCAL is not 
  6161. followed by an ENDLOCAL function in a procedure, then the initial environment 
  6162. saved by SETLOCAL will be restored upon exiting the procedure. 
  6163.  
  6164. Here is an example: 
  6165.  
  6166. /* current path is 'C:\PROJ\FILES' */
  6167. n = SETLOCAL()        /* saves all environment settings    */
  6168.  
  6169. /* Now use the VALUE function to change the PATH variable. */
  6170. p = VALUE('Path','C:\PROC\PROGRAMS'.'OS2ENVIRONMENT')
  6171.  
  6172. /* Programs in directory C:\PROC\PROGRAMS may now be run   */
  6173.  
  6174. n = ENDLOCAL()  /* restores initial environment (including */
  6175.                 /* the changed PATH variable, which is   */
  6176.                 /* once again 'C:\PROJ\FILES'              */
  6177.  
  6178. Note:   Unlike their counterparts in the OS/2 Batch language (the Setlocal and 
  6179.         Endlocal statements), the REXX SETLOCAL and ENDLOCAL functions can be 
  6180.         nested. 
  6181.  
  6182.  
  6183. ΓòÉΓòÉΓòÉ 11.50. SIGN ΓòÉΓòÉΓòÉ
  6184.  
  6185.  ΓöÇΓöÇSIGN(number)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6186.  
  6187. SIGN returns a number that indicates the sign of number. number is first 
  6188. rounded according to standard REXX rules, just as though the operation number+0 
  6189. had been carried out. If number is less than 0, then -1 is returned; if it is 0 
  6190. then 0 is returned; and if it is greater than 0, 1 is returned. 
  6191.  
  6192. Here are some examples: 
  6193.  
  6194. SIGN('12.3')       ->     1
  6195. SIGN(' -0.307')    ->    -1
  6196. SIGN(0.0)          ->     0
  6197.  
  6198.  
  6199. ΓòÉΓòÉΓòÉ 11.51. SOURCELINE ΓòÉΓòÉΓòÉ
  6200.  
  6201.  ΓöÇΓöÇSOURCELINE(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6202.                  ΓööΓöÇΓöÇnΓöÇΓöÇΓöÿ
  6203.  
  6204. SOURCELINE returns the line number of the final line in the source file if you 
  6205. omit n, or returns the n th line in the source file if you specify n. 
  6206.  
  6207. If specified, n must be a positive whole number, and must not exceed the number 
  6208. of the final line in the source file. 
  6209.  
  6210. Here are some examples: 
  6211.  
  6212. SOURCELINE()    ->   10
  6213. SOURCELINE(1)   ->   '/* This is a 10-line program */'
  6214.  
  6215.  
  6216. ΓòÉΓòÉΓòÉ 11.52. SPACE ΓòÉΓòÉΓòÉ
  6217.  
  6218.  ΓöÇΓöÇSPACE(stringΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6219.                   ΓööΓöÇ,ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6220.                        ΓööΓöÇnΓöÇΓöÿ ΓööΓöÇΓöÇ,padΓöÇΓöÇΓöÿ
  6221.  
  6222. SPACE formats the blank-delimited words in string with n pad characters between 
  6223. each word. The n must be nonnegative. If it is 0, all blanks are removed. 
  6224. Leading and trailing blanks are always removed. The default for n is 1, and the 
  6225. default pad character is a blank. 
  6226.  
  6227. Here are some examples: 
  6228.  
  6229. SPACE('abc  def  ')          ->    'abc def'
  6230. SPACE('  abc def',3)         ->    'abc   def'
  6231. SPACE('abc  def  ',1)        ->    'abc def'
  6232. SPACE('abc  def  ',0)        ->    'abcdef'
  6233. SPACE('abc  def  ',2,'+')    ->    'abc++def'
  6234.  
  6235.  
  6236. ΓòÉΓòÉΓòÉ 11.53. STREAM ΓòÉΓòÉΓòÉ
  6237.  
  6238.  ΓöÇΓöÇΓöÇSTREAM(nameΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  6239.                    ΓööΓöÇΓöÇ,ΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  6240.                           Γö£ΓöÇC,ΓöÇΓöÇstreamcommandΓöÇΓöñ
  6241.                           Γö£ΓöÇDΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
  6242.                           ΓööΓöÇSΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
  6243.  
  6244. STREAM returns a string describing the state of, or the result of an operation 
  6245. upon, the character stream name. This function is used to request information 
  6246. on the state of an input or output stream, or to carry out some specific 
  6247. operation on the stream. 
  6248.  
  6249. The first argument, name, specifies the stream to be accessed. The second 
  6250. argument can be one of the following strings (of which only the first letter is 
  6251. needed) which describes the action to be carried out: 
  6252.  
  6253. Command        an operation (specified by the streamcommand given as the third 
  6254.                argument) to be applied to the selected input or output stream. 
  6255.                The string that is returned depends on the command performed, 
  6256.                and can be the null string. 
  6257.  
  6258. Description    Also returns the current state of the specified stream. It is 
  6259.                identical to the State operation, except that the returned 
  6260.                string is followed by a colon and, if available, additional 
  6261.                information about ERROR or NOTREADY states. 
  6262.  
  6263. State          Returns a string that indicates the current state of the 
  6264.                specified stream. This is the default operation. 
  6265.  
  6266. When used with the State option, STREAM returns one of the following strings: 
  6267.  
  6268. 'ERROR'               The stream has been subject to an erroneous operation 
  6269.                       (possibly during input, output, or through the STREAM 
  6270.                       function. Additional information about the error may be 
  6271.                       available by invoking the STREAM function with a request 
  6272.                       for the implementation-dependent description. 
  6273.  
  6274. 'NOTREADY'            The stream is known to be in a state such that normal 
  6275.                       input or output operations attempted upon it would raise 
  6276.                       the NOTREADY condition. For example, a simple input 
  6277.                       stream may have a defined length; an attempt to read that 
  6278.                       stream (with the CHARIN or LINEIN built-in functions, 
  6279.                       perhaps) beyond that limit may make the stream 
  6280.                       unavailable until the stream has been closed, for 
  6281.                       example, with LINEIN(name), and then reopened. 
  6282.  
  6283. 'READY'               The stream is known to be in a state such that normal 
  6284.                       input or output operations can be attempted.  This is the 
  6285.                       usual state for a stream, though it does not guarantee 
  6286.                       that any particular operation will succeed. 
  6287.  
  6288. 'UNKNOWN'             The state of the stream is unknown. In OS/2 
  6289.                       implementations, this generally means that the stream is 
  6290.                       closed (or has not yet been opened). However, this 
  6291.                       response can be used in other environments to indicate 
  6292.                       that the state of the stream cannot be determined. 
  6293.  
  6294. Note:   The state (and operation) of an input or output stream is global to a 
  6295.         REXX program, in that it is not saved and restored across function and 
  6296.         subroutine calls (including those caused by a CALL ON condition trap). 
  6297.  
  6298. Stream Commands 
  6299.  
  6300. The following stream commands are used to: 
  6301.  
  6302. o Open a stream for reading or writing 
  6303. o Close a stream at the end of an operation 
  6304. o Position the read or write position within a persistent stream (for example, 
  6305.   a file) 
  6306. o Get information about a stream (its existence, size, and last edit date). 
  6307.  
  6308. The streamcommand argument must be used when you select the operation C 
  6309. (command). The syntax is: 
  6310.  
  6311.  ΓöÇΓöÇSTREAM(name,'C',streamcommand)ΓöÇΓöÇΓöÇΓöÇ
  6312.  
  6313. In this form, the STREAM function itself returns a string corresponding to the 
  6314. given streamcommand if the command is successful. If the command is 
  6315. unsuccessful, STREAM returns an error message string in the same form as that 
  6316. supplied by the D (Description) operation. 
  6317.  
  6318. Command strings - The argument streamcommand can be any expression that REXX 
  6319. evaluates as one of the following command strings: 
  6320.  
  6321. 'OPEN'              Opens the named stream. The default for 'OPEN' is to open 
  6322.                     the stream for both reading and writing data. To specify 
  6323.                     whether name is only to be read or only to be written to, 
  6324.                     add the word READ or WRITE to the command string. 
  6325.  
  6326.                     The STREAM function itself returns 'READY' if the named 
  6327.                     stream is successfully opened or an appropriate error 
  6328.                     message if unsuccessful. 
  6329.  
  6330.                     Examples: 
  6331.  
  6332.                                         stream(strout,'c','open')
  6333.                                         stream(strout,'c','open write')
  6334.                                         stream(strinp,'c','open read')
  6335.  
  6336. 'CLOSE'             Closes the named stream. The STREAM function itself returns 
  6337.                     'READY' if the named stream is successfully closed or an 
  6338.                     appropriate error message otherwise. If an attempt is made 
  6339.                     to close an unopened file, then STREAM() returns a null 
  6340.                     string (""). 
  6341.  
  6342.                     Example: 
  6343.  
  6344.                                         stream('STRM.TXT','c','close')
  6345.  
  6346. 'SEEK' offset       Sets the read or write position a given number (offset) 
  6347.                     within a persistent stream. 
  6348.  
  6349.                     Note:   In OS/2, the read and write positions are the same. 
  6350.                             To use this command, the named stream must first be 
  6351.                             opened (with the 'OPEN' stream command, described 
  6352.                             previously). 
  6353.  
  6354.                     The offset number can be preceded by one of the following 
  6355.                     characters: 
  6356.  
  6357.    =    Explicitly specifies the offset from the beginning of the stream.  This 
  6358.         is the default if no prefix is supplied. 
  6359.  
  6360.    <    Specifies offset from the end of the stream. 
  6361.  
  6362.    +    Specifies offset forward from the current read or write position. 
  6363.  
  6364.    -    Specifies offset backward from the current read or write position. 
  6365.  
  6366.                     The STREAM function itself returns the new position in the 
  6367.                     stream if the read or write position is successfully 
  6368.                     located; an appropriate error message is displayed 
  6369.                     otherwise. 
  6370.  
  6371.                     Examples: 
  6372.  
  6373.                                         stream(name,'c','seek =2')
  6374.                                         stream(name,'c','seek +15')
  6375.                                         stream(name,'c','seek -7')
  6376.                                         fromend  = 125
  6377.                                         stream(name,'c','seek <'fromend)
  6378.  
  6379. Used with these stream commands, the STREAM function returns specific 
  6380. information about a stream 
  6381.  
  6382. 'QUERY EXISTS'      Returns the full path specification of the named stream, if 
  6383.                     it exists, and a null string otherwise. 
  6384.  
  6385.                                         stream('..\file.txt','c','query exists')
  6386.  
  6387. 'QUERY SIZE'        Returns the size in bytes of a persistent stream. 
  6388.  
  6389.                                         stream('..\file.txt','c','query size')
  6390.  
  6391. 'QUERY DATETIME'    Returns the date and time stamps of a stream. 
  6392.  
  6393.                                         stream('..\file.txt','c','query datetime')
  6394.  
  6395.  
  6396. ΓòÉΓòÉΓòÉ 11.54. STRIP ΓòÉΓòÉΓòÉ
  6397.  
  6398.  ΓöÇΓöÇSTRIP(stringΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6399.                   ΓööΓöÇ,ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6400.                        ΓööΓöÇoptionΓöÇΓöÿ ΓööΓöÇ,charΓöÇΓöÿ
  6401.  
  6402. STRIP removes leading and trailing characters from string based on the option 
  6403. you specify. Valid options (of which only the capitalized letter is 
  6404. significant, all others are ignored) are: 
  6405.  
  6406. Both            Removes both leading and trailing characters from string. This 
  6407.                 is the default. 
  6408.  
  6409. Leading         Removes leading characters from string. 
  6410.  
  6411. Trailing        Removes trailing characters from string. 
  6412.  
  6413. The third argument, char, specifies the character to remove; The default is a 
  6414. blank.  If you specify char, it must be exactly one character long. 
  6415.  
  6416. Here are some examples: 
  6417.  
  6418. STRIP('  ab c  ')        ->    'ab c'
  6419. STRIP('  ab c  ','L')    ->    'ab c  '
  6420. STRIP('  ab c  ','t')    ->    '  ab c'
  6421. STRIP('12.7000',,0)      ->    '12.7'
  6422. STRIP('0012.700',,0)     ->    '12.7'
  6423.  
  6424.  
  6425. ΓòÉΓòÉΓòÉ 11.55. SUBSTR ΓòÉΓòÉΓòÉ
  6426.  
  6427.  ΓöÇΓöÇSUBSTR(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6428.                       ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6429.                           ΓööΓöÇlengthΓöÇΓöÿ ΓööΓöÇ,padΓöÇΓöÿ
  6430.  
  6431. SUBSTR returns the substring of string that begins at the nth character, and is 
  6432. of length length and padded with pad if necessary. n must be a positive whole 
  6433. number. 
  6434.  
  6435. If length is omitted, the rest of the string will be returned.  The default pad 
  6436. character is a blank. 
  6437.  
  6438. Here are some examples: 
  6439.  
  6440. SUBSTR('abc',2)          ->    'bc'
  6441. SUBSTR('abc',2,4)        ->    'bc  '
  6442. SUBSTR('abc',2,6,'.')    ->    'bc....'
  6443.  
  6444. Note:   In some situations the positional (numeric) patterns of parsing 
  6445.         templates are more convenient for selecting substrings, especially if 
  6446.         more than one substring is to be extracted from a string. 
  6447.  
  6448.  
  6449. ΓòÉΓòÉΓòÉ 11.56. SUBWORD ΓòÉΓòÉΓòÉ
  6450.  
  6451.  ΓöÇΓöÇSUBWORD(string,n ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6452.                        ΓööΓöÇ,lengthΓöÇΓöÇΓöÿ
  6453.  
  6454. SUBWORD returns the substring of string that starts at the nth word, and is of 
  6455. length length, blank-delimited words. n must be a positive whole number. If you 
  6456. omit length, it defaults to the number of remaining words in string. The 
  6457. returned string never has leading or trailing blanks, but includes all blanks 
  6458. between the selected words. 
  6459.  
  6460. Here are some examples: 
  6461.  
  6462. SUBWORD('Now is the  time',2,2)    ->    'is the'
  6463. SUBWORD('Now is the  time',3)      ->    'the  time'
  6464. SUBWORD('Now is the  time',5)      ->    ''
  6465.  
  6466.  
  6467. ΓòÉΓòÉΓòÉ 11.57. SYMBOL ΓòÉΓòÉΓòÉ
  6468.  
  6469.  ΓöÇΓöÇSYMBOL(name)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6470.  
  6471. SYMBOL returns the state of the symbol named by name. If name is not a valid 
  6472. REXX symbol, BAD is returned. SYMBOL returns VAR if it is the name of a 
  6473. variable (that is, a symbol that has been assigned a value). Otherwise, SYMBOL 
  6474. returns LIT, indicating that it is either a constant symbol or a symbol that 
  6475. has not yet been assigned a value (that is, a literal). 
  6476.  
  6477. As with symbols in REXX expressions, lowercase characters in name are 
  6478. translated to uppercase and substitution in a compound name occurs if possible. 
  6479.  
  6480. Note:   You should specify name as a literal string (or derived from an 
  6481.         expression) to prevent substitution before it is passed to the 
  6482.         function. 
  6483.  
  6484. Here are some examples: 
  6485.  
  6486. /* following: Drop A.3;  J=3 */
  6487. SYMBOL('J')      ->   'VAR'
  6488. SYMBOL(J)        ->   'LIT' /* has tested "3"     */
  6489. SYMBOL('a.j')    ->   'LIT' /* has tested "A.3"   */
  6490. SYMBOL(2)        ->   'LIT' /* a constant symbol  */
  6491. SYMBOL('*')      ->   'BAD' /* not a valid symbol */
  6492.  
  6493.  
  6494. ΓòÉΓòÉΓòÉ 11.58. TIME ΓòÉΓòÉΓòÉ
  6495.  
  6496.  ΓöÇΓöÇTIME(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6497.            ΓööΓöÇoptionΓöÇΓöÿ
  6498.  
  6499. TIME returns the local time in the 24-hour clock format hh:mm:ss (hours, 
  6500. minutes, and seconds) by default; for example: 
  6501.  
  6502. 04:41:37
  6503.  
  6504. You can use the following options (for which only the capitalized letter is 
  6505. needed) to obtain alternative formats, or to gain access to the elapsed-time 
  6506. clock: 
  6507.  
  6508. Civil             Returns hh:mmxx, the time in Civil format, in which the hours 
  6509.                   may take the values 1 through 12, and the minutes the values 
  6510.                   00 through 59.  The minutes are followed immediately by the 
  6511.                   letters "am" or "pm" to distinguish times in the morning 
  6512.                   (midnight 12:00am through 11:59am) from noon and afternoon 
  6513.                   (noon 12:00pm through 11:59pm).  The hour will not have a 
  6514.                   leading zero.  The minute field shows the current minute 
  6515.                   (rather than the nearest minute) for consistency with other 
  6516.                   TIME results. 
  6517.  
  6518. Elapsed           Returns sssssssss.uu0000, the number of seconds.hundredths 
  6519.                   since the elapsed time clock was started or reset (see 
  6520.                   below). The returned number has no leading zeros, but always 
  6521.                   has four trailing zeros in the decimal portion. It is not 
  6522.                   affected by the setting of NUMERIC DIGITS. 
  6523.  
  6524. Hours             Returns number of hours since midnight in the format hh (no 
  6525.                   leading zeros). 
  6526.  
  6527. Long              Returns time in the format hh:mm:ss.uu0000 (where uu is the 
  6528.                   fraction of seconds in hundredths of a second). 
  6529.  
  6530. Minutes           Returns number of minutes since midnight in the format: mmmm 
  6531.                   (no leading zeros). 
  6532.  
  6533. Normal            Returns the time in the default format hh:mm:ss, as described 
  6534.                   above. 
  6535.  
  6536. Reset             Returns sssssssss.uu0000, the number of seconds.hundredths 
  6537.                   since the elapsed time clock was started or reset (see below) 
  6538.                   and also resets the elapsed-time clock to zero. The returned 
  6539.                   number has no leading zeros, but always has four trailing 
  6540.                   zeros in the decimal portion. 
  6541.  
  6542. Seconds           Returns number of seconds since midnight in the format sssss 
  6543.                   (no leading zeros). 
  6544. Here are some examples: 
  6545.  
  6546. TIME('L')    ->   '16:54:22.120000'   /* Perhaps */
  6547. TIME()       ->   '16:54:22'
  6548. TIME('H')    ->   '16'
  6549. TIME('M')    ->   '1014'           /* 54 + 60*16 */
  6550. TIME('S')    ->   '60862'  /* 22 + 60*(54+60*16) */
  6551. TIME('N')    ->   '16:54:22'
  6552. TIME('C')    ->   '4:54pm'
  6553.  
  6554. The Elapsed-Time Clock 
  6555.  
  6556. The elapsed-time clock may be used for measuring real time intervals. On the 
  6557. first call to the elapsed-time clock, the clock is started, and both TIME('E') 
  6558. and TIME('R') will return 0. 
  6559.  
  6560. The clock is saved across internal routine calls, which is to say that an 
  6561. internal routine inherits the time clock its caller started.  Any timing the 
  6562. caller is doing is not affected even if an internal routine resets the clock. 
  6563.  
  6564. Here is an example of the elapsed-time clock: 
  6565.  
  6566. time('E')    ->    0          /* The first call */
  6567. /* pause of one second here */
  6568. time('E')    ->    1.020000   /* or thereabouts */
  6569. /* pause of one second here */
  6570. time('R')    ->    2.030000   /* or thereabouts */
  6571. /* pause of one second here */
  6572. time('R')    ->    1.050000   /* or thereabouts */
  6573.  
  6574. Note:   See the DATE function about consistency of times within a single 
  6575.         expression.  The elapsed-time clock is synchronized to the other calls 
  6576.         to TIME and DATE, so multiple calls to the elapsed-time clock in a 
  6577.         single expression always return the same result.  For the same reason, 
  6578.         the interval between two normal TIME and DATE results may be calculated 
  6579.         exactly using the elapsed-time clock. 
  6580.  
  6581. Implementation maximum: If the number of seconds in the elapsed time exceed 
  6582. nine digits (equivalent to over 31.6 years), an error will result. 
  6583.  
  6584.  
  6585. ΓòÉΓòÉΓòÉ 11.59. TRACE ΓòÉΓòÉΓòÉ
  6586.  
  6587.  ΓöÇΓöÇTRACE(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  6588.             ΓööΓöÇoptionΓöÇΓöÿ
  6589.  
  6590. TRACE returns trace actions currently in effect. 
  6591.  
  6592. If option is supplied, it must be the valid prefix (?), one of the alphabetic 
  6593. character options (that is, starting with A, C, E, F, I, L, N, O, or R) 
  6594. associated with the TRACE instruction, or both. The function uses option to 
  6595. alter the effective trace action (such as tracing labels). Unlike the TRACE 
  6596. instruction, the TRACE function alters the trace action even if interactive 
  6597. debug is active. 
  6598.  
  6599. Unlike the TRACE instruction, option cannot be a number. 
  6600.  
  6601. Here are some examples: 
  6602.  
  6603. TRACE()       ->   '?R' /* maybe */
  6604. TRACE('O')    ->   '?R' /* also sets tracing off    */
  6605. TRACE('?I')   ->   'O'  /* now in interactive debug */
  6606.  
  6607.  
  6608. ΓòÉΓòÉΓòÉ 11.60. TRANSLATE ΓòÉΓòÉΓòÉ
  6609.  
  6610.  ΓöÇΓöÇTRANSLATE(string ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇ
  6611.                        ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  6612.                            ΓööΓöÇtableoΓöÇΓöÿ ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓö¼Γöÿ
  6613.                                           ΓöötableiΓöÿ Γöö,padΓöÿ
  6614.  
  6615. TRANSLATE translates characters in string to other characters, or reorders 
  6616. characters in a string. If neither translate table is given, string is simply 
  6617. translated to uppercase (for example, a lowercase a-z to an uppercase A-Z). The 
  6618. output table is tableo and the input translate table is tablei (the default is 
  6619. XRANGE('00'x,'FF'x)). The output table defaults to the null string and is 
  6620. padded with pad or truncated as necessary. The default pad is a blank. The 
  6621. tables can be of any length; the first occurrence of a character in the input 
  6622. table is the one that is used if there are duplicates. 
  6623.  
  6624. Here are some examples: 
  6625.  
  6626. TRANSLATE('abcdef')                        ->    'ABCDEF'
  6627. TRANSLATE('abbc','&','b')                  ->    'a&&c'
  6628. TRANSLATE('abcdef','12','ec')              ->    'ab2d1f'
  6629. TRANSLATE('abcdef','12','abcd','.')        ->    '12..ef'
  6630. TRANSLATE('4123','abcd','1234')            ->    'dabc'
  6631.  
  6632. Note:   The last example shows how to use the TRANSLATE function to reorder the 
  6633.         characters in a string.  In the example, the last character of any 
  6634.         four-character string specified as the second argument would be moved 
  6635.         to the beginning of the string. 
  6636.  
  6637.  
  6638. ΓòÉΓòÉΓòÉ 11.61. TRUNC ΓòÉΓòÉΓòÉ
  6639.  
  6640.  ΓöÇΓöÇΓöÇTRUNC(number ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6641.                     ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  6642.  
  6643. TRUNC returns the integer part of number, and n decimal places. The default n 
  6644. is zero, and it returns an integer with no decimal point. If you specify n, it 
  6645. must be a nonnegative whole number. The number is first rounded according to 
  6646. standard REXX rules, just as though the operation number+0 had been carried 
  6647. out. The number is then truncated to n decimal places (or trailing zeros are 
  6648. added if needed to make up the specified length). The result is never in 
  6649. exponential form. 
  6650.  
  6651. Here are some examples: 
  6652.  
  6653. TRUNC(12.3)           ->    12
  6654. TRUNC(127.09782,3)    ->    127.097
  6655. TRUNC(127.1,3)        ->    127.100
  6656. TRUNC(127,2)          ->    127.00
  6657.  
  6658. Note:   The number is rounded according to the current setting of NUMERIC 
  6659.         DIGITS if necessary before being processed by the function. 
  6660.  
  6661.  
  6662. ΓòÉΓòÉΓòÉ 11.62. VALUE ΓòÉΓòÉΓòÉ
  6663.  
  6664.  ΓöÇVALUE(nameΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇ)ΓöÇΓöÇΓöÇ
  6665.                  ΓööΓöÇ,ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6666.                       ΓööΓöÇnewvalueΓöÇΓöÇΓöÿ ΓööΓöÇ,selectorΓöÇΓöÿ
  6667.  
  6668. VALUE returns the value of the symbol named by name, and optionally assigns it 
  6669. a new value. By default, VALUE refers to the current REXX-variables 
  6670. environment, but other, external collections of variables may be selected. If 
  6671. you use the function to refer to REXX variables, then name must be a valid REXX 
  6672. symbol. (You can confirm this by using the SYMBOL function.) Lowercase 
  6673. characters in name are translated to uppercase. If name is a compound symbol, 
  6674. then REXX substitutes symbol values to produce the derived name of the symbol. 
  6675.  
  6676. If you specify newvalue, then the named variable is assigned this new value. 
  6677. This does not affect the result returned; that is, the function returns the 
  6678. value of name as it was before the new assignment. 
  6679.  
  6680. Here are some examples: 
  6681.  
  6682.      /* After: Drop A3; A33=7; K=3; fred='K'; list.5='Hi' */
  6683.      VALUE('a'k)     ->  'A3'
  6684.      VALUE('a'k||k)  ->  '7'
  6685.      VALUE('fred')   ->  'K'  /* looks up FRED   */
  6686.      VALUE(fred)     ->  '3'  /* looks up K      */
  6687.      VALUE(fred,5)   ->  '3'  /* and sets K=5    */
  6688.      VALUE(fred)     ->  '5'
  6689.      VALUE('LIST.'k) ->  'Hi' /* looks up LIST.5 */
  6690.  
  6691. To use VALUE to manipulate OS/2 environment variables, selector must be the 
  6692. string 'OS2ENVIRONMENT' or an expression so evaluated. In this case, the 
  6693. variable name need not be a valid REXX symbol. When VALUE is used to set or 
  6694. change the value of an environment variable, the new value is retained after 
  6695. the REXX procedure ends. 
  6696.  
  6697. Here are some examples: 
  6698.  
  6699. /* Given that an external variable FRED has a value of 4      */
  6700. share = 'OS2ENVIRONMENT'
  6701. say VALUE('fred',7,share)      /* says '4' and assigns        */
  6702.                                /* FRED a new value of 7       */
  6703.  
  6704. say VALUE('fred',,share)       /* says '7'                    */
  6705.  
  6706. /* After this procedure ends, FRED again has a value of 4     */
  6707.  
  6708. /* Accessing and changing OS/2 environment entries            */
  6709. env = 'OS2ENVIRONMENT'
  6710. new = 'C:\LIST\PROD;'
  6711. say value('prompt',,env)   /* says '$i[p]' (perhaps)          */
  6712. say value('path',new,env)  /* says 'C:\EDIT\DOCS;' (perhaps)  */
  6713.                            /* and sets PATH = 'C:LIST\PROD'   */
  6714.  
  6715. say value('path',,env)     /* says 'C:LIST\PROD'              */
  6716.  
  6717. /* When this procedure ends, PATH = 'C:\LIST\PROD'           */
  6718.  
  6719. Notes: 
  6720.  
  6721.  1. If the VALUE function refers to an uninitialized REXX variable, then the 
  6722.     default value of the variable is always returned; the NOVALUE condition is 
  6723.     not raised. NOVALUE is never raised by a reference to an external 
  6724.     collection of variables. 
  6725.  
  6726.  2. The VALUE function is used when a variable contains the name of another 
  6727.     variable, or when a name is constructed dynamically. If the name is 
  6728.     specified as a single literal string, the symbol is a constant and so the 
  6729.     whole function call can usually be replaced directly by the string between 
  6730.     the quotation marks.  (For example, fred=VALUE('k'); is identical to the 
  6731.     assignment fred=k;,unless the NOVALUE condition is being trapped. 
  6732.  
  6733.  3. To effect temporary changes to environment variables, use the SETLOCAL and 
  6734.     ENDLOCAL functions. 
  6735.  
  6736.  
  6737. ΓòÉΓòÉΓòÉ 11.63. VERIFY ΓòÉΓòÉΓòÉ
  6738.  
  6739.  ΓöÇΓöÇVERIFY(string,referenceΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇ
  6740.                              ΓööΓöÇ,ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÿ
  6741.                                  ΓööΓöÇoptionΓöÇΓöÇΓöÿ ΓööΓöÇ,startΓöÇΓöÿ
  6742.  
  6743. VERIFY returns a number indicating whether string is composed only of 
  6744. characters from reference. VERIFY returns the position of the first character 
  6745. in string that is not also in reference.  If all the characters were found in 
  6746. reference, 0 is returned. 
  6747.  
  6748. The third argument, option, can be any expression that results in a string 
  6749. starting with N or M that represents either Nomatch (the default) or Match.. 
  6750. Only the first character of option is significant and it can be in uppercase or 
  6751. lowercase, as usual. If Nomatch is specified, the position of the first 
  6752. character in string that is not also in reference is returned. 0 is returned if 
  6753. all characters in string were found in reference. If Match is specified, the 
  6754. position of the first character in string that is in reference is returned, or 
  6755. 0 is returned if none of the characters were found. 
  6756.  
  6757. The default for start is 1, thus, the search starts at the first character of 
  6758. string. You can override this by specifying a different start point, which must 
  6759. be a positive whole number. 
  6760.  
  6761. VERIFY always returns 0 if string is null or if start is greater than 
  6762. LENGTH(string). If reference is null, VERIFY returns 0 if you specify Match; 
  6763. otherwise, 1 is returned. 
  6764.  
  6765. Here are some examples: 
  6766.  
  6767. VERIFY('123','1234567890')             ->    0
  6768. VERIFY('1Z3','1234567890')             ->    2
  6769. VERIFY('AB4T','1234567890')            ->    1
  6770. VERIFY('AB4T','1234567890','M')        ->    3
  6771. VERIFY('AB4T','1234567890','N')        ->    1
  6772. VERIFY('1P3Q4','1234567890',,3)        ->    4
  6773. VERIFY('AB3CD5','1234567890','M',4)    ->    6
  6774.  
  6775.  
  6776. ΓòÉΓòÉΓòÉ 11.64. WORD ΓòÉΓòÉΓòÉ
  6777.  
  6778.  ΓöÇΓöÇΓöÇWORD(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6779.  
  6780. WORD returns the n th blank-delimited word in string. n must be a positive 
  6781. whole number. If there are fewer than n words in string, the null string is 
  6782. returned. This function is equivalent to SUBWORD(string,n,1). 
  6783.  
  6784. Here are some examples: 
  6785.  
  6786. WORD('Now is the time',3)    ->    'the'
  6787. WORD('Now is the time',5)    ->    ''
  6788.  
  6789.  
  6790. ΓòÉΓòÉΓòÉ 11.65. WORDINDEX ΓòÉΓòÉΓòÉ
  6791.  
  6792.  ΓöÇΓöÇΓöÇWORDINDEX(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6793.  
  6794. WORDINDEX returns the position of the first character in the n th 
  6795. blank-delimited word in string. n must be a positive whole number. If there are 
  6796. fewer than n words in the string, 0 is returned. 
  6797.  
  6798. Here are some examples: 
  6799.  
  6800. WORDINDEX('Now is the time',3)    ->    8
  6801. WORDINDEX('Now is the time',6)    ->    0
  6802.  
  6803.  
  6804. ΓòÉΓòÉΓòÉ 11.66. WORDLENGTH ΓòÉΓòÉΓòÉ
  6805.  
  6806.  ΓöÇΓöÇΓöÇWORDLENGTH(string,n)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6807.  
  6808. WORDLENGTH returns the length of the n th blank-delimited word in string. n 
  6809. must be a positive whole number. If there are fewer than n words in the string, 
  6810. 0 is returned. 
  6811.  
  6812. Here are some examples: 
  6813.  
  6814. WORDLENGTH('Now is the time',2)       ->    2
  6815. WORDLENGTH('Now comes the time',2)    ->    5
  6816. WORDLENGTH('Now is the time',6)       ->    0
  6817.  
  6818.  
  6819. ΓòÉΓòÉΓòÉ 11.67. WORDPOS ΓòÉΓòÉΓòÉ
  6820.  
  6821.  ΓöÇΓöÇΓöÇWORDPOS(phrase,stringΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6822.                              ΓööΓöÇ,startΓöÇΓöÇΓöÿ
  6823.  
  6824. WORDPOS searches string for the first occurrence of the sequence of 
  6825. blank-delimited words phrase, and returns the word number of the first word of 
  6826. phrase in string.  Multiple blanks between words in either phrase or string are 
  6827. treated as a single blank for the comparison, but otherwise the words must 
  6828. match exactly. 
  6829.  
  6830. By default, the search starts at the first word in string. You can override 
  6831. this by specifying start (which must be positive), the word at which to start 
  6832. the search. 
  6833.  
  6834. Here are some examples: 
  6835.  
  6836. WORDPOS('the','now is the time')              ->  3
  6837. WORDPOS('The','now is the time')              ->  0
  6838. WORDPOS('is the','now is the time')           ->  2
  6839. WORDPOS('is   the','now is the time')         ->  2
  6840. WORDPOS('is   time ','now is   the time')     ->  0
  6841. WORDPOS('be','To be or not to be')            ->  2
  6842. WORDPOS('be','To be or not to be',3)          ->  6
  6843.  
  6844.  
  6845. ΓòÉΓòÉΓòÉ 11.68. WORDS ΓòÉΓòÉΓòÉ
  6846.  
  6847.  ΓöÇΓöÇΓöÇWORDS(string)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6848.  
  6849. WORDS returns the number of blank-delimited words in string. 
  6850.  
  6851. Here are some examples: 
  6852.  
  6853. WORDS('Now is the time')    ->    4
  6854. WORDS(' ')                  ->    0
  6855.  
  6856.  
  6857. ΓòÉΓòÉΓòÉ 11.69. XRANGE ΓòÉΓòÉΓòÉ
  6858.  
  6859.  ΓöÇΓöÇΓöÇXRANGE(ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6860.               ΓööΓöÇstartΓöÇΓöÿ  ΓööΓöÇ,endΓöÇΓöÇΓöÿ
  6861.  
  6862. XRANGE returns a string of all one-byte codes between and including the values 
  6863. start and end. The default value for start is `00'x, and the default value for 
  6864. end is `FF'x. If start is greater than end, the values wrap from `FF'x to 
  6865. `00'x. If specified, start and end must be single characters. 
  6866.  
  6867. Here are some examples: 
  6868.  
  6869. XRANGE('a','f')      ->   'abcdef'
  6870. XRANGE('03'x,'07'x)  ->   '0304050607'x
  6871. XRANGE(,'04'x)       ->   '0001020304'x
  6872. XRANGE('i','j')      ->   '898A8B8C8D8E8F9091'x  /* EBCDIC */
  6873. XRANGE('FE'x,'02'x)  ->   'FEFF000102'x
  6874. XRANGE('i','j')      ->   'ij'                   /* ASCII  */
  6875.  
  6876.  
  6877. ΓòÉΓòÉΓòÉ 11.70. X2B (Hexadecimal to Binary). ΓòÉΓòÉΓòÉ
  6878.  
  6879.  ΓöÇΓöÇΓöÇX2B(hexstring)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6880.  
  6881. X2B converts hexstring (a string of hexadecimal characters) to an equivalent 
  6882. string of binary digits. hexstring can be of any length; each hexidecimal 
  6883. character is converted to a string of four binary digits. The returned string 
  6884. has a length that is a multiple of four, and does not include any blanks. 
  6885.  
  6886. Blanks can optionally be added (at byte boundaries only, not leading or 
  6887. trailing) to aid readability; they are ignored. 
  6888.  
  6889. If hexstring is null, X2B returns 0. 
  6890.  
  6891. Here are some examples: 
  6892.  
  6893. X2B('C3')        ==  '11000011'
  6894. X2B('7')         ==  '0111'
  6895. X2B('1 C1')      ==  '000111000001'
  6896.  
  6897. You can combine X2B( ) may be combined with the functions D2X( ) and C2X( ) to 
  6898. convert decimal numbers or character strings into binary form. 
  6899.  
  6900. Here are some examples: 
  6901.  
  6902. X2B(C2X('C3'x))  ==  '11000011'
  6903. X2B(D2X('129'))  ==  '10000001'
  6904. X2B(D2X('12'))   ==  '1100'
  6905.  
  6906.  
  6907. ΓòÉΓòÉΓòÉ 11.71. X2C (Hexadecimal to Character) ΓòÉΓòÉΓòÉ
  6908.  
  6909.  ΓöÇΓöÇΓöÇX2C(hexstring)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6910.  
  6911. X2C converts hexstring (a string of hexadecimal characters) to character. 
  6912.  
  6913. hexstring can be of any length. You can optionally add blanks to hexstring (at 
  6914. byte boundaries only, not leading or trailing positions) to aid readability; 
  6915. they are ignored. 
  6916.  
  6917. If necessary, hexstring is padded with a leading 0 to make an even number of 
  6918. hexadecimal digits. 
  6919.  
  6920. Here are some examples: 
  6921.  
  6922. X2C('4865 6c6c 6f') ->  'Hello'     /*  ASCII   */
  6923. X2C('3732 73')      ->  '72s'       /*  ASCII   */
  6924. X2C('F')          ->    '0F'x
  6925.  
  6926.  
  6927. ΓòÉΓòÉΓòÉ 11.72. X2D (Hexadecimal to Decimal) ΓòÉΓòÉΓòÉ
  6928.  
  6929.  ΓöÇΓöÇΓöÇX2D(hexstring ΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇ
  6930.                      ΓööΓöÇ,nΓöÇΓöÇΓöÿ
  6931.  
  6932. X2D converts hexstring (a string of hexadecimal characters) to decimal. If the 
  6933. result cannot be expressed as a whole number, an error results. That is, the 
  6934. result must have no more digits than the current setting of NUMERIC DIGITS. 
  6935.  
  6936. You can optionally add blanks to hexstring (at byte boundaries only, not 
  6937. leading or trailing positions) to aid readability; they are ignored. 
  6938.  
  6939. If hexstring is null, X2D returns 0. 
  6940.  
  6941. If n is not specified, hexstring is processed as an unsigned binary number. 
  6942.  
  6943. Here are some examples: 
  6944.  
  6945. X2D('0E')        ->    14
  6946. X2D('81')        ->    129
  6947. X2D('F81')       ->    3969
  6948. X2D('FF81')      ->    65409
  6949. X2D('c6 f0'X)    ->    240
  6950.  
  6951. If n is specified, the given sequence of hexadecimal digits is padded on the 
  6952. left with zeros (note, not sign-extended), or truncated on the left to n 
  6953. characters. The resulting string of n hexadecimal digits is taken to be a 
  6954. signed binary number-positive if the leftmost bit is OFF, and negative, in 
  6955. two's complement notation, if the leftmost bit is ON. If n is 0, X2D returns 0. 
  6956.  
  6957. Here are some examples: 
  6958.  
  6959. X2D('81',2)      ->    -127
  6960. X2D('81',4)      ->    129
  6961. X2D('F081',4)    ->    -3967
  6962. X2D('F081',3)    ->    129
  6963. X2D('F081',2)    ->    -127
  6964. X2D('F081',1)    ->    1
  6965. X2D('0031',0)    ->    0
  6966.  
  6967.  
  6968. ΓòÉΓòÉΓòÉ 12. Queue Interface ΓòÉΓòÉΓòÉ
  6969.  
  6970. REXX provides queuing services entirely separate from the OS/2 interprocess 
  6971. communications queues. The queues discussed here are solely for the use of REXX 
  6972. programs. 
  6973.  
  6974. REXX queues are manipulated within a program by these instructions: 
  6975.  
  6976. PUSH        Stacks a string on top of the queue (LIFO). 
  6977.  
  6978. QUEUE       Adds a string to the tail of the queue (FIFO). 
  6979.  
  6980. PULL        Reads a string from the head of the queue. If the queue is empty, 
  6981.             input is taken from the console (STDIN:). 
  6982.  
  6983. To get the number of items remaining in the queue, use the function QUEUED. 
  6984.  
  6985. Access to Queues 
  6986.  
  6987. There are two kinds of queues in REXX. Both kinds are accessed and processed by 
  6988. name. 
  6989.  
  6990. Session Queues - One session queue is automatically provided for each OS/2 
  6991. session in operation. Its name is always SESSION, and it is created by REXX the 
  6992. first time information is put on the queue by a program or procedure. All 
  6993. processes (programs and procedures) in a session can access the session queue. 
  6994. However, a given process can only access the session queue defined for its 
  6995. session, and the session queue is not unique to any single process in the 
  6996. session. 
  6997.  
  6998. Private Queues - Private queues are created (and deleted) by your program. You 
  6999. can name the queue yourself or leave the naming to REXX. In order for your 
  7000. program to use any queue, it must know the name of the queue. 
  7001.  
  7002.  
  7003. ΓòÉΓòÉΓòÉ 12.1. RXQUEUE Function ΓòÉΓòÉΓòÉ
  7004.  
  7005. Use the RxQueue function in a REXX program to create and delete queues and to 
  7006. set and query their names. The first parameter determines the function, the 
  7007. entire function name must be specified but the case of the function parameter 
  7008. is ignored. 
  7009.  
  7010. Syntax: 
  7011.  
  7012.  
  7013.  ΓöÇΓöÇRXQUEUE(ΓöÇΓö¼ΓöÇΓöÇ"Create"ΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓö¼ΓöÇ)ΓöÇΓöÇΓöÇΓöÇΓöÇ
  7014.               Γöé            ΓööΓöÇ,queuename ΓöÇΓöÿ Γöé
  7015.               Γö£ΓöÇΓöÇΓöÇ"Delete"ΓöÇΓöÇ queuename ΓöÇΓöÇΓöÇΓöÇΓöñ
  7016.               Γö£ΓöÇΓöÇΓöÇ"Get"ΓöÇΓöÇΓöÇΓöÇΓöÇ newqueuename ΓöÇΓöñ
  7017.               ΓööΓöÇΓöÇΓöÇ"Set"ΓöÇΓöÇΓöÇΓöÇΓöÇ newqueuename ΓöÇΓöÿ
  7018.  
  7019. Parameters: 
  7020.  
  7021. Create            Creates a queue with the name, queuename (if specified); if 
  7022.                   no name is specified, then REXX will provide a name. Returns 
  7023.                   the name of the queue in either case. 
  7024.  
  7025. Delete            Deletes the named queue; returns 0 if successful, a nonzero 
  7026.                   number if an error occurs; the possible return values are: 
  7027.  
  7028.    0           Queue has been deleted. 
  7029.  
  7030.    5           Not a valid queue name. 
  7031.  
  7032.    9           Queue named does not exist. 
  7033.  
  7034.    10          Queue is busy; wait is active. 
  7035.  
  7036.    12          A memory failure has occurred. 
  7037.  
  7038.    1000        Initialization error; check file OS/2.INI 
  7039.  
  7040. Get               Returns the name of the queue currently in use. 
  7041.  
  7042. Set               Sets the name of the current queue to newqueuename and 
  7043.                   returns the previous name of the queue. 
  7044.  
  7045. Example: Sample Queue in a REXX Procedure 
  7046.  
  7047.  
  7048. /*                                                                */
  7049. /*        push/pull WITHOUT multiprogramming support         */
  7050. /*                                                                */
  7051. push date() time()          /* push date and time            */
  7052. do 1000                     /* lets pass some time           */
  7053.   nop                       /* doing nothing                 */
  7054. end                         /* end of loop                   */
  7055. pull a b .                  /* pull them                     */
  7056. say 'Pushed at ' a b ', Pulled at ' date()
  7057. time() /* say now and then */
  7058.  
  7059. /*                                                                    */
  7060. /*              push/pull WITH multiprogramming support               */
  7061. /*            (no error recovery, or unsupported env tests            */
  7062. /*                                                                    */
  7063. newq = RXQUEUE('Create')    /* create a unique queue           */
  7064. oq = RXQUEUE('Set',newq)    /* establish new queue             */
  7065. push date() time()          /* push date and time              */
  7066. do 1000                     /* lets spend some time            */
  7067.   nop                       /* doing nothing                   */
  7068. end                         /* end of loop                     */
  7069. pull a b .                  /* get pushed info                 */
  7070. say 'Pushed at ' a b ', Pulled at ' date() time() /* tell user     */
  7071. call RXQUEUE 'Delete',newq         /* destroy unique queue created  */
  7072. call RXQUEUE 'Set',oq         /* reset to default queue (not required)*/
  7073.  
  7074. Special Considerations 
  7075.  
  7076.  1. External programs that must communicate with a REXX procedure by means of 
  7077.     defined data queues can use the default queue or the session queue, or they 
  7078.     can receive the data queue name by some interprocess communication 
  7079.     technique. This could include parameter passing, placement on a prearranged 
  7080.     logical queue, or use of normal OS/2 Inter-Process Communication mechanisms 
  7081.     (for example, pipes, shared memory or IPC queues). 
  7082.  
  7083.  2. Named queues are available across the entire system; therefore, the names 
  7084.     of queues must be unique within the system.  If a queue named os2que exists 
  7085.     and this function is issued: 
  7086.  
  7087.         newqueue = RXQUEUE('Create', 'os2que')
  7088.  
  7089.     a new queue is created and the name is chosen by REXX.  This new name is 
  7090.     returned by the function. 
  7091.  
  7092.  3. Any external program started inherits as its default queue the queue in use 
  7093.     by the parent process. 
  7094.  
  7095. Detached Processes 
  7096.  
  7097.  1. Detached processes will access a detached session queue that is unique for 
  7098.     each detached process. Note, however, that this detached session queue is 
  7099.     not the same as the session queue of the starting session. 
  7100.  
  7101.  2. REXX programs that are to be run as detached processes cannot perform any 
  7102.     SAY instructions or any PULL or PARSE PULL instructions that involve 
  7103.     terminal I/O. However, PULL and PARSE PULL instructions that act on a queue 
  7104.     are permitted in detached processes. 
  7105.  
  7106. Multi-Programming Considerations 
  7107.  
  7108. This data queue mechanism differs from OS/2 standard API queueing in the 
  7109. following ways: 
  7110.  
  7111.  1. The queue is NOT owned by a specific process, and as such any process is 
  7112.     entitled to modify the queue at any time.  The operations that effect the 
  7113.     queue are atomic, in that the resource will be serialized by the subsystem 
  7114.     such that no data integrity problems can be encountered. 
  7115.  
  7116.     However, synchronization of requests such that two processes, accessing the 
  7117.     same queue, get the data in the order it was placed on the queue is a user 
  7118.     responsibility and will not be provided by the subsystem support code. This 
  7119.     selector is owned by the calling application code and must be freed by the 
  7120.     caller using DosFreeSeg. 
  7121.  
  7122.  2. A regular OS/2 IPC queue is owned (created) by a specific process. When 
  7123.     that process terminates, the queue is destroyed. Conversely, the queues 
  7124.     created by the RxQueue('Create', queuename) call will exist until 
  7125.     EXPLICITLY deleted. Termination of a program or procedure that created a 
  7126.     private queue does not force the deletion of the private queue. Any data on 
  7127.     the queue when the process creating it terminates will remain on the queue 
  7128.     until either the queue is deleted (by way of the REXX function call 
  7129.     RxQueue('Create', queuename) or until the data is read. 
  7130.  
  7131. Data queues must be explicitly deleted by some procedure or program (not 
  7132. necessarily the creator). Deletion of a queue with remaining items, destroys 
  7133. those items. If a queue is not deleted, it will be lost and cannot be recovered 
  7134. except by randomly attempting to access each queue in the defined series. 
  7135.  
  7136.  
  7137. ΓòÉΓòÉΓòÉ <hidden>  ΓòÉΓòÉΓòÉ
  7138.  
  7139. A batch file contains a series of commands that you would enter, one at a time, 
  7140. at a command prompt for a particular process.  Instead, you simply type the 
  7141. name of the file.  Using a batch file shortens process time and reduces the 
  7142. possibility of typing errors.  Batch files in DOS sessions have a .BAT 
  7143. extension and in OS/2 sessions a .CMD extension.  For more information about 
  7144. batch files, see the Command Reference.