On 02 Oct 2013 15:47, Booth Martin wrote:
Now I am confused. Does he want to remove all blanks? Or just reduce
any and all blank strings to one blank, only?
Probably best to ask the Original Poster or refer back to the
Original Post than to inquire in response to my comments :-) But, given
the question was raised, I explain my thoughts...
The goal was stated in the OP as "trying to find the spaces ' ' and
replace them with no spaces ''" whereby the former apostrophe-delimited
string was clearly two blanks\space, and the latter was the
apostrophe-delimited empty string. While the two-blanks might seem to
suggest that the intent is to replace any occurrences of successive
blanks to just one-blank, that is not compatible with the empty-string
as the replacement value, because any two-blank sequences would get
removed without leaving anything to know that a single-blank should be
reinserted at that position. Thus I concluded as very probable, that
the two-blanks was likely a typographical error.
Additionally, within the same post, was a specific example of an
input string and the desired output string [albeit non-delimited]. That
seemed to clarify that the intent was to replace each space character
with the empty-string; again, that the two-blanks was a typo:
"... 'COPY EQUIPMNT, EQIPX' for example... into something like this:
'COPYEQUIPMNT,EQIPX' ..." // strings apostrophe-delimited by me.
The same /apparent/ effect of removing all blanks seemed implied
again, later in the OP, in the code snippet that summed up that OP.
Albeit improperly formed syntactically, a %REPLACE example showed a
single apostrophe-delimited blank\space character, with another argument
as the apostrophe-delimited empty-string. Ignoring the obvious syntax
issue, the implication ¿seemed to be? an intention to replace a ' ' with
a '':
SUBDTA=%REPLACE(' ':'') // RPG statement in code snippet of OP
The message I replied to had a similar coding, but using the %XLATE
[albeit poorly formed, as in a request that would effect no change to
the data] instead of the %REPLACE; i.e. again, one blank, and the
empty-string [as the alluded replacement character according to the
supporting text in the replied-to message]:
SUBDTA= %XLATE(' ':'':SUBDTA) // RPG stmt in msg I replied-to
Thus it seemed to me, that the most conspicuous intent implied [in
both the OP and the message to which I replied] was to replace all
spaces\blank characters with the empty-string, for which, given IBM i
7.1 is the OS being used, the following request apparently [I can not
test] should effect that:
SUBDTA=%ScanRpl(' ':'':SUBDTA); // remove blanks from SUBDTA
As an Amazon Associate we earn from qualifying purchases.