× 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.



On 15 Apr 2013 13:28, Stone, Joel wrote:
Not sure what is non-sensical - I was trying to make sense :(

Understood. But, as was done in a follow-up to Vern, having lead originally with the actual code or pseudo-code would have been, IMO, much clearer.

The nonsensical was first with regard to a return-value, something a CLP can not perform for a string, except as a parameter; I inferred from the description, that possibly the intention was to effect a return value. A literal parameter can not be changed, but nothing obvious suggested that a copy of the string need to be modified only in a called CLP and then used only in that CLP for whatever purpose. I supposed maybe the latter was the case, but to "change the text" seemed possibly to allude to a return value. As silly as it might seem, had it said "change a copy of the text", that would be totally different; thus why code examples can help clarify. Second, the apparent command string "SET_ENVR (jde_&ENVR_report@xxxxxxxxxxxxx)" is invalid syntactically either as an invocation of a SET_ENVR command with a positional parameter, or as a program invocation equivalent to CALL SET_ENVR PARM(jde_&ENVR_report@xxxxxxxxxxxxx) so even by that point in reading the message [the effective end], how the processing was to be invoked was still not clear... and why I supposed maybe the text in the parameter could actually have represented what would be in a CL variable that was to be updated.

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?

Use the SQL SET statement to set the result of an expression.

CL: call RplWithVal( 'jde_&ENVR4_report@xxxxxxxxxxxxx' '&ENVR4' &PTD )

// sqlrpgle pgm: RplWithVal
// parmlist: inpString, rplThisVal, rplWithVal
// code:
Exec SQL
set ReturnVal =
replace( :inpString , :rplThisVal , :rplWithVal ) ;

Regards, Chuck


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.

CRPence on Monday, April 15, 2013 3:21 PM wrote:

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 effective 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.