REXX/400 Programmer’s Guide

3y ago
57 Views
2 Downloads
853.63 KB
251 Pages
Last View : 14d ago
Last Download : 3m ago
Upload by : Audrey Hope
Transcription

AS/400 Advanced SeriesIBMREXX/400 Programmer’s GuideVersion 4SC41-5728-00

AS/400 Advanced SeriesIBMREXX/400 Programmer’s GuideVersion 4SC41-5728-00

Take Note!Before using this information and the product it supports, be sure to read the general information under “Notices” on page vii.First Edition (August 1997)This edition applies to the licensed program Operating System/400, (Program 5769-SS1), Version 4 Release 1 Modification 0, and toall subsequent releases and modifications until otherwise indicated in new editions.Make sure that you are using the proper edition for the level of the product.Order publications through your IBM representative or the IBM branch serving your locality. If you live in the United States, PuertoRico, or Guam, you can order publications through the IBM Software Manufacturing Solutions at 800 879-2755. Publications are notstocked at the address given below.IBM welcomes your comments. A form for readers’ comments may be provided at the back of this publication. You can also mailyour comments to the following address:IBM CorporationAttention Department 542IDCLERK3605 Highway 52 NRochester, MN 55901-7829 USAor you can fax your comments to:United States and Canada: 800 937-3430Other countries: ( 1) 507 253-5192If you have access to Internet, you can send your comments electronically to IDCLERK@RCHVMW2.VNET.IBM.COM; IBMMAIL, toIBMMAIL(USIB56RZ).When you send information to IBM, you grant IBM a nonexclusive right to use or distribute the information in any way it believesappropriate without incurring any obligation to you. Copyright International Business Machines Corporation 1997. All rights reserved.Note to U.S. Government Users — Documentation related to restricted rights — Use, duplication or disclosure is subject torestrictions set forth in GSA ADP Schedule Contract with IBM Corp.

ContentsNotices . . . . . . . . . . . . . . .Programming Interface InformationTrademarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .About REXX/400 Programmer’s Guide . . . . .Who Should Read This Book . . . . . . . . . . . .What You Should Know before Reading This BookWhat This Book Contains . . . . . . . . . . . . . .Prerequisite and Related Information . . . . . . .Information Available on the World Wide Web . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Chapter 1. Using REXX on the AS/400 System.Using REXX on the AS/400 System . . . . . . . . . .Learning About . . . . . . . . . . . . . . . . . . . .An Interpreted Language . . . . . . . . . . . . . . .Free Format . . . . . . . . . . . . . . . . . . . . . .Variables Without Type . . . . . . . . . . . . . . . .Built-in Functions . . . . . . . . . . . . . . . . . . .Parsing . . . . . . . . . . . . . . . . . . . . . . . . .How to Determine and Correct Programming ErrorsREXX and Systems Application Architecture . . . . .Understanding the AS/400 System Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Chapter 2. Writing and Running REXX Programs . . . . . . . . . . . . .Understanding the Parts of a REXX Program. . . . . . . . . . . . . . . . .Using Clauses . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Understanding REXX Source Entry . . . . . . . . . . . . . . . . . . . . . . .Using REXX Source Type in Source Entry. . . . . . . . . . . . . . . . .Using REXX Programs as Source File Members . . . . . . . . . . . . . .Understanding REXX as an Interpreted Language . . . . . . . . . . . . .Running REXX Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using the Start REXX Procedure CommandRunning REXX Programs by Using User-Defined Commands With REXXUsing the Program Development Manager (PDM) Work with MembersOption . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Starting REXX from a Program . . . . . . . . . . . . . . . . . . . . . . . .Using REXX Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using the Integrated Language Environment (ILE) Session Manager . . . .Using the SAY and PULL Keyword Instructions . . . . . . . . . . . . . . . .Using Interactive Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Using Batch Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Chapter 3. Using Variables . . . . . .Understanding Variables and ConstantsUsing Constants . . . . . . . . . . . .Using Variables . . . . . . . . . . . .Using Compound Symbols . . . . . . .Stems and Tails . . . . . . . . . . . .Derived Names . . . . . . . . . . . .Arrays . . . . . . . . . . . . . . . . . . Copyright IBM Corp. 1997. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1212121414161717171720202123iii

