Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Substring parameter into multiple parameters
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] Substring parameter into multiple parameters
 Login/Join
 
Platinum Member
posted
Hi,

Does anyone no how to split one parameter into multiple parameters.

Excample :

Input : &WEEKNUMBERS = 01 OR 06 OR 10 OR 11
Output: &WEEKNUMBER01 = 01
&WEEKNUMBER02 = 06
&WEEKNUMBER03 = 10
&WEEKNUMBER04 = 11

Thanks Mark

This message has been edited. Last edited by: FP Mod Chuck,


8
Windows XP
HTML
SQL
 
Posts: 102 | Registered: March 18, 2008Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Hi

You can use the GETTOK function.

Example
-* 2017-10-18 - Split var based +1 char delimiter.

-DEFAULTH &STR = '01 OR 06 OR 10 OR 11' ;
-DEFAULTH &DEL = ' OR ' ;

-TYPE String...: '&STR'
-TYPE Delimiter: '&DEL'

-* Use 1 char delimiter, comma for example.
-SET &LEN = &STR.LENGTH ;
-SET &STR = STRREP (&LEN, &STR, &DEL.LENGTH, &DEL, 1, ',', &LEN, 'A&LEN.EVAL') ;
-SET &STR = TRUNCATE(&STR);
-SET &LEN = &STR.LENGTH ;

-* Tokens extraction loop.
-SET &I = 0 ;
-SET &SUB = 'X' ;
-REPEAT :LOOPEND WHILE &SUB NE ' ' ;
-SET &I = &I + 1 ;
-SET &SUB = GETTOK(&STR, &LEN, &I, ',', &LEN, 'A&LEN');
-SET &SUB = TRUNCATE(&SUB) ;
-SET &SUB.&I = &SUB ;
-TYPE Substr &I : &SUB.&I
-:LOOPEND


Output
String...: '01 OR 06 OR 10 OR 11'
Del......: ' OR '
Substr 1 : 01
Substr 2 : 06
Substr 3 : 10
Substr 4 : 11
Substr 5 :


Regards. Mikel.


WebFOCUS 8.1.05, 8.2.01
 
Posts: 173 | Location: Madrid, Spain | Registered: May 09, 2003Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Hi Mikel,

Thanks exactly what I needed.

Kind Regards

Mark


8
Windows XP
HTML
SQL
 
Posts: 102 | Registered: March 18, 2008Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Using WF8 you can also use TOKEN function. It's a little more simplest then GETTOK but do the same.


WF 7.7.05M, 8.1.05M, 8.2.0.1M Windows, HTML, Excel
In Focus since 2007
 
Posts: 1542 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Expert
posted Hide Post
I like the new TOKEN function better than GETTOK Smiler
 
Posts: 2451 | Location: TN: Nashville Area | Registered: February 23, 2005Reply With QuoteReport This Post
Platinum Member
posted Hide Post
Doug,

I was working with Token function in WF 8105
and I replaced GETTOK function with TOKEN in Mikel's code it shows error
quote:
(FOC36355) INVALID TYPE OF ARGUMENT #3 FOR USER FUNCTION TOKEN


 
 -DEFAULTH &STR = '01 OR 06 OR 10 OR 11' ;
-DEFAULTH &DEL = ' OR ' ;

-TYPE String...: '&STR'
-TYPE Delimiter: '&DEL'

-* Use 1 char delimiter, comma for example.
-SET &LEN = &STR.LENGTH ;
-SET &STR = STRREP (&LEN, &STR, &DEL.LENGTH, &DEL, 1, ',', &LEN, 'A&LEN.EVAL') ;
-SET &STR = TRUNCATE(&STR);
-SET &LEN = &STR.LENGTH ;

-* Tokens extraction loop.
-SET &I = 0 ;
-SET &SUB = 'X' ;
-REPEAT :LOOPEND WHILE &SUB NE ' ' ;
-SET &I = &I + 1 ;
-*-SET &SUB = GETTOK(&STR, &LEN, &I, ',', &LEN, 'A&LEN');
-SET &SUB = TOKEN(&STR, ',' ,&I );
-SET &SUB = TRUNCATE(&SUB) ;
-SET &SUB.&I = &SUB ;
-TYPE Substr &I : &SUB.&I
-:LOOPEND


It seems that we can not pass Parameter value in number place.

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


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10
 
Posts: 177 | Location: Infobuild India | Registered: August 28, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
I just tried your code in 8.2.01M and it worked. Which version did you test in?


WebFOCUS 8203, Unix, Windows
 
Posts: 997 | Location: New York City | Registered: December 30, 2015Reply With QuoteReport This Post
Virtuoso
posted Hide Post
Perform this small change as for WF8105 to work :

-SET &SUB = TOKEN(&STR, ',' ,&I.EVAL);


WF 7.7.05M, 8.1.05M, 8.2.0.1M Windows, HTML, Excel
In Focus since 2007
 
Posts: 1542 | Location: Montreal Area, Qc, CA | Registered: September 25, 2013Reply With QuoteReport This Post
Platinum Member
posted Hide Post
quote:
I just tried your code in 8.2.01M and it worked. Which version did you test in?

BabakNYC I was trying it in WF8105M


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10
 
Posts: 177 | Location: Infobuild India | Registered: August 28, 2015Reply With QuoteReport This Post
Platinum Member
posted Hide Post
quote:
Perform this small change as for WF8105 to work :

-SET &SUB = TOKEN(&STR, ',' ,&I.EVAL);



Thanks Martin in WF8105 it works with "EVAL"


WF Production :- WF:8.0.0.4, 8.1.05 App-studio/Developer Studio(8.1.x) ,
8.2.0.1M , 8.2.0.2 (App-Studio8.2.x),
InfoAssist/+, InfoDiscovery
Output format:-AHTML, PDF, Excel, HTML
Platform:-Windows 7, 8,10
 
Posts: 177 | Location: Infobuild India | Registered: August 28, 2015Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] Substring parameter into multiple parameters

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.