Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

REXX on z/OS Versions and CHANGESTR

504 views
Skip to first unread message

Sevetson, Phil

unread,
Mar 16, 2015, 5:20:46 PM3/16/15
to
I just tried to use the CHANGESTR(old,target,new) function in REXX on our z/OS installation, which is at z/OS 2.1. It wasn't there (UNRECOGNIZED FUNCTION). Fosdick's REXX book says it was part of the ANSI-1996 standard, so it's about 20 years old.

1) Does anyone know whether it's supposed to be there - as in, did IBM make the change to the 1996 REXX standard in their z/OS Compiler? It looks like the answer to that is "No" - the most up to date IBM REXX reference manual that I can see online doesn't have it - but I'd love for someone to show me otherwise.
2) If it's supposed to be there, is there a library I'm supposed to include, or something nontrivial that I'm supposed to do to get access to it?
3) I'm hand-coding a function for it; Has anyone else done this already who'd be willing to share?

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

Pedro Vera

unread,
Mar 16, 2015, 5:31:42 PM3/16/15
to
I have used this in the past:

myline = change(myline, cfrom, cto)
....

change:
Parse Arg string, old, new
If old=='' Then Return new||string

out=''
Do while pos(old,string)ャ=0
Parse var string prefix (old) string
out=out||prefix||new
End
Return out||string



Pedro Vera
DB2 Admin Tool
http://www-01.ibm.com/software/data/db2imstools/db2tools/db2admin/

Sevetson, Phil

unread,
Mar 16, 2015, 5:33:30 PM3/16/15
to
Thank you. I'll see if that does what I want, or can be modified for that.

Sevetson, Phil

unread,
Mar 16, 2015, 5:41:44 PM3/16/15
to
Can't get that to work for me. I'll bash it about a bit and try to figure out why not.

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Pedro Vera
Sent: Monday, March 16, 2015 5:31 PM
To: TSO-...@VM.MARIST.EDU
Subject: Re: [TSO-REXX] REXX on z/OS Versions and CHANGESTR

Ze'ev Atlas

unread,
Mar 16, 2015, 5:45:13 PM3/16/15
to
you may want to look intohttp://www.scoug.com/os24u/2002/scoug202.changestr.htmlfor an alternative implementation, which is similar to Pedro's, but there is an implementation for countstr as well and some safeguards. 
Ze'ev Atlas

From: "Sevetson, Phil" <PSev...@FISA.NYC.GOV>
To: TSO-...@VM.MARIST.EDU
Sent: Monday, March 16, 2015 5:33 PM
Subject: Re: [TSO-REXX] REXX on z/OS Versions and CHANGESTR

Thank you.  I'll see if that does what I want, or can be modified for that.

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Pedro Vera
Sent: Monday, March 16, 2015 5:31 PM
To: TSO-...@VM.MARIST.EDU
Subject: Re: [TSO-REXX] REXX on z/OS Versions and CHANGESTR

I have used this in the past:

myline = change(myline, cfrom, cto)
....

change:
  Parse Arg string, old, new
  If old=='' Then Return new||string

  out=''
  Do while pos(old,string)¬=0

Robert Zenuk

unread,
Mar 16, 2015, 5:48:43 PM3/16/15
to
Here is my version...

say chgstr('xexexe','qq','xe')
say chgstr('xexexe','ae','k')
say chgstr('xexexe','ae','e')
say chgstr('xexexe','Q','xexex')
say chgstr('xexe xe xe xexex','ll','e')
say chgstr('xexe xe xe xexex','f','xe')
say chgstr('aaaa','1','a')
say chgstr('zzzz','26','z')
say chgstr('error','xx')
say chgstr('JOHN JACOB GEORGE SCHMIDT','JINGLEHEIMER','GEORGE')
exit 0
chgstr: procedure
if arg() <> 3 then
return 'chgstr: missing args, must have string, new and old'
string = arg(1)
new = arg(2)
old = arg(3)
lnew = length(new)
lold = length(old)
x = 1
do forever
if pos(old,string,x) = 0 then return string
x = pos(old,string,x)
string = insert(new,delstr(string,x,lold),x-1,lnew)
x = x + length(new)
end

Rob


-----Original Message-----
From: Sevetson, Phil <PSev...@FISA.NYC.GOV>
To: TSO-REXX <TSO-...@VM.MARIST.EDU>
Sent: Mon, Mar 16, 2015 2:41 pm
Subject: Re: REXX on z/OS Versions and CHANGESTR


Can't get that to work for me. I'll bash it about a bit and try to figure out
why not.