Using Variables in Programs, Functions, and SubroutinesUsing Special Variables. . . . . . . . . . . . . . . . .Using the SYMBOL Function . . . . . . . . . . . . . .Using the PROCEDURE Instruction. . . . . . . . . .Chapter 4. Using REXX ExpressionsUsing Terms and Operators . . . . . . .Using Arithmetic Operators. . . . .Using String Operators . . . . . . . .Using Comparison Operators . . . .Using Logical Operators . . . . . . .Using Function Calls as Expressions .Using Expressions in Instructions. . .Using Expressions as Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Chapter 5. Using REXX Instructions . . . . .Learning About Keyword Instructions . . . . . .Using Structured Programming . . . . . . . . . .Using Branches . . . . . . . . . . . . . . . . .Using Loops . . . . . . . . . . . . . . . . . . .Understanding Programming Style . . . . . . . .Using the INTERPRET Instruction . . . . . . . .Using a REXX Program Instead of a CL ProgramChapter 6. Using REXX Parsing TechniquesUnderstanding Parsing . . . . . . . . . . . . . .Using the PARSE Instruction . . . . . . . .Using Templates. . . . . . . . . . . . . . .Using Placeholders . . . . . . . . . . . . . .Parsing Variables and Expressions . . . . .Using Special Parsing Techniques . . . . .Using Parsing in a Program . . . . . . . . .Parsing With Patterns . . . . . . . . . . . . . .Using Literal Patterns . . . . . . . . . . . . .Using Positional Patterns . . . . . . . . . . .Using Variables in Patterns . . . . . . . . .Using String Functions . . . . . . . . . . . . . .Managing Strings . . . . . . . . . . . . . . .Measuring Strings . . . . . . . . . . . . . . .iv. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46565666869697071727274Chapter 7. Understanding Commands and Command Environments . . .Understanding Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Understanding Clause Interpretation . . . . . . . . . . . . . . . . . . . . . . .Understanding Command Environments. . . . . . . . . . . . . . . . . . . . . .Understanding Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . .Understanding Return Codes . . . . . . . . . . . . . . . . . . . . . . . . . . .Understanding the Error and Failure Conditions . . . . . . . . . . . . . . . . . .Understanding CL Command Environment Conditions . . . . . . . . . . . . .Understanding CPICOMM and EXECSQL Command Environment ConditionsUnderstanding User-Defined Command Environment Conditions . . . . . . .Understanding the Control Language (CL) Command Environment . . . . .7979798081828585868686Chapter 8. Using REXX Functions and SubroutinesUnderstanding Functions and Subroutines . . . . . . .9999REXX/400 Programmer’s Guide V4R1. . . . . . . . . . . . . . . . . . . . . . . . . .

Understanding the Differences Between Functions and SubroutinesUsing Internal Routines . . . . . . . . . . . . . . . . . . . . . . . . . . .Using External Routines . . . . . . . . . . . . . . . . . . . . . . . . . . .Understanding External Routines Written in REXX . . . . . . . . . .Understanding External Routines Written in Other Languages . . .Accessing Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . .Returning Results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Understanding the Function Search Order . . . . . . . . . . . . . . . .Using REXX Built-in Functions . . . . . . . . . . . . . . . . . . . . . . .Using the ADDRESS Built-in Function . . . . . . . . . . . . . . . . .Using the DATE Built-in Function . . . . . . . . . . . . . . . . . . . .Using the ERRORTEXT Built-in Function . . . . . . . . . . . . . . .Using the FORMAT Built-in Function . . . . . . . . . . . . . . . . . .Using the MAX and MIN Built-in Functions . . . . . . . . . . . . . .Using the SETMSGRC Built-in Function . . . . . . . . . . . . . . . .Using the SOURCELINE Built-in Function . . . . . . . . . . . . . . .Using the TIME Built-in Function . . . . . . . . . . . . . . . . . . . .Understanding Conversion Functions . . . . . . . . . . . . . . . . . . .Understanding Data Formats . . . . . . . . . . . . . . . . . . . . . .Using Conversion Functions . . . . . . . . . . . . . . . . . . . . . . .Chapter 9. Using the REXX External Data Queue . . . . .Learning About the REXX External Data Queue . . . . . . . .Using the REXX Queue Services on the AS/400 System . . .Starting Queuing Services . . . . . . . . . . . . . . . . . . .Understanding Queue Management Instructions . . . . . . . .Using the PUSH Instruction . . . . . . . . . . . . . . . . . .Using the QUEUE Instruction . . . . . . . . . . . . . . . . .Using the PULL Instruction . . . . . . . . . . . . . . . . . . .Using the Add REXX Buffer (ADDREXBUF) Command . .Using the Remove REXX Buffer (RMVREXBUF) CommandChapter 10. Determining Problems with REXX ProgramsUsing the TRACE Instruction and the TRACE Function . . .Using Interactive Tracing . . . . . . . . . . . . . . . . . . .Using Trace Settings . . . . . . . . . . . . . . . . . . . . .Interpreting Trace Results . . . . . . . . . . . . . . . . . .Using the Trace REXX (TRCREX) Command . . . . . . . .Chapter 11. Understanding Condition TrappingDefining Conditions . . . . . . . . . . . . . . . . . .Defining Condition Traps. . . . . . . . . . . . . .Using Condition Trapping . . . . . . . . . . . . . .Trapping Multiple Conditions . . . . . . . . . . .Appendix A. REXX Keywords. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124128129. . . . . . . . . . . . . . . .131131132133136. . . . . . . . . . . . . . . . . . . . . . . . . .137Appendix B. REXX Built-in Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139Appendix C. Double-Byte Character Set Support. . . . . . . . . . . . . .141Appendix D. Operators and Order of OperationsOperators . . . . . . . . . . . . . . . . . . . . . . . .Order of Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .143143145. . . . . . . . . . . . . . .Contentsv

