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     Counting the words in a string

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Counting the words in a string
 Login/Join
 
Virtuoso
posted
Has anyone developed a technique to count the number of words in a string? A blank is the word separator. I would like to create a report that counts the number of words in an A254 field.
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Guru
posted Hide Post
What about using ARGLEN to find out how many characters are in the string, Doing a STRIP to remove all blank spaces, and then doing an ARGLEN again on the result? The difference (plus one) should be the number of words you had.
 
Posts: 391 | Location: California | Registered: April 14, 2003Report This Post
Virtuoso
posted Hide Post
Very slick! I will try this. Thanks!
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Expert
posted Hide Post
Very slick!
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Virtuoso
posted Hide Post
Here is the code for the DEFINE FUNCTION I created using your suggested technique.

DEFINE FUNCTION WORDCNT(THESRCE/A254)
ORG_LEN/I3=ARGLEN(254,THESRCE,'I3');
SHRTVER/A254=STRIP(254,THESRCE,' ','A254');
NEW_LEN/I3=ARGLEN(254,SHRTVER,'I3');
WORDCNT/I3=ORG_LEN - NEW_LEN + 1;
END

TABLE FILE MYFILE
PRINT DESCRIPTION
COMPUTE DESCWORDS/I3=WORDCNT(DESCRIPTION);
END

This works great! Things like a directory structure (c:\inetpub\wwwroot\baseapps) get counted as one word but for my purpoases this is perfect.

Thanks again!

(I'm kind of liking this DEFINE FUNCTION thing.)
 
Posts: 995 | Location: Gaithersburg, MD, USA | Registered: May 07, 2003Report This Post
Gold member
posted Hide Post
and if there are multiple spaces between words? What then?


WF 7.1.6 moving to WF 7.7, Solaris 10, HTML,PDF,XL
 
Posts: 83 | Location: Dartmouth Hitchcock Medical Center | Registered: April 17, 2003Report This Post
Expert
posted Hide Post
Then you could incorporate the SQUEEZ function (Reduce Multiple Spaces to a Single Space)


Francis


Give me code, or give me retirement. In FOCUS since 1991

Production: WF 7.7.05M, Dev Studio, BID, MRE, WebSphere, DB2 / Test: WF 8.1.05M, App Studio, BI Portal, Report Caster, jQuery, HighCharts, Apache Tomcat, MS SQL Server
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report 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     Counting the words in a string

Copyright © 1996-2020 Information Builders