Focal Point
[CLOSED] Replacing in a String Dynamically

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

January 02, 2010, 11:59 AM
saggy
[CLOSED] Replacing in a String Dynamically
I have a Scenario in report where i have to replace a string.From a HTML page i get a string in the format of STR1 = 'X1' AND 'X2' AND 'X3'

This string needs to be converted in to the format of STR1 = X1 + X2 + X3 removing both the quotes and the AND replaced by a plus sign and add to this the string is always dynamic.Is there any solution for this.

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


7.6.4
Unix & Windows
Excel,HTML,PDF,PPT,AHTML


January 03, 2010, 03:45 PM
FrankDutch
there are many ways to replace characters in a string.

did you look at the several formulas?




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

January 03, 2010, 04:52 PM
Waz
Check out the Using Functions documentation.

http://documentation.informati....htm?url=topic14.htm


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!

January 03, 2010, 05:15 PM
njsden
Check out this thread on a similar case which might give you some ideas: Search and Replace paying particular attention to the STRREP function.

- Neftali.



Prod/Dev: WF Server 8008/Win 2008 - WF Client 8008/Win 2008 - Dev. Studio: 8008/Windows 7 - DBMS: Oracle 11g Rel 2
Test: Dev. Studio 8008 /Windows 7 (Local) Output:HTML, EXL2K.
January 03, 2010, 07:34 PM
saggy
thanks for the solutions of which most of them almost worked.I am not able to use the STRREP function to replace AND with a '+' Sign.The Error is something like invalid argument in the fucntion.Is this because this being an operator?? and the other problem is with the single quote .How will it recognize the ' and replace it coz
-SET &V1 = ' 'a' OR 'b' OR 'c' OR 'd' OR 'e'' ;

-SET &V2 = STRREP(&V1.LENGTH, &V1, 1, ''', 1, ' ', &V1.LENGTH, 'A&V1.LENGTH');
would be an invalid specification


7.6.4
Unix & Windows
Excel,HTML,PDF,PPT,AHTML


January 03, 2010, 07:45 PM
Dan Satchell
Try this code. The STRIP function is used to remove the single quotes. STRREP does not like the + sign so I replaced 'AND' with '^', then used CTRAN to replace the '^' with '+'. I used a length of 100, but you should adjust this length to the maximum expected length of your input string. Also be aware that the output length for STRREP must be longer than the input length.

-SET &STR1 = '''X1'' AND ''X2'' AND ''X3''';
-SET &LEN1 = ARGLEN(100,&STR1,'I2');
-SET &STR2 = STRIP(&LEN1,&STR1,'''','A&LEN1');
-SET &STR3 = STRREP(&LEN1,&STR2,3,'AND',1,'^',100,'A100');
-SET &STR4 = CTRAN(100,&STR3,94,43,'A100');



WebFOCUS 7.7.05
January 03, 2010, 08:04 PM
Waz
Working on a Sunday. thats dedication.
Smiler


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!

January 04, 2010, 02:07 AM
Tony A
quote:
Working on a Sunday. thats dedication
... or boredom!

Happy New Year all

T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
January 04, 2010, 05:47 AM
Dan Satchell
quote:
... or boredom!


Tony is closer to the mark. While awaiting the appointed hour to perform my duty as parental chauffeur it came down to a choice between an interesting Focal Point problem and the mindless drivel they call entertainment on the telly.


WebFOCUS 7.7.05