-----Original Message-----
From: TSO REXX Discussion List
[mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Pedro Vera
Sent: Monday, March 16,
2015 5:31 PM
To: TSO-...@VM.MARIST.EDU
Subject: Re: [TSO-REXX] REXX on z/OS
Versions and CHANGESTR

I have used this in the past:

myline =
change(myline, cfrom, cto)
....

change:
Parse Arg string, old, new
If
old=='' Then Return new||string

out=''
Do while pos(old,string)¬=0

Sevetson, Phil

unread,
Mar 16, 2015, 5:59:43 PM3/16/15
to
Thanks, I'll have a look at that, too. (Tomorrow.)

Sevetson, Phil

unread,
Mar 19, 2015, 3:59:29 PM3/19/15
to
Ze'ev, I didn't see an implementation of CHANGESTR there. COUNTSTR only, and it looked like they were using PARSE, which defaults to separating only _words_, not embedded strings. (I admit to not having looked in depth at the code after it became clear that I wasn't seeing an implementation of string substitution.)

Ze'ev Atlas

unread,
Mar 19, 2015, 4:16:29 PM3/19/15
to
In the bottom of the article there is a link to download some versions of both routines and as far as I can tell, it would do the trick for what you need. Ze'ev Atlas

Robert Garrett

unread,
Mar 23, 2015, 7:27:43 PM3/23/15
to
This works for me:

say CHANGE_ALL('INPUT',,
'NEED INPUT, STEPHANIE... INPUT!',,
'OUTPUT');

return 0;

CHANGE_ALL:
parse arg _NEEDLE,_HAYSTACK,_REPLACEMENT;
do ZIX = 1;
if POS(_NEEDLE,_HAYSTACK) = 0 then,
leave ZIX;
else,
do;
parse value _HAYSTACK with,
_PREFIX (_NEEDLE) _SUFFIX;
_HAYSTACK = _PREFIX||_REPLACEMENT||_SUFFIX;
end;
end ZIX;
return _HAYSTACK;

-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of

Steve Coalbran

unread,
Mar 24, 2015, 2:59:27 AM3/24/15
to
Another Needle/Haystack lover.
Cut&Pasted from my REXX member 'REQUIRED' where I store oft-used
goodies...
/*<CHANGESTR>========================================================*/
/* Replace all occurrences of needle in the string haystack */
/* The function returns the changed string. If haystack does not */
/* contain needle, then the original haystack is returned. */
/* Syntax: CHANGESTR(needle, haystack, newneedle ) */
/* TRY: ------------------------------------------------------------->>
SAY LEFT("Function -> Result",53) "?=Prediction"
SAY COPIES("-",53) "-----------------"
SAY "CHANGESTR('B','Buttle','T') ->",
CHANGESTR('B','Buttle','T') " ?=Tuttle"
SAY "CHANGESTR('z','zdefzcdzd','abc') ->",
CHANGESTR('z','zdefzcdzd','abc') " ?=abcdefabccdabcd"
SAY "CHANGESTR('abc','abcdefabccdabcd','z') ->",
CHANGESTR('abc','abcdefabccdabcd','z') " ?=zdefzcdzd"
EXIT
>>===================================================================*/
CHANGESTR: PROCEDURE ;TRACE "O"
PARSE ARG old_needle ,,
old_haystack =1 front (old_needle) back ,,
new_needle new_haystack
DO WHILE(front<<old_haystack)
new_haystack = new_haystack!!front!!new_needle
PARSE VAR back old_haystack =1 front (old_needle) back
END
RETURN new_haystack!!old_haystack /*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/*</CHANGESTR>=======================================================*/
Looking at it now I can't remember why it works but it does! 8-@
Amazingly.
Yes! I know I have some weird standards and if you're wondering, the !≡|
in CP=1143.
The pseudo-HTML tags are part of an indexing feature I started writing in
1985 but haven't quite got around to finishing! ...One day perhaps?!


/Steve



From: Robert Garrett <rob...@GARRETTFAMILY.US>
To: TSO-...@VM.MARIST.EDU,
Date: 2015-03-24 00:28
Subject: Re: [TSO-REXX] REXX on z/OS Versions and CHANGESTR
Sent by: TSO REXX Discussion List <TSO-...@VM.MARIST.EDU>



This works for me:

say CHANGE_ALL('INPUT',,
'NEED INPUT, STEPHANIE... INPUT!',,
'OUTPUT');

return 0;

CHANGE_ALL:
parse arg _NEEDLE,_HAYSTACK,_REPLACEMENT;
do ZIX = 1;
if POS(_NEEDLE,_HAYSTACK) = 0 then,
leave ZIX;
else,
do;
parse value _HAYSTACK with,
_PREFIX (_NEEDLE) _SUFFIX;
_HAYSTACK = _PREFIX||_REPLACEMENT||_SUFFIX;
end;
end ZIX;
return _HAYSTACK;

-----Original Message----- Deleted -----





S?vida annat inte anges ovan: / Unless stated otherwise above:
IBM Svenska AB
Organisationsnummer: 556026-6883
Adress: 164 92 Stockholm

Kopischke, David G.

unread,
Mar 24, 2015, 11:54:11 AM3/24/15
to
Nice Software



-----Original Message-----
From: TSO REXX Discussion List [mailto:TSO-...@VM.MARIST.EDU] On Behalf Of Robert Garrett
Sent: Monday, March 23, 2015 5:27 PM
To: TSO-...@VM.MARIST.EDU
This e-mail transmission may contain information that is proprietary, privileged and/or confidential and is intended exclusively for the person(s) to whom it is addressed. Any use, copying, retention or disclosure by any person other than the intended recipient or the intended recipient's designees is strictly prohibited. If you are not the intended recipient or their designee, please notify the sender immediately by return e-mail and delete all copies. OppenheimerFunds may, at its sole discretion, monitor, review, retain and/or disclose the content of all email communications.

Walter Pachl

unread,
Mar 24, 2015, 4:04:36 PM3/24/15
to
But yiu get a loop with
say CHANGE_ALL('INPUT',,
'NEED INPUT, STEPHANIE... INPUT!',,
'INPUT');
--
Walter Pachl (nasty tester :-)

--

mar...@gmail.com

unread,
May 5, 2015, 5:36:52 AM5/5/15
to
The link above works not for me; but you get it (and some other useful things as well) by the Wayback Machine:

http://web.archive.org/web/20061019223413/http://www.scoug.com/OS24U/2002/SCOUG202.CHANGESTR.HTML

Gabor
0 new messages