× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Not sure what is non-sensical - I was trying to make sense :(

Can SQL do a replace on the value in a CL variable? Or would I have to write out the variable to a temp file, do the replace, then read the row back in?

Yes SET_ENVR is a command and CL also.

Trying to make a command with one parm (text) that would replace an instance of the text "&ENVR4" with the 4 character environment "TEST" or "PROD" or "DEMO".

So it would work for email addresses, network path names, iseries lib names, etc.

Thanks



-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of CRPence
Sent: Monday, April 15, 2013 3:21 PM
To: midrange-l@xxxxxxxxxxxx
Subject: Re: want to create CL & CMD to substitute text in a parm

The examples are somewhat nonsensical with regard to a "result", if
that result is supposed to be a _returned_ string.? If the string is to
be returned, then is the SET_ENVR a *CMD object that is invoked with a
RTNVAL(*YES) parameter for which the input\output string is set via a CL
variable; i.e. invoked as SET_ENVR (&INOUTSTRNG) ? I wonder also,
because the given as apparent [call or command] invocation for "End
result" is not valid per the ampersand in the text not being delimited.
Per reference to wanting to "call" SET_ENVR, I suppose it could be a
*PGM instead? Command or Program, perhaps the literal string is
composed and passed, but perhaps only within the program the replacement
of the data should transpire in a local copy of the passed string constant?

As for doing a /replace/ function, as the efffective operation in CL,
there is new function in CL in v7r1 for a %SCAN to avoid having to use
QCLSCAN or similar. But the replace is still the concatenation of %SST
results. A link to the CL enhancements:
IBM i CL Enhancements in v7r1 TRx
Published by: Bob Cozzi on 06 Feb 2013
http://www.midrangenews.com/view?id=1997

Of course not understanding what is really desired to be done, other
than a /replace/ function, my first choice would be to avoid the use of
CL because string handling is really not its forté. I would probably be
real lazy and just use an SQLRPGLE and use the SQL REPLACE() scalar. A
REXX could easily be coded to do the replace as well, and the CL could
use STRREXXPRC to invoke the REXX code; returning values is not very
nice, so normally replacing the CL with REXX is the better option when
more sophisticated string handling is desirable.

If the replacement string can be matched to a message replacement
variable, e.g. &1 instead of the &ENVR4 [¿later shown as &ENVR?], then
the given string can be added as a message description and the
replacement value set as message data, and finally a RTVMSGD can effect
the variable replacement processing.

Regards, Chuck

On 15 Apr 2013 12:04, Stone, Joel wrote:
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

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.