Sie sind auf Seite 1von 356

OS/2 REXX:

From Bark to Byte

Document Number GG24-4199-00

December 1993

International Technical Support Organization Boca Raton Center

Take Note! Before using this information and the product it supports, be sure to read

Take Note!

Take Note! Before using this information and the product it supports, be sure to read the
Before using this information and the product it supports, be sure to read the general

Before using this information and the product it supports, be sure to read the general information under “Special Notices” on page xix.

information and the product it supports, be sure to read the general information under “Special Notices”

First Edition (December 1993)

This edition applies to OS/2 2.1.

Order publications through your IBM representative or the IBM branch office serving

your locality.

Publications are not stocked at the address given below.

An ITSO Technical Bulletin Evaluation Form for reader s feedback appears facing

Chapter 1.

If the form has been removed, comments may be addressed to:

IBM Corporation, International Technical Support Organization Dept. 91J, Building 235-2 Internal Zip 4423 901 NW 51st Street Boca Raton, Florida 33431-1328

When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you.

Copyright International Business Machines Corporation 1993.

All rights reserved.

Note to U.S. Government Users — Documentation related to restricted rights — Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp.

Abstract This document describes OS/2 REXX from a usage and application scenario basis. It includes

Abstract

This document describes OS/2 REXX from a usage and application scenario

basis.

It includes OS/2 REXX interfaces to CM/2, DB2/2 and MMPM/2.

This document is intended for IBM system engineers, IBM technical advisors, IBM authorized dealers, IBM customers and others who require a knowledge

of OS/2 2.1 REXX and its interfaces.

A working knowledge of OS/2 2.1 and REXX is assumed.

PS

(336 pages)

Contents Abstract   . . . . . . . . . . . .

Contents

Abstract

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

iii

Figures

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

xiii

Tables

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

xvii

Special Notices

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

xix

Preface How This Document is Organized

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

xxi

xxi

Related Publications International Technical Support Organization Publications Acknowledgments

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

xxii

xxiii

xxiii

Chapter 1.

Why REXX?

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

1

1.1 Power of OS/2 2.1 REXX

 

2

1.2 Example

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

5

 

1.2.1

Sample 1 FAH2CEL.CMD

 

5

Chapter 2.

OS/2 REXX Specifics

9

2.1

Calling from a REXX Procedure

9

2.1.1 The REXX Call Instruction

10

2.1.2 Calling OS/2 .EXE or Command Files

11

2.1.3 Multitasking with START and DETACH

15

2.2

File I/O with OS/2 REXX

18

2.2.1 Charin(name,start,length)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

19

2.2.2 Charout(name,string,start)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

20

2.2.3 Chars(name)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

20

2.2.4 Linein(name,line,count)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

21

2.2.5 Lineout(name,string,line)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

21

2.2.6 Lines(name)

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

22

2.2.7 Stream(name,operation,streamcommand)

.

.

.

.

.

.

.

.

.

.

.

.

.

22

2.2.8 Examples

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

23

2.3

RxQueue

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

25

2.3.1 PUSH

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

25

2.3.2 QUEUE

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

25

2.3.3 Private Queues Using RXQUEUE

 

26

2.3.4 LIFO, FIFO and CLEAR

38

2.4

Printing

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

38

2.4.1

PRINT Command

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

39

 

2.4.2 Lineout and Charout

 

39

2.4.3 Printer Objects

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

39

2.5

PMREXX, REXXTRY and RxMessageBox

 

42

PMREXX

2.5.1 .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

42

2.5.2 REXXTRY

46

2.5.3 RxMessageBox

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

47

Chapter 3.

External Functions

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

49

3.1 Usefulness

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

49

3.2 How to Register External Functions

 

50

3.3 Example - Accessing User Profile Management Services

 

51

3.4 Some Established External Function Packages

 

52

Chapter 4.

REXX Utilities External Function Package (REXXUTIL)

 

53

4.1

Drives, Directories and Files

 

54

4.1.1 SysDriveMap

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

54

4.1.2 SysDriveInfo

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

56

4.1.3 SysFileDelete

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

58

4.1.4 SysFileTree

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

58

4.1.5 SysFileSearch

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

58

4.1.6 SysMkDir

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

60

4.1.7 SysSearchPath

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

60

4.2

Workplace Shell Objects

 

60

4.2.1 SysCreateObject

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

61

4.2.2 SysSetObjectData

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

62

4.3

Miscalleneus Functions

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

64

4.3.1 SysCls

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

65

4.3.2 SysCurPos

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

65

4.3.3 SysCurState

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

65

4.3.4 SysGetKey

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

66

4.3.5 SysSleep

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

66

4.3.6 SysTextScreenRead

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

67

4.3.7 SysTextScreenSize

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

67

Chapter 5.

The Workplace Shell and REXX

 

69

5.1

Objects and Object Classes

 

69

5.1.1 WPFileSystem

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

71

WPAbstract

5.1.2 .

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

71

5.1.3 WPTransient

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

71

5.2

Creating Objects

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

72

5.2.1 Creating a Folder Object

 

72

5.2.2 Creating a Program Object

 

74

5.2.3 Creating a Shadow Object

75

5.2.4

Creating a Program Object in the Startup Folder

 

76

5.3 Creating Drag and Drop REXX Programs

 

77

5.4 Creating (Shadow) Objects Associated With Data Files

 

78

5.5 Modifying Workplace Shell Objects

 

79

5.5.1 Object IDs

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

79

RC Files

5.5.2 .

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

79

5.5.3 User INI File

 

80

5.5.4 SysSetObjectData

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

81

5.6 Moving Objects

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

84

5.7 SysIni

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

84

5.7.1 Using SysIni to Change System Settings

 

85

5.7.2 Using SysIni to Read INI Data

 

87

5.8

Extended Attributes

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

89

Chapter 6.

REXX and C

 

93

6.1 Creating C Functions for REXX

 

93

6.1.1 RXSTRING

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

94

6.1.2 Writing the C Function

 

94

6.1.3 Parameter Handling

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

97

6.2 Creating DLLs Callable by REXX Programs

 

100

6.3 Calling REXX from C (REXXSTART Function)

 

101

Chapter 7.

Multimedia REXX

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

105

7.1 MMPM/2 Installation

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

106

7.2 Using MCI from REXX

 

106

7.2.1 Registering MMPM/2 Functions

 

106

7.2.2 Checking if MMPM/2 is Installed

106

7.2.3 Opening a Media Device

 

107

7.2.4 Error Checking

 

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

108

7.2.5 MCI Commands

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

108

7.2.6 ACQUIRE

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.