Focal Point Banner


As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only.

Join the TIBCO Community
TIBCO Community is a collaborative space for users to share knowledge and support one another in making the best use of TIBCO products and services. There are several TIBCO WebFOCUS resources in the community.

  • From the Home page, select Predict: WebFOCUS to view articles, questions, and trending articles.
  • Select Products from the top navigation bar, scroll, and then select the TIBCO WebFOCUS product page to view product overview, articles, and discussions.
  • Request access to the private WebFOCUS User Group (login required) to network with fellow members.

Former myibi community members should have received an email on 8/3/22 to activate their user accounts to join the community. Check your Spam folder for the email. Please get in touch with us at community@tibco.com for further assistance. Reference the community FAQ to learn more about the community.


Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Search and Replace

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[CLOSED] Search and Replace
 Login/Join
 
Member
posted
Hi,

Does anyone have a little routine that performs and search and replace on a string?
I have a string that looks something like this:
'a OR b OR c OR d OR e'
and I want to replace the OR with a comma...
I tried to write my own search and replace but am having problems with substr padding my strings and I couldn't remove the padding...

Thanks!

-Daniel.,

This message has been edited. Last edited by: <Kathryn Henning>,
 
Posts: 20 | Registered: April 05, 2006Report This Post
Guru
posted Hide Post
Are you trying to do this in DM or a TABLE FILE?
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Report This Post
Master
posted Hide Post
Here is the code, I did in both ways.
using dialogue manager and using Define.

-SET &TESTVAR='A OR B OR C OR D';
-SET &DECVAL=BYTVAL('O','I3');
-SET &DECVAL1=BYTVAL('R','I3');
-SET &CHGTVAR=CTRAN(50,&TESTVAR,&DECVAL,44,'A50');
-SET &CHGTVAR1=CTRAN(50,&CHGTVAR,&DECVAL1,32,'A50');


DEFINE FILE CAR
TESTVAR/A50='A OR B OR C OR D';
DECVAL/I3=BYTVAL('O','I3');
DECVAL1/I3=BYTVAL('R','I3');
-*CTRAN(charlen, string, decimal, decvalue, outfield)
CHGTVAR/A50=CTRAN(50,TESTVAR,DECVAL,44,CHGTVAR);
CHGTVAR1/A50=CTRAN(50,CHGTVAR,DECVAL1,32,CHGTVAR1);
END

TABLE FILE CAR
HEADING
" <TESTVAR "
" <CHGTVAR1 "
" TESTVAR AMP : &TESTVAR "
" CHGVAR AMP : &CHGTVAR1 "
PRINT *
WHERE RECORDLIMIT EQ 10
END
-EXIT


I'm not sure whether we have a function to do this. We may have it.


WFConsultant

WF 8105M on Win7/Tomcat
 
Posts: 780 | Location: Florida | Registered: January 09, 2005Report This Post
Member
posted Hide Post
Thank you for your reply Kamesh,

Do you have a more generic version of the code that will not replace Os and Rs with commas and spaces as my terms may contain those letters?
I want something like replace ' OR ' with ', '

Thanks.

-Daniel.,
 
Posts: 20 | Registered: April 05, 2006Report This Post
Virtuoso
posted Hide Post
Can I ask what you are trying to do with the final changed string?


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
 
Posts: 1102 | Location: Toronto, Ontario | Registered: May 26, 2004Report This Post
Member
posted Hide Post
Thank you for your inquiry.
I will be displaying the transformed string in the header.

-Daniel.,
 
Posts: 20 | Registered: April 05, 2006Report This Post
Expert
posted Hide Post
dtrang, check out the OVRLAY function in your WebFocus Using Functions Manual.
just the ticket.




In Focus since 1979///7706m/5 ;wintel 2008/64;OAM security; Oracle db, ///MRE/BID
 
Posts: 3811 | Location: Manhattan | Registered: October 28, 2003Report This Post
Platinum Member
posted Hide Post
Hey thanks , susannah , i'v never came across that function before

Cool !!

P.


D: WF 7.6.2 P. : WF 7.6.2 on W2003
------------------------------------------------------------------
I see myself as an intelligent, sensitive human, with the soul of a clown which forces me to blow it at the most important moments.

