Discussion:
Favorite Rexx code
(too old to reply)
Lindy Mayfield
2016-04-09 10:40:22 UTC
Permalink
Raw Message
It's been slow in Rexxville, so I thought I'd show one of my favorite Rexx programs. I had help from ibm-main of course to do it. And the Get_stor() isn't mine. The research required to do this, though, was intensive. :)

Br,
Lindy

/* Rexx */
Numeric Digits 10
Depth = 0
ASCB = Get_Stor('224'x)
ASCBRCTP = Get_Stor(ASCB,'7C'x)
Call Process_TCB ASCBRCTP
Return

Process_TCB: Procedure Expose Depth
Say Copies(".",Depth) C2X(Arg(1))
Daughter = Get_Stor(Arg(1),'88'x)
If C2D(Daughter) <> 0 Then Do
Depth = Depth + 1
Call Process_TCB Daughter
Depth = Depth - 1
End
Sister = Get_Stor(Arg(1),'80'x)
If C2D(Sister) <> 0 Then call Process_TCB Sister
Return

Get_Stor: Procedure /* Not mine but a great procedure! */
Parse Arg Area,Offset,Leng
If Arg(2,'O') Then Offset=0
If Arg(3,'O') Then Leng=4
If DataType(Area) = 'CHAR' Then Do
Area = C2D(Area)
End
If DataType(Offset) = 'CHAR' Then Do
Offset = C2D(Offset)
End
Return Storage((D2X(Area+Offset)),Leng)


----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Richards, Robert B.
2016-04-11 13:06:25 UTC
Permalink
Raw Message
41 +++ Area = C2D(Area)
26 +++ Daughter = Get_Stor(Arg(1),'88'x)
33 +++ call Process_TCB Sister Return
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
21 +++ Call Process_TCB ASCBRCTP
IRX0040I Error running GETSTOR, line 41: Incorrect call to routine
***
Am I the only one getting this error?

Bob

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Lindy Mayfield
Sent: Saturday, April 09, 2016 6:40 AM
To: TSO-***@VM.MARIST.EDU
Subject: [TSO-REXX] Favorite Rexx code

It's been slow in Rexxville, so I thought I'd show one of my favorite Rexx programs. I had help from ibm-main of course to do it. And the Get_stor() isn't mine. The research required to do this, though, was intensive. :)

Br,
Lindy

/* Rexx */
Numeric Digits 10
Depth = 0
ASCB = Get_Stor('224'x)
ASCBRCTP = Get_Stor(ASCB,'7C'x)
Call Process_TCB ASCBRCTP
Return

Process_TCB: Procedure Expose Depth
Say Copies(".",Depth) C2X(Arg(1))
Daughter = Get_Stor(Arg(1),'88'x)
If C2D(Daughter) <> 0 Then Do
Depth = Depth + 1
Call Process_TCB Daughter
Depth = Depth - 1
End
Sister = Get_Stor(Arg(1),'80'x)
If C2D(Sister) <> 0 Then call Process_TCB Sister Return

Get_Stor: Procedure /* Not mine but a great procedure! */
Parse Arg Area,Offset,Leng
If Arg(2,'O') Then Offset=0
If Arg(3,'O') Then Leng=4
If DataType(Area) = 'CHAR' Then Do
Area = C2D(Area)
End
If DataType(Offset) = 'CHAR' Then Do
Offset = C2D(Offset)
End
Return Storage((D2X(Area+Offset)),Leng)


----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Schmutzok, Mike , Alpharetta
2016-04-11 13:27:07 UTC
Permalink
Raw Message
I had to move the RETURN statement on 33 to a new line to get it recognized.

Mike S

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Richards, Robert B.
Sent: Monday, April 11, 2016 9:04 AM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Favorite Rexx code

41 +++ Area = C2D(Area)
26 +++ Daughter = Get_Stor(Arg(1),'88'x)
33 +++ call Process_TCB Sister Return
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
21 +++ Call Process_TCB ASCBRCTP
IRX0040I Error running GETSTOR, line 41: Incorrect call to routine
***
Am I the only one getting this error?

Bob

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Lindy Mayfield
Sent: Saturday, April 09, 2016 6:40 AM
To: TSO-***@VM.MARIST.EDU
Subject: [TSO-REXX] Favorite Rexx code

It's been slow in Rexxville, so I thought I'd show one of my favorite Rexx programs. I had help from ibm-main of course to do it. And the Get_stor() isn't mine. The research required to do this, though, was intensive. :)

Br,
Lindy

/* Rexx */
Numeric Digits 10
Depth = 0
ASCB = Get_Stor('224'x)
ASCBRCTP = Get_Stor(ASCB,'7C'x)
Call Process_TCB ASCBRCTP
Return

