Focal Point
[CLOSED] replace '^' with '&' in string ..... & causing problem

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

November 06, 2009, 09:59 AM
rp
[CLOSED] replace '^' with '&' in string ..... & causing problem
Hi All,
I have a string in procedure which i need to replace '^' with '&'. (I used POSIT and STRREP function)
here is the code:

-*this is the string:&URL=Report.aspx?viewby=CG-R-PL^CMGP=10^CMGPDESC=QkNTIFNwZWNpZmlj
-SET &STR1 = &URL;
-SET &STR1A = &STR1;
-SET &STR1LEN = &STR1.LENGTH;
-SET &SP1 = POSIT(&STR1, &STR1LEN, '''', 1, 'I3');
-BLOOP
-SET &STRLEN = &STR1LEN;
-SET &STRSTART = &SP1+1;
-SET &STROUT = 'A' || &STRLEN;
-SET &NSTR = SUBSTR(&STR1LEN, &STR1, &STRSTART, &STRLEN, &STRLEN, '&STROUT');
-SET &STRCNT = IF &SP1 GT 0 THEN &STRCNT + 1 ELSE &STRCNT + 0;
-SET &STR1 = &NSTR;
-SET &SP1 = POSIT(&STR1, &STR1LEN, '''', 1, 'I2');
-IF &SP1 GT 0 THEN GOTO BLOOP;
-SET &STR1ALEN = &STR1LEN + &STRCNT;
-SET &NSTR1 = STRREP (&STR1LEN, &STR1A, 1,'^', 1, '&|', &STR1ALEN, 'A&STR1ALEN.EVAL');
-SET &URL = &NSTR1;



but the output i am getting is
URL = PPVVarianceReport.aspx?viewby=CG-R-PL&CMGP=10&CMGPDESC=QkNTIFNwZWNpZmlj;

how can i remove amp;from output string??

regards
RP

This message has been edited. Last edited by: Kerry,


webfocus 7.6.9 windows XP Excel
November 06, 2009, 11:28 AM
Doug
Check out CTRAN
Here's what I got from that:
 BEFORE ... Report.aspx?viewby=CG-R-PL^CMGP=10^CMGPDESC=QkNTIFNwZWNpZmlj
 AFTER .... Report.aspx?viewby=CG-R-PL&CMGP=10&CMGPDESC=QkNTIFNwZWNpZmlj
I hope this helps...




   In FOCUS Since 1983 ~ from FOCUS to WebFOCUS.
   Current: WebFOCUS Administrator at FIS Worldpay | 8204, 8206
November 06, 2009, 04:47 PM
susannah
replace a 94 with a 38
that's what you need to know for CTRAN function.
94 is the bytval for the ^ and 38 for the &.
ARe you saying you want to now remove the & ??
I don't understand your question.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
November 06, 2009, 07:15 PM
Doug
Oh Susannah,

I believe that he wanted to change
Report.aspx?viewby=CG-R-PL^CMGP=10^CMGPDESC=QkNTIFNwZWNpZmlj
      to
Report.aspx?viewby=CG-R-PL&CMGP=10&CMGPDESC=QkNTIFNwZWNpZmlj
Change the 94, an up-carrot, to a 38, an ampersand, right? (or, maybe trade in your 22 for a 357?) So anyway, I presented the Good old CTRAN. I believe that should do the trick, don't you? I don't want to do pass on the code, where's the learning factor in that? I just want to pointing RP in the right direction...
November 06, 2009, 09:23 PM
Tom Flynn
Actually, the question from rp that was asked:

quote:

how can i remove amp;from output string??


which, my suggestion would be STRREP:

 
-SET &URL_1  = 'Report.aspx?viewby=CG-R-PL^CMGP=10^CMGPDESC=QkNTIFNwZWNpZmlj';
-SET &URL_11 = STRREP(&URL_1.LENGTH, '&URL_1.EVAL', 1, '^'  ,0,  'X', &URL_1.LENGTH, 'A&URL_1.LENGTH');
-TYPE &URL_11
-EXIT


And, based on the description of the task, where rp's statement is:

quote:

I have a string in procedure which i need to replace '^' with '&'.


I would use, say, STRREP:

  
-SET &URL_2  = 'Report.aspx?viewby=CG-R-PL^CMGP=10^CMGPDESC=QkNTIFNwZWNpZmlj';
-SET &URL_21 = STRREP(&URL_2.LENGTH, '&URL_2.EVAL', 1, '^'  ,1,  '&', &URL_2.LENGTH, 'A&URL_2.LENGTH');
-TYPE &URL_21


But, then again, who knows what the need really is???


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
November 06, 2009, 10:26 PM
Doug
Now, I'm confused. RP's original question is
quote:
I have a string in procedure which i need to replace '^' with '&'.
then RP goes on to say
quote:
how can i remove amp;from output string??
which beckons the question: Why change the "^" to a "&" in the first place?

How about CTRAN and change the 94 to a zero?:
 BEFORE ... Report.aspx?viewby=CG-R-PL^CMGP=10^CMGPDESC=QkNTIFNwZWNpZmlj
 AFTER .... Report.aspx?viewby=CG-R-PLCMGP=10CMGPDESC=QkNTIFNwZWNpZmlj

November 09, 2009, 01:16 AM
rp
Hi All first of all Sorry for making the confusion.

Actually in my output string where ever '&' is there its being replaced and shown as & amp ;.(that is why i asked, how can i remove amp;from output string??) .
when i copy pasted the output the post window converted ' & amp ;' into '&' which made the confusion.


webfocus 7.6.9 windows XP Excel
November 09, 2009, 08:34 AM
Tom Flynn
Did you try STRREP? When putting code on this Forum, you wrap them "within" the RED </> code tags, upper-right on the toolbar. Then, click Options on the lower left and check Disable HTML...

-SET &URL_2 = 'Report.aspx?viewby=CG-R-PLamp;CMGP=10amp;CMGPDESC=QkNTIFNwZWNpZmlj';
-SET &URL_21 = STRREP(&URL_2.LENGTH, '&URL_2.EVAL', 4, 'amp;' ,0, 'X', &URL_2.LENGTH, 'A&URL_2.LENGTH');
-TYPE &URL_21


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe