Thanks Vern for this and all your help!

That is what I am doing but it gets messy quickly and is not so self-documenting.

Here is what I have so far: - any suggestions would be appreciated!

PGM parm(&text)
dcl &text *char len(500)
dcl &textLen *dec len(3) value(500)
dcl &envr1 *char len(1) value('?')
dcl &envr4 *char len(4) value('????')
dcl &patternlen *dec len(3)
dcl &dblib *char len(10)
dcl &start_pos *dec len(3)
dcl &start_pos1 *dec len(3)
dcl &end_pos1 *dec len(3)
dcl &start_pos2 *dec len(3)
dcl &end_pos2 *dec len(3)


rtvobjd RESTART objtype(*FILE) rtnlib(&DBLIB)
select
when (&DBLIB = 'PRODLIB') DO
chgvar &ENVR1 'P'
chgvar &ENVR4 'PROD'
ENDDO
when (&DBLIB = 'TESTLIB') DO
chgvar &ENVR1 'T'
chgvar &ENVR4 'TEST'
ENDDO
when (&DBLIB = 'DEMOLIB') DO
chgvar &ENVR1 'D'
chgvar &ENVR4 'DEMO'
ENDDO
endselect

chgvar &patternlen 6
SCNVAR RESULT(&start_pos) STRING(&TEXT) +
STRINGLEN(&textLen) PATTERN('&ENVR4') +
PATTERNLEN(&patternlen) TRANSLATE(*YES)
IF (&start_pos > 1) do
chgvar &end_pos1 (&start_pos - 1)
chgvar &start_pos2 (&start_pos + &patternlen)
chgvar &end_pos2 (&textLen - &start_pos2)
chgvar &text +
(%sst(&text 1 &end_pos1 ) +
|| &ENVR4 +
|| %sst(&text &start_pos2 &end_pos2))
ENDDO

ENDPGM


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Vern Hamberg
Sent: Monday, April 15, 2013 2:58 PM
To: Midrange Systems Technical Discussion
Subject: Re: want to create CL & CMD to substitute text in a parm

Joel

There is now a %scan builtin function - if you are at v7.1. You could still use QCLSCAN, too - and write your own. Once you find the location of &ENVR, you can use %SST to get the part before it and the part after it and put TEST or PROD in between.

That's the hard way. RPG is much better at this. So is a thing called REXX - easily called from CL.

I'm hoping IBM comes out with a %replace, too, for CL.

Vern

----- Original Message -----
For the purpose of describing the operating environment state (DEV, TEST, or PROD).

I want to call

SET_ENVR ('text or network path or email address goes here &ENVR4 and more text')

And have the CL named SET_ENVR change the text "&ENVR4" to TEST when the environment is a test environment (or PROD for production environment).

I am using the TAATOOL "SCNVAR" to locate the string of interest.

Is there a "replace" function in CL or TAATOOL or elsewhere that would help accomplish this?



End result:


SET_ENVR (jde_&ENVR_report@xxxxxxxxxxxxx) will result in the following if run from a test LPAR:

jde_TEST_report@xxxxxxxxxxxxx


If run on a production LPAR, the environment would resolve to:

jde_PROD_report@xxxxxxxxxxxxx


Thanks!



______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs Skyscan service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.