Process_TCB: Procedure Expose Depth
Say Copies(".",Depth) C2X(Arg(1))
Daughter = Get_Stor(Arg(1),'88'x)
If C2D(Daughter) <> 0 Then Do
Depth = Depth + 1
Call Process_TCB Daughter
Depth = Depth - 1
End
Sister = Get_Stor(Arg(1),'80'x)
If C2D(Sister) <> 0 Then call Process_TCB Sister Return

Get_Stor: Procedure /* Not mine but a great procedure! */
Parse Arg Area,Offset,Leng
If Arg(2,'O') Then Offset=0
If Arg(3,'O') Then Leng=4
If DataType(Area) = 'CHAR' Then Do
Area = C2D(Area)
End
If DataType(Offset) = 'CHAR' Then Do
Offset = C2D(Offset)
End
Return Storage((D2X(Area+Offset)),Leng)


----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Richards, Robert B.
2016-04-11 14:10:24 UTC
Permalink
Raw Message
Good catch, thanks!

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Schmutzok, Mike (Alpharetta)
Sent: Monday, April 11, 2016 9:26 AM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Favorite Rexx code

I had to move the RETURN statement on 33 to a new line to get it recognized.

Mike S

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Richards, Robert B.
Sent: Monday, April 11, 2016 9:04 AM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Favorite Rexx code

41 +++ Area = C2D(Area)
26 +++ Daughter = Get_Stor(Arg(1),'88'x)
33 +++ call Process_TCB Sister Return
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
21 +++ Call Process_TCB ASCBRCTP
IRX0040I Error running GETSTOR, line 41: Incorrect call to routine
***
Am I the only one getting this error?

Bob

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Lindy Mayfield
Sent: Saturday, April 09, 2016 6:40 AM
To: TSO-***@VM.MARIST.EDU
Subject: [TSO-REXX] Favorite Rexx code

It's been slow in Rexxville, so I thought I'd show one of my favorite Rexx programs. I had help from ibm-main of course to do it. And the Get_stor() isn't mine. The research required to do this, though, was intensive. :)

Br,
Lindy

/* Rexx */
Numeric Digits 10
Depth = 0
ASCB = Get_Stor('224'x)
ASCBRCTP = Get_Stor(ASCB,'7C'x)
Call Process_TCB ASCBRCTP
Return

Process_TCB: Procedure Expose Depth
Say Copies(".",Depth) C2X(Arg(1))
Daughter = Get_Stor(Arg(1),'88'x)
If C2D(Daughter) <> 0 Then Do
Depth = Depth + 1
Call Process_TCB Daughter
Depth = Depth - 1
End
Sister = Get_Stor(Arg(1),'80'x)
If C2D(Sister) <> 0 Then call Process_TCB Sister Return

Get_Stor: Procedure /* Not mine but a great procedure! */
Parse Arg Area,Offset,Leng
If Arg(2,'O') Then Offset=0
If Arg(3,'O') Then Leng=4
If DataType(Area) = 'CHAR' Then Do
Area = C2D(Area)
End
If DataType(Offset) = 'CHAR' Then Do
Offset = C2D(Offset)
End
Return Storage((D2X(Area+Offset)),Leng)


----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lindy Mayfield
2016-04-11 17:37:03 UTC
Permalink
Raw Message
Actually, I did manage to find the original author of the get_stor() we see in a lot of execs. It's quite elegant and easy to use.



Br,

Lindy



000428 Get_Stor: PROCEDURE

000429

000430 /*------------------------------------------------------------------*/

000431 /* */

000432 /* Written by Vinh Vu */

000433 /* */

000434 /* This procedure will extract data using the MVS Storage */

000435 /* function. Input arguments will be: */

000436 /* */

000437 /* 1) Storage_Pointer or Literal, i.e. CVTPTR or '10'x, or */

000438 /* 16 (like '10'x) */

000439 /* 2) Offset in hex or dec (numnber), i.e. 'FF'x or 256 or */

000440 /* D2C(256) */

000441 /* 3) Length of returned data in decimal, i.e. 256 */

000442 /* */

000443 /* NOTE - To make sure that this procedure will work all the */

000444 /* times, just include 'NUMERIC DIGITS 256' at the beginning */

000445 /* of the calling REXX exec. */

000446 /* */

000447 /*------------------------------------------------------------------*/

000448

000449 Parse Arg AREA,OFFSET,LENG

000450

000451 If Arg(2,'O') Then OFFSET=0

000452

000453 If Arg(3,'O') Then LENG=4

000454