-Jim Morrison-

 
Posts: 206 | Registered: February 25, 2005Report This Post
Virtuoso
posted Hide Post
Learn something new everyday. Wink


In Focus since 1993. WebFOCUS 7.7.03 Win 2003
 
Posts: 1903 | Location: San Antonio | Registered: February 28, 2005Report This Post
Gold member
posted Hide Post
Has anybody done the code for a generic-search-and-replace function ?

-* Replace occurances of P2 in P1 with P3
-*
DEFINE FUNCTION SREPLACE/A255(P1 A255, P2 A255, P3 A255)
 ...
 ...
END


I was about to implement it but I could not find the syntax for
REPEAT/GOTO anywhere. Any idea ?

BTW, my requirement is exactly same as the requirement in this
thread. I am trying to convert the webfocus's javascript generated
code of following kind -

WHERE V1 EQ 'A' OR 'B' OR 'C';

into -

WHERE V1 IN ('A','B','C');

so that I can plug it directly into DB2 SQL.

This message has been edited. Last edited by: Govind Jujare,


WebFOCUS 5.3.3 MRE - Solaris - Sun Web Server - Weblogic
 
Posts: 85 | Registered: December 20, 2005Report This Post
Platinum Member
posted Hide Post
Working on WebFOCUS 7, we can use STRREP function:

STRREP Function: Replacing Character Strings
(documented as 7.1.3 new feature)

Simple D.M. Example tested with WF 7.1.0 & 7.1.1:
-SET &V1 = 'a OR b OR c OR d OR e' ;
-SET &V2 = STRREP(&V1.LENGTH, &V1, 4, ' OR ', 1, ',', &V1.LENGTH, 'A&V1.LENGTH');
-TYPE V1= &V1
-TYPE V2= &V2

Output:
V1= a OR b OR c OR d OR e 
V2= a,b,c,d,e

Regards,
Mikel


WebFOCUS 8.1.05, 8.2.01
 
Posts: 173 | Location: Madrid, Spain | Registered: May 09, 2003Report This Post
Member
posted Hide Post
Thanks Mikel!
That function works nicely.
Why isn't it documented in developer studio's help?

Thanks again!
 
Posts: 20 | Registered: April 05, 2006Report This Post
Expert
posted Hide Post
Just for info, and with the usual overrides, this also works in 5.3.2 on Windows. Just be careful that as it is quoted as a new feature as of 7, that this may not be supported in earlier versions even though it appears to function.

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Gold member
posted Hide Post
I tested it just now on 5.3.3 and yes it worked. Thx for the tip. That helped me avoid a whole bunch of coding.


WebFOCUS 5.3.3 MRE - Solaris - Sun Web Server - Weblogic
 
Posts: 85 | Registered: December 20, 2005Report This Post
Gold member
posted Hide Post
Hi All,
How can we use STRREP function in a DEFINE against a field not against a variable?

Regards,
Johney.


Version 7.6.11
Webfocus installed in AIX 5.3,
desktop PC: Windows-XP based
Output: Excel, HTML, PDF
 
Posts: 83 | Registered: October 19, 2007Report This Post
Expert
posted Hide Post
Johney,

The link in Mikel's post above will give you all the detail you require.

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 
 
Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004Report This Post
Member
posted Hide Post
Was trying to use this for multiselect in Teradata
But this solution breaks when the variable didnt have OR

-SET &V1 = 'a' ;
-SET &V2 = STRREP(&V1.LENGTH, &V1, 4, ' OR ', 1, ',', &V1.LENGTH, 'A&V1.LENGTH');
-TYPE V1= &V1
-TYPE V2= &V2


Raj
 
Posts: 1 | Registered: August 11, 2008Report This Post
<Kathryn Henning>
posted
Hi Rajkurien,

Welcome to Focal Point!

Does your data contain OR values? In the example above, that is the value being replaced. Please see the documentation link in Mikel's comments above. The fourth parameter is the character string to be replaced.

Thanks and regards,

Kathryn
 
Report This Post
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [CLOSED] Search and Replace

Copyright © 1996-2020 Information Builders