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     Extracting a given number of characters from a string

Read-Only Read-Only Topic
Go
Search
Notify
Tools
Extracting a given number of characters from a string
 Login/Join
 
Silver Member
posted
I have a 80 character field that I need to extract the last 15 positions (minus the peroid). For example, within - "xwzo abcde ghig - nbnbc uucucb 12345678-0728." I need to extract "12345678-0728" only. What can be entered into this field is dynamic but what is a constant is I need the last 13 positions minus the period. I looked at the "GETTOK" function but it didn't work. Any Ideas? Thanks Smiler
 
Posts: 31 | Registered: November 17, 2005Report This Post
Virtuoso
posted Hide Post
If the position within the 80-character field is fixed, all you need is SUBSTR, with appropriate (integer) arguments for start and end position and length of the portion to extract.

If location varies, and you want the tail end of the text, use ARGLEN to locate the end, and fashion expresions for the start/end column arguments accordingly.


- Jack Gross
WF through 8.1.05
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Expert
posted Hide Post
As Jack says, ARGLEN to find the length of the text if it isn't fixed and 80 chars.

You could also use RJUST and SUBSTR or REVERSE / SUBSTR or EDIT / REVERSE.

Check out the WebFOCUS Functions documentation, there is quite a few string fucntions available.


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!

 
Posts: 6347 | Location: 33°49'23.0"S, 151°11'41.0"E | Registered: October 31, 2006Report This Post
Expert
posted Hide Post
Denny,

I would go for the REVERSE function and I suggested a method in this topic - "Function for getting right two characters" last year, but there are earlier suggestions of a similar process from previous years.

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
Virtuoso
posted Hide Post
Alternatively, you could solve this in your master file, provided the part you're interested in is always the last so many positions.
The way to do this is to make this 80 character field a group field, and then create three fields in that group field: a field that hold the first 65 positions, next a field for the 14 you want, and last a field for the period.
That way, just referencing the field will give you the portion you want, in stead of having to resort to functions to do the same thing.
Mind you, this is only going to work if positions are fixed.

Hope this helps ...


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report This Post
Virtuoso
posted Hide Post
Also, you might use POSIT (check spelling) to find the period and calculate your start and end to use the substrn function.


Leah
 
Posts: 1317 | Location: Council Bluffs, IA | Registered: May 24, 2004Report This Post
Expert
posted Hide Post
No different from what everyone else has already said, i'ld go REVERSE/SUBSTRing/REVERSE
maybe with a POSIT before the SUBSTR, just to be sure.
i think i remember having ageda last year
with RJUST/SUBSTR
for some reason, the RJUST just wouldn't do what i expected it to, i don't remember why.
but the REVERSE was the bomb!




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
Gold member
posted Hide Post
I'm thinking maybe the "REVERSE" or "RJUST" functions may not trim trailing spaces ?
That would make the "last" characters NOT be what you had expected, so "TRIM" the string first ?

I like the idea of re-defining the field with overlaying sub-fields, IFF the SUBSTR you want is fixed.
It also saves a lot of processing time (i.e.: fewer function calls for all those SUBSTR, RJUST, POSIT, etc.)

I may post another separate request for info on a way to re-FIELD a records (is that called a "sub-mask" ?)

Thanks for a wealth of information from everyone !


WF 7.6.4 & 5.3
Charles Lee
 
Posts: 93 | Registered: June 17, 2008Report This Post
Expert
posted Hide Post
Charlz,

If you read the link I posted above and also the inference by Waz, you will see that ARGLEN is used to obtain the "real" length of the incoming data so the string that is reversed is stripped of trailing blanks first. That way you are controling what you achieve.

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
Tony A,

Yes, although it wasn't clear if the ARGLEN automatically TRIMmed the string, and I was trying to avoid all that processing needed for multiple function calls.

Thanks for the link to your previous post, which answered this, ++ PLUS ++ answered a question about functions I was going to ask, and now I don't have to !

Thanks !


WF 7.6.4 & 5.3
Charles Lee
 
Posts: 93 | Registered: June 17, 2008Report This Post
Virtuoso
posted Hide Post
Denny seems to be overwhelmed by all the answers. I hope one of the answers solved his problem.

The answer GamP has given is for me an interesting one. I'm going to use it in one of my masters. Thx Gerard!




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

 
Posts: 2387 | Location: Amsterdam, the Netherlands | Registered: December 03, 2006Report This Post
Virtuoso
posted Hide Post
You're welcome Frank, always glad to be of help.


GamP

- Using AS 8.2.01 on Windows 10 - IE11.
in Focus since 1988
 
Posts: 1961 | Location: Netherlands | Registered: September 25, 2007Report 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     Extracting a given number of characters from a string

Copyright © 1996-2020 Information Builders