I need to remove all occurrences of apostrophes within a text fields, I'd appreciate any help.
I am importing data from a RPGLE environment to a VB.Net environment; I usually remove apostrophes after importing, however I have fields that are now part of the file key and therefore need to be cleaned up on the RPGLE level.
(1) How would an apostrophes be identified in RPG, would I use a quotation within the apostrophes used as text identifiers to declare it?
(2) How would I remove all the occurences of apostrophes within a text field?.... preferably using free format code?
Thanks in anticipation. Once again, I appreciate any help.
Take a look at %xlate
This code will convert all "!" to *Blanks in field cmdstring
C eval CmdString = %xlate('!' : ' ' : CmdString)
All my answers were extracted from the "Big Dummy's Guide to the As400"
and I take no responsibility for any of them.
We call them single quotes. Generally in RPG a constant of a single quote is represented by two quotes. Thus
CmdString = %xlate('''' : ' ' : CmdString)
Using %Xlate will only replace characters - i.e. substitute a space for a quote as in the examples above. You'll need a series of %check and %Subst if you simply need to remove the quote and replace it by nothingness.
Code:d quotePosn s 5u 0 d text s 200a d quote c '''' /free quotePosn = %scan(quote: text ); DoW quotePosn > 0; text = %subst(text: 1: quotePosn - 1 ) + %subst(text: quotePosn + 1 ); quotePosn = %scan(quote: text ); EndDo;
THANK YOU ALL! I progress only so far in my cut & paste RPG world, and when I have to do something outside it, I like to do it right; I really appreciate the timely replies, without the help my code would be the dreaded crap we all hate to work with! Thanks again.