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     [SOLVED] Can't get Substrings

Read-Only Read-Only Topic
Go
Search
Notify
Tools
[SOLVED] Can't get Substrings
 Login/Join
 
Member
posted
I have a parameter being passed in that looks like:

('1234','4321','2345').First,Last

I want to be able to get everything before the '.' and put it in one variable and put everything after the '.' in another variable.

I have been trying with TRIM, GETTOK, and STRREP. Nothing I have done seems to work.

Any help/suggestion is appreciated.
Thanks!

This message has been edited. Last edited by: Tim Bayer,



------------------------------------
WebFOCUS Version 7.6.2
 
Posts: 17 | Registered: September 08, 2008Report This Post
Expert
posted Hide Post
What is your code like ?

Try this
-SET &Text = '(''1234'',''4321'',''2345'').First,Last' ;

-SET &SubStr = GETTOK(&Text,&Text.LENGTH,1,'.',&Text.LENGTH,'A&Text.LENGTH') ;

-TYPE &SubStr


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
if that's really what your entire character string looks like,
then i would use the POSIT function to determine the exact location of the .
Lets say its 23,then determine the length of the whole string
Lets say its 33
then 2 substring functions
FRONT/A33=SUBSTR(33,input,1,23-1,23-1,'A33');
BACK/A33=SUBSTR(33,input,23+1,33,33-23,'A33')
nb: SUBSTR(inlength, parent, start, end, sublength, outfield)

Hows that?




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
Member
posted Hide Post
Susannah, unfortunately the array of numbers is always changing. Otherwise I think your idea would work.

Waz, I think you have exactly what I'm looking for, except I also need a variable containing the string after the '.' What is the "A&"? I am not familiar with that and I don't see anything in the help docs about it.

I will need something like:
-SET &Text = '(''1234'',''4321'',''2345'').First,Last' ;

-SET &SubStr = GETTOK(&Text,&Text.LENGTH,1,'.',&Text.LENGTH,'A&Text.LENGTH') ;
-SET &SubStr2 = GETTOK(&Text,&Text.LENGTH,1,'.',&Text.LENGTH,'A&Text.LENGTH') ;

-TYPE &SubStr
-TYPE &SubStr2


Where &SubStr2 is the string after the '.'

Thanks for the help.



------------------------------------
WebFOCUS Version 7.6.2
 
Posts: 17 | Registered: September 08, 2008Report This Post
Member
posted Hide Post
It figures as soon as I hit Post, I figure it out Smiler

I needed to use a -1 instead of 1.

-SET &Text = '(''1234'',''4321'',''2345'').First,Last' ;

-SET &SubStr = GETTOK(&Text,&Text.LENGTH,1,'.',&Text.LENGTH,'A&Text.LENGTH') ;
-SET &SubStr2 = GETTOK(&Text,&Text.LENGTH,-1,'.',&Text.LENGTH,'A&Text.LENGTH') ;

-TYPE &SubStr
-TYPE &SubStr2



Thanks again for the help!



------------------------------------
WebFOCUS Version 7.6.2
 
Posts: 17 | Registered: September 08, 2008Report This Post
Expert
posted Hide Post
Tim, if you check out the documentation on GETTOK, you will find that parameter 3 is the position. 2 will get the second item. -1 will get the last.

Susannah,'s suggestion will also work. as POSIT will get the position of the '.', then you can SUBSTRing the before '.' text and after '.' text.


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
quote:
FRONT/A33=SUBSTR(33,input,1,23-1,23-1,'A33');
BACK/A33=SUBSTR(33,input,23+1,33,33-23,'A33')


Of course its always changing...
so first you figure out how long it is.
(this is an &var, yes? so you're not using DEFINE ?)

-SET &HOWLONGISIT = input.LENGTH ;
-SET &WHEREISIT=POSIT(input,'.');
-SET &FRONT = SUBSTR(&HOWLONGISIT,input,1,&WHEREISIT -1, &WHEREISIT -1,'A&HOWLONGISIT.EVAL');
-SET &BACK = SUBSTR (&HOWLONGISIT, input, &WHEREISIT + 1, &HOWLONGISIT, &HOWLONGISIT-&WHEREISIT, ...you figure out the last one. NCIS is on.




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
  Powered by Social Strata  

Read-Only Read-Only Topic

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Can't get Substrings

Copyright © 1996-2020 Information Builders