000455 If DataType(AREA) = 'CHAR' Then Do

000456 AREA = C2D(AREA)

000457 End

000458

000459 If DataType(OFFSET) = 'CHAR' Then Do

000460 OFFSET = C2D(OFFSET)

000461 End

000462

000463 Return Storage((D2X(AREA+OFFSET)),LENG)



It's quite nice. With it you can easily look at control blocks and create things like this as a simple control block example:



000001 /* Rexx */

000002 /* Lists address spaces and if started task, batch job or TSO User */

000003 Numeric Digits 10

000004 CVT=Get_Stor('10'x)

000005 ASCB=Get_Stor(CVT,'234'x)

000006 OUCB=Get_Stor(ASCB,'90'x)

000007 Do While C2D(ASCB) /= 0

000008 JBNI=Get_Stor(ASCB,'AC'x)

000009 JBNS=Get_Stor(ASCB,'B0'x)

000010 If C2D(JBNI) /= 0 Then

000011 Jobname=Get_Stor(JBNI,0,8)

000012 Else Jobname=Get_Stor(JBNS,0,8)

000013 OUCB=Get_Stor(ASCB,'90'x)

000014 OUCBYFL=Get_Stor(OUCB,'12'x,1)

000015 OUCBYFL=X2B(C2X(OUCBYFL))

000016 OUCBSTT=Substr(OUCBYFL,2,1)

000017 OUCBLOG=Substr(OUCBYFL,3,1)

000018 OUCBMNT=Substr(OUCBYFL,4,1)

000019 If OUCBSTT Then Type='Started Task'

000020 If OUCBLOG Then Type='TSO User'

000021 If OUCBMNT Then Type='Mount'

000022 If C2D(JBNI) /=0 Then Type='Batch Job'

000023 Say Left(Jobname,8) Type

000024 ASCB=Get_Stor(ASCB,4)

000025 End

000026 Return





JOBSCAN Rexx -

/* Rexx */

/* Lists address spaces and if started task, batch job or TSO User */

Numeric Digits 10

CVT=Get_Stor('10'x)

ASCB=Get_Stor(CVT,'234'x)

OUCB=Get_Stor(ASCB,'90'x)

Do While C2D(ASCB) /= 0

JBNI=Get_Stor(ASCB,'AC'x)

JBNS=Get_Stor(ASCB,'B0'x)

If C2D(JBNI) /= 0 Then

Jobname=Get_Stor(JBNI,0,8)

Else Jobname=Get_Stor(JBNS,0,8)

OUCB=Get_Stor(ASCB,'90'x)

OUCBYFL=Get_Stor(OUCB,'12'x,1)

OUCBYFL=X2B(C2X(OUCBYFL))

OUCBSTT=Substr(OUCBYFL,2,1)

OUCBLOG=Substr(OUCBYFL,3,1)

OUCBMNT=Substr(OUCBYFL,4,1)

If OUCBSTT Then Type='Started Task'

If OUCBLOG Then Type='TSO User'

If OUCBMNT Then Type='Mount'

If C2D(JBNI) /=0 Then Type='Batch Job'

Say Left(Jobname,8) Type

ASCB=Get_Stor(ASCB,4)

End

Return



Get_Stor: PROCEDURE /* Written by Vinh Vu */

Parse Arg AREA,OFFSET,LENG

If Arg(2,'O') Then OFFSET=0

If Arg(3,'O') Then LENG=4

If DataType(AREA) = 'CHAR' Then Do

AREA = C2D(AREA)

End

If DataType(OFFSET) = 'CHAR' Then Do

OFFSET = C2D(OFFSET)

End

Return Storage((D2X(AREA+OFFSET)),LENG)



----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Paul Gilmartin
2016-04-11 15:41:33 UTC
Permalink
Raw Message
Post by Schmutzok, Mike , Alpharetta
I had to move the RETURN statement on 33 to a new line to get it recognized.
??? But that's what I see in Lindy's original post, but not as Robert quoted
it. Did a mailer or copy-paste (which?) do Bad Things to you?
Post by Schmutzok, Mike , Alpharetta
-----Original Message-----
Sent: Monday, April 11, 2016 9:04 AM
...
33 +++ call Process_TCB Sister Return
....
-- gil

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Richards, Robert B.
2016-04-11 15:51:38 UTC
Permalink
Raw Message
Lindy's email and my cut/paste were identical. :-(


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Paul Gilmartin
Sent: Monday, April 11, 2016 11:41 AM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Favorite Rexx code
Post by Schmutzok, Mike , Alpharetta
I had to move the RETURN statement on 33 to a new line to get it recognized.
??? But that's what I see in Lindy's original post, but not as Robert quoted it. Did a mailer or copy-paste (which?) do Bad Things to you?
Post by Schmutzok, Mike , Alpharetta
-----Original Message-----
Sent: Monday, April 11, 2016 9:04 AM
...
33 +++ call Process_TCB Sister Return
....
-- gil

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lindy Mayfield
2016-04-11 17:18:37 UTC
Permalink
Raw Message
Strange. Looks like this on my screen. But my bad in any case.

