Focal Point
[SOLVED] replacing a single quote

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/9327019336

October 03, 2013, 07:14 PM
Jay Potter
[SOLVED] replacing a single quote
I am trying to replace a single quote with a space. I have tried this

-SET &FFCCNMB = STRREP (25,&FFCCNMB, 1, "'", 1, ' ', 25, 'A25');

also this -SET &FFCCNMB = STRREP (25,&FFCCNMB, 1, ''''', 1, ' ', 25, 'A25');

Any suggestions?

This message has been edited. Last edited by: Jay Potter,


WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster
October 03, 2013, 07:23 PM
Waz
With these functions and a space, you need to add an extra non space but still only give a length of 1.

e.g.
SET &FFCCNMB = STRREP (25,&FFCCNMB, 1, '''', 1, ' X', 25, 'A25');



Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

October 04, 2013, 05:29 AM
Danny-SRL
You can also use CTRAN:
-SET &FFCCNMB = CTRAN (25,&FFCCNMB, 39, 32, 'A25');

Or more generally, using BYTVAL to translate a character to its decimal value:
-SET &FFCCNMB = CTRAN (25,&FFCCNMB, BYTVAL('''', 'I3'), BYTVAL(' ', 'I3'), 'A25');


All quotes will become spaces.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

October 04, 2013, 06:08 AM
Jay Potter
All three worked!!! Thank You very much.

I had to make a small change to the first CTRAN. I failed to say that I am using an iSeries so I had to use EDCDIC values instead.


WebFocus 8.1.5
iSeries/Windows
DB2/SQL/Access
Dev Studio
App Studio
Maintain
ReportCaster
October 04, 2013, 09:36 AM
Doug
Consider: CTRAN: Translating One Character to Another.




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
October 04, 2013, 09:55 AM
Twanette
I also like CTRAN in these situations.

And because Dialogue Manager does not necessarily have a "format" like a field, you may need to dynamically determine the length of your variable.
You could do something like this:
-SET &TLEN = &FFCCNMB.LENGTH ;
-SET &TFMT = 'A' | &TLEN ;
-SET &FFCCNMB = CTRAN(&TLEN, &FFCCNMB, 39, 32, '&TFMT') ;

Merge that into Daniel's second -SET and you then have a very interesting command ;-)


WebFOCUS 8.2.06 mostly Windows Server
October 05, 2013, 01:15 PM
Danny-SRL
Twanette,

Very true.
You can also do away with your second DM command:
  
-SET &FFCCNMB = CTRAN(&TLEN, &FFCCNMB, 39, 32, 'A&TLEN.EVAL') ;

BTW, I see many times people using .EVAL when not in a DM command. It doesn't hurt, but then it doesn't help.


Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

October 07, 2013, 04:53 PM
Waz
FYI,

You can do away with both lines with:
-SET &FFCCNMB = CTRAN(&FFCCNMB.LENGTH, &FFCCNMB, 39, 32, 'A&FFCCNMB.LENGTH') ;


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!