Appendix E. Sample REXX Programs. . . . . . . . . . . . . . . . . . . . .Appendix F. Sample REXX Programs for the AS/400 System. . . . . . .157. . . . . . . . . . . . . 84185191193194Appendix H. Communication Between REXX/400 and Other LanguagesUsing the REXX External Data Queue API . . . . . . . . . . . . . . . . . . . .Pushing Data from RPG into the Queue . . . . . . . . . . . . . . . . . . . .Updating the File from the Queue by RPG. . . . . . . . . . . . . . . . . .Pushing Data from COBOL into the Queue . . . . . . . . . . . . . . . . . .Overriding STDIN and STDOUT . . . . . . . . . . . . . . . . . . . . . . . . . .199199199200204206Appendix I. String Manipulation in REXX versus CLSearching for a String Pattern . . . . . . . . . . . . . .Extracting Words from a String . . . . . . . . . . . . . .Concatenation with Numeric Variables. . . . . . . . . . . . . . . . . . . . .211211211213. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .219Appendix G. Communication Between REXX/400 and ILE/CCalling an ILE/C Program From REXX . . . . . . . . . . . . . .Calling ILE/C as an External Subroutine . . . . . . . . . . . .Calling ILE/C as an External Function . . . . . . . . . . . . .Calling ILE/C as a Command Environment . . . . . . . . . .Calling ILE/C with the CL CALL Command . . . . . . . . . . . . . . . . . . . . .Passing Parameters and Control to ILE/CCalling External Subroutines and Functions . . . . . . . . . .Calling a Command Environment . . . . . . . . . . . . . . . .Using the CL CALL Command. . . . . . . . . . . . . . . . .Using the REXX External Data Queue . . . . . . . . . . . . .Receiving Parameters in an ILE/C Program . . . . . . . . . . .Calling ILE/C Programs as External Functions or SubroutinesCalling ILE/C Programs as Command Environments . . . . .Calling ILE/C Programs with the CL CALL Command . . . .Receiving Parameters from the REXX External Data QueueReturning Results and Return Codes from ILE/C Programs . .Returning Results with the Variable Pool Interface . . . . . .Returning Results from the CL Command Environment . . .Returning Results in the REXX External Data Queue . . . .Example Using the REXX External Data Queue . . . . . . . . .GlossaryBibliographyIndexvi147. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .225. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .227REXX/400 Programmer’s Guide V4R1

NoticesReferences in this publication to IBM products, programs, or services do not imply that IBM intends tomake these available in all countries in which IBM operates. Any reference to an IBM product, program,or service is not intended to state or imply that only that IBM product, program, or service may be used.Subject to IBM's valid intellectual property or other legally protectable rights, any functionally equivalentproduct, program, or service may be used instead of the IBM product, program, or service. The evaluationand verification of operation in conjunction with other products, except those expressly designated by IBM,are the responsibility of the user.IBM may have patents or pending patent applications covering subject matter in this document. Thefurnishing of this document does not give you any license to these patents. You can send licenseinquiries, in writing, to the IBM Director of Licensing, IBM Corporation, 500 Columbus Avenue, Thornwood,NY 10594, U.S.A.Licensees of this program who wish to have information about it for the purpose of enabling: (i) theexchange of information between independently created programs and other programs (including this one)and (ii) the mutual use of the information which has been exchanged, should contact the softwareinteroperability coordinator. Such information may be available, subject to appropriate terms andconditions, including in some cases, payment of a fee.Address your questions to:IBM CorporationSoftware Interoperability Coordinator3605 Highway 52 NRochester, MN 55901-7829 USAThis publication could contain technical inaccuracies or typographical errors.This publication may refer to products that are announced but not currently available in your country. Thispublication may also refer to products that have not been announced in your country. IBM makes nocommitment to make available any unannounced products referred to herein. The final decision toannounce any product is based on IBM's business and technical judgment.This publication contains examples of data and reports used in daily business operations. To illustratethem as completely as possible, the examples include the names of individuals, companies, brands, andproducts. All of these names are fictitious and any similarity to the names and addresses used by anactual business enterprise is entirely coincidental.This publication contains small programs that are furnished by IBM as simple examples to provide anillustration. These examples have not been thoroughly tested under all conditions. IBM, therefore, cannotguarantee or imply reliability, serviceability, or function of these programs. All programs contained hereinare provided to you "AS IS". THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FORA PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Copyright IBM Corp. 1997vii

Programming Interface InformationThis REXX/400 Programmer’s Guide is intended to help you write programs using the AS/400 REXXinterpreter. This REXX/400 Programmer’s Guide documents General-Use Programming Interface andAssociated Guidance Information provided by AS/400.General-Use programming interfaces allow you to write programs that use the services of AS/400 REXX.TrademarksThe following terms are trademarks of the IBM Corporation in the United States or other countries or both:Application System/400Operating System/400AS/400OS/2BookManagerOS/400DB2Personal System/2DB2/400PS/2IBMLinkSAAIntegrated Language EnvironmentSQL/400Library ReaderSystems Application ArchitectureOperating System/2Microsoft, Windows, and the Windows 95 logo are trademarks or registered trademarks of M

Programming Interface Information This REXX/400 Programmer’s Guide is intended to help you write programs using the AS/400 REXX interpreter. This REXX/400 Programmer’s Guide documents General-Use Programming Interface and

Related Documents:

This book provides a comprehensive reference and programming guide to the Rexx programming lan-guage. It shows how to use the most popular implementations of Rexx and Rexx external function pack-ages and is suited to both the programmer learning Rexx for the

Rexx is the Restructured Extended Executor Language. New with TSO/E version 2, Rexx is a high-level procedural language that allows programmers to mix instructions with TSO commands, and build high-powered tools and utilities, called “exec”s. Rexx is a programming language, and a scripting language. Rexx is a fascinating language.File Size: 1MB

DB2 and the Joy of Rexx History of Rexx 1979 – 1982: creator Mike Cowlishaw on VM 1988: Ported to TSO & all other IBM platforms 1996: ANSI standard TRL-2 for “classic” Rexx 1997: Object Rexx for Windows & OS/2, then ported to AIX, Linux & SUN Solaris 2004: Open Object

computing with REXX Rexx Symposium 2004 Michael Beer mbeer@m-dc.com. Agenda on-demand overview personal experience CRM ASP. . productivity tools. Why REXX ? &TRACE OFF &TYPE HELLO &EXIT 0 . Why REXX ? &TRACE OFF &TYPE HELLO &EXIT 0 . Mainframe N/A PC Server many/large Servers Client: 3270 Terminal PC PC Web browser .

TSO/E command or as a REXX external routine. Once this has been determined, the compiled REXX program is given control with the appropriate parameters. In simple terms, subroutines called using the CALL statement or invoked as a function call See IBM Compiler and Library for REXX on System z: User's Guide and ReferenceFile Size: 1MB

As the inventor of the REXX language, Dr. Cowlishaw provides a unique perspective on its purpose and design. The REXX Handbook (McGraw Hill, 1991, ISBN 0-07-023682-8), edited by Gabe Goldberg and Philip Smith, contains information from a variety of sources concerning the history of REXX, REXX on non-MVS pla

As the inventor of the REXX language, Dr. Cowlishaw provides a unique perspective on its purpose and design. The REXX Handbook (McGraw Hill, 1991, ISBN 0-07-023682-8), edited by Gabe Goldberg and Philip Smith, contains information from a variety of sources concerning the history of REXX, REXX on non-MVS pla

2nd Grade – Launching with . Voices in the Park by Anthony Browne (lead from the Third Voice) My First Tooth is Gone by student (student authored work from Common Core Student Work Samples) A Chair for my Mother by Vera B. William Moonlight on the River by Robert McCloskey One Morning in Maine by Robert McCloskey, Roach by Kathy (student authored work from www.readingandwritingproject.com .