000012 Return
000013
000014 Process_TCB: Procedure Expose Depth
000015 Say Copies(".",Depth) C2X(Arg(1))
000016 Daughter = Get_Stor(Arg(1),'88'x)
000017 If C2D(Daughter) <> 0 Then Do
000018 Depth = Depth + 1
000019 Call Process_TCB Daughter
000020 Depth = Depth - 1
000021 End
000022 Sister = Get_Stor(Arg(1),'80'x)
000023 If C2D(Sister) <> 0 Then call Process_TCB Sister
000024 Return
000025


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Richards, Robert B.
Sent: maanantaina 11. huhtikuuta 2016 17.47
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Favorite Rexx code

Lindy's email and my cut/paste were identical. :-(


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Paul Gilmartin
Sent: Monday, April 11, 2016 11:41 AM
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Favorite Rexx code
Post by Schmutzok, Mike , Alpharetta
I had to move the RETURN statement on 33 to a new line to get it recognized.
??? But that's what I see in Lindy's original post, but not as Robert quoted it. Did a mailer or copy-paste (which?) do Bad Things to you?
Post by Schmutzok, Mike , Alpharetta
-----Original Message-----
Sent: Monday, April 11, 2016 9:04 AM
...
33 +++ call Process_TCB Sister Return
....
-- gil

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Lindy Mayfield
2016-04-11 15:52:55 UTC
Permalink
Raw Message
Whoops sorry, a copy/paste problem, but cool to see the "recursive" error trace.

It was the first time I tried to write something recursive, and only because it was the only way to follow this particular control block chain without a lot of really complex logic.

Actually the TCB's have a mother, daughter and sister, but mother is more used by z/OS internals to do other stuff. This is year's old code, so I've forgotten most of it.. :-)

Br,
Lindy


-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Richards, Robert B.
Sent: maanantaina 11. huhtikuuta 2016 15.04
To: TSO-***@VM.MARIST.EDU
Subject: Re: [TSO-REXX] Favorite Rexx code

41 +++ Area = C2D(Area)
26 +++ Daughter = Get_Stor(Arg(1),'88'x)
33 +++ call Process_TCB Sister Return
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
29 +++ Call Process_TCB Daughter
21 +++ Call Process_TCB ASCBRCTP
IRX0040I Error running GETSTOR, line 41: Incorrect call to routine
***
Am I the only one getting this error?

Bob

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-***@VM.MARIST.EDU] On Behalf Of Lindy Mayfield
Sent: Saturday, April 09, 2016 6:40 AM
To: TSO-***@VM.MARIST.EDU
Subject: [TSO-REXX] Favorite Rexx code

It's been slow in Rexxville, so I thought I'd show one of my favorite Rexx programs. I had help from ibm-main of course to do it. And the Get_stor() isn't mine. The research required to do this, though, was intensive. :)

Br,
Lindy

/* Rexx */
Numeric Digits 10
Depth = 0
ASCB = Get_Stor('224'x)
ASCBRCTP = Get_Stor(ASCB,'7C'x)
Call Process_TCB ASCBRCTP
Return

Process_TCB: Procedure Expose Depth
Say Copies(".",Depth) C2X(Arg(1))
Daughter = Get_Stor(Arg(1),'88'x)
If C2D(Daughter) <> 0 Then Do
Depth = Depth + 1
Call Process_TCB Daughter
Depth = Depth - 1
End
Sister = Get_Stor(Arg(1),'80'x)
If C2D(Sister) <> 0 Then call Process_TCB Sister Return

Get_Stor: Procedure /* Not mine but a great procedure! */
Parse Arg Area,Offset,Leng
If Arg(2,'O') Then Offset=0
If Arg(3,'O') Then Leng=4
If DataType(Area) = 'CHAR' Then Do
Area = C2D(Area)
End
If DataType(Offset) = 'CHAR' Then Do
Offset = C2D(Offset)
End
Return Storage((D2X(Area+Offset)),Leng)


----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions, send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX

----------------------------------------------------------------------
For TSO-REXX subscribe / signoff / archive access instructions,
send email to ***@VM.MARIST.EDU with the message: INFO TSO-REXX
Loading...