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     How to get multiple string variables from a parameter? [SOLVED]

Read-Only Read-Only Topic
Go
Search
Notify
Tools
How to get multiple string variables from a parameter? [SOLVED]
 Login/Join
 
Member
posted
Need help!

How can I get multiple variables from a parameter where the "OR" string is the delimiter. eg stringA is "'ADMT_SRC' OR 'ADMT_SRC_D' OR 'ADMT_TYPE' OR 'ADMT_TYP_D' OR 'AGE' OR 'AGEGRP'" I would like to get each value separated by the "OR".
I am familiar with looping, but need the string functions to identify the ORs and to parse through each item. Thanks!

This message has been edited. Last edited by: Gerard Cabunoc,
 
Posts: 3 | Registered: August 04, 2009Report This Post
Virtuoso
posted Hide Post
Take a look at the GETTOK function.


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
What's interesting about this is that to use GETTOK you need to know how many OR's there are, and I haven't found a ready-made function for that.


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
Expert
posted Hide Post
If you don't know how many OR's there are, then use a loop until you get nothing.


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
Virtuoso
posted Hide Post
No ready made function, but you could define your own function by calculating the length of a string, then strip out the OR and recalculate the length. The difference (divide by two because OR has two characters in it) would tell you how many there are in a given string.

Then you can


-SET &PARM_CNT=1;
-REPEAT PARM_LOOP WHILE &PARM_CNT LE (number of occurrences of OR);
-SET &PARM&PARM_CNT.EVAL=GETTOK(&parmstring,&parmstring.LENGTH,&PARM_CNT,'OR',length of value,'Alength of value');
-SET &PARM_CNT=&PARM_CNT + 1;
-PARM_LOOP


Regards,

Darin



In FOCUS since 1991
WF Server: 7.7.04 on Linux and Z/OS, ReportCaster, Self-Service, MRE, Java, Flex
Data: DB2/UDB, Adabas, SQL Server Output: HTML,PDF,EXL2K/07, PS, AHTML, Flex
WF Client: 77 on Linux w/Tomcat
 
Posts: 2298 | Location: Salt Lake City, Utah | Registered: February 02, 2007Report This Post
Virtuoso
posted Hide Post
The STRREP function replaces the ' OR ' strings with a single quote ('). I tried a straight GETTOK solution (without STRREP), but GETTOK didn't like having a delimiter string longer than one character. It worked, but not as expected.

-SET &VALS  = '''ADMT_SRC'''|' OR '|'''ADMT_SRC_D'''|' OR '|'''ADMT_TYPE'''|' OR '|'''ADMT_TYP_D'''|' OR '|'''AGE'''|' OR '|'''AGEGRP''';
-SET &VALSX = STRREP(&VALS.LENGTH,&VALS,6,''' OR ''',1,'''',&VALS.LENGTH,'A&VALS.LENGTH');
-*
-REPEAT ENDREPEAT1 FOR &I FROM 1 TO 100
-SET &VAL.&I = GETTOK(&VALSX,&VALSX.LENGTH,&I,'''',15,'A15');
-*TYPE &VAL.&I
-IF &VAL.&I EQ '' GOTO QUITREPEAT1 ;
-ENDREPEAT1
-QUITREPEAT1


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Function to count the occurrence of one string in another:

-*------------------------------------------------------------------------------
-* Module Name    : deffunc_cntchar.fex
-* Description    : DEFINE Function to count the occurrence of a character in a string
-*                  (Can be used in Dialogue Manager or DEFINE or COMPUTE)
-* Developed by   : Francis Mariani - Francis Mariani Inc.
-* Date Developed : March 3, 2010
-*
-* How to count the occurrence of a character in a string
-*
-*   CNTCHAR(string1, string2)
-*     where:
-*       string1 (Alphanumeric, max 600)
-*         Is an alphanumeric string, or field in which the character will be counted.
-*       string2 (Alphanumeric, max 10)
-*         Is an alphanumeric string, or field that will be counted.
-*
-* Example: Counting occurrences of a character in a string
-*
-* -SET &STR1 = 'AAA-AAAA AAAA-W OR WW RRRR FF OR FF-FFFFF';
-* -SET &STR2 = '-';
-* -SET &COUNT = CNTCHAR(&STR1,&STR2);
-*
-* Documentation: Creating Reports With WebFOCUS Language
-*                  Creating Temporary Fields
-*                    Creating Temporary Fields Unrelated to Master Files
-*
-*------------------------------------------------------------------------------
-*                 Maintenance History
-*------------------------------------------------------------------------------
-* Modified by   :
-* Date Modified :
-* Reason        :
-* Change ID     :
-*------------------------------------------------------------------------------

DEFINE FUNCTION CNTCHAR(INSTRING1/A600, INSTRING2/A10)
-* Determine the non-blank length of the input string
-*   (If the string to be counted is not blank, strip the blank
-*    characters in the input string before determining the length)
INSTRLEN/D4  = IF INSTRING2 EQ ' ' THEN ARGLEN(600, INSTRING1, 'D4') ELSE ARGLEN(600, STRIP(600, INSTRING1, ' ', 'A600'), 'D4');
-* Convert the string to be counted in the input string to blank
INSTRING2LEN/I4 = IF INSTRING2 EQ ' ' THEN 1 ELSE ARGLEN(10, INSTRING2, 'I4');
OUTSTR1/A600 = STRREP(600, INSTRING1, INSTRING2LEN, INSTRING2, 1, ' ', 600, 'A600');
-* Strip the blanks out of the string (the blanks represent the string to be counted)
OUTSTR2/A600 = STRIP(600, OUTSTR1, ' ', OUTSTR2);
-* Determine the length of the string without the blanks
OUTSTRLEN/D4 = ARGLEN(600, OUTSTR2, 'D4');
-* Determine the number of blanks in the string by subtracting the length of the string
-* without the blanks from the length of the input string - this gives us the count of the string
CNTCHAR/D4   = (INSTRLEN - OUTSTRLEN) / INSTRING2LEN;
END
-RUN

Save this code in a file in an Application Folder, then -INCLUDE it whenever you need it.

Dialogue Manager Example:

-SET &STR = 'AAA-AAAA AAAA-W OR WW RRRR FF OR FF-FFFFF';

-SET &SSTR1 = '-';
-SET &COUNT1 = CNTCHAR(&STR,&SSTR1);

-SET &SSTR2 = ' ';
-SET &COUNT2 = CNTCHAR(&STR,&SSTR2);

-SET &SSTR3 = 'OR';
-SET &COUNT3 = CNTCHAR(&STR,&SSTR3);

-SET &SSTR4 = 'F';
-SET &COUNT4 = CNTCHAR(&STR,&SSTR4);

-TYPE STRING: &STR
-TYPE COUNT OF '&SSTR1' : &COUNT1
-TYPE COUNT OF '&SSTR2' : &COUNT2
-TYPE COUNT OF '&SSTR3' : &COUNT3
-TYPE COUNT OF '&SSTR4' : &COUNT4


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
Virtuoso
posted Hide Post
Francis,

Very nice job. But if I use your sample string and enter ' OR ' for the search string (to differentiate it from 'OR' characters that might be embedded elsewhere in the string), it comes back with a count of 1 instead of 2?


WebFOCUS 7.7.05
 
Posts: 1213 | Location: Seattle, Washington - USA | Registered: October 22, 2007Report This Post
Expert
posted Hide Post
Dan, yes, the ' OR ' doesn't work - I haven't tried hard enough to make that work - I'm sure I can, but I quickly adapted a DEFINE FUNCTION that searched for a character into one that searched for a string...


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
Expert
posted Hide Post
OK, let's give this a try:

DEFINE FUNCTION CNTSTR(INSTRING1/A600, INSTRING2/A10, INSTRING2LEN/I4)

INSTRING1LEN/I4 = IF INSTRING1 EQ ' ' THEN 1 ELSE ARGLEN(600, INSTRING1, 'I4');
INSTRING1LENA/A8 = 'A' | EDIT(INSTRING1LEN);
INSTRING2LENA/A8 = 'A' | EDIT(INSTRING2LEN);

INSTRING1A/A600 = CTRAN(600, INSTRING1, BYTVAL(' ','I3'), BYTVAL('^','I3'), INSTRING1A);
INSTRING2A/A10  = CTRAN( 10, INSTRING2, BYTVAL(' ','I3'), BYTVAL('^','I3'), INSTRING2A);

INSTRING1B/A600 = SUBSTR(600, INSTRING1A, 1, INSTRING1LEN, INSTRING1LEN, INSTRING1B);
INSTRING2B/A600 = SUBSTR( 10, INSTRING2A, 1, INSTRING2LEN, INSTRING2LEN, INSTRING2B);

OUTSTR1/A600 = STRREP(600, INSTRING1B, INSTRING2LEN, INSTRING2B, 1, ' ', 600, 'A600');
OUTSTR2/A600 = STRIP(600, OUTSTR1, ' ', OUTSTR2);

CNTSTR/D4   = (INSTRING1LEN - ARGLEN(600, OUTSTR2, 'D4')) / INSTRING2LEN;
END
-RUN

Test:

-SET &STR = 'AAA-AAAA AAAA-W OR WW RRRR FF OR FF-FFORF';
-SET &SSTR1 = '-';

-SET &COUNT1 = CNTSTR(&STR,&SSTR1,&SSTR1.LENGTH);

-SET &SSTR2 = ' ';
-SET &COUNT2 = CNTSTR(&STR,&SSTR2,&SSTR2.LENGTH);

-SET &SSTR3 = ' OR ';
-SET &COUNT3 = CNTSTR(&STR,&SSTR3,&SSTR3.LENGTH);

-SET &SSTR4 = 'F';
-SET &COUNT4 = CNTSTR(&STR,&SSTR4,&SSTR4.LENGTH);

-SET &SSTR5 = 'OR';
-SET &COUNT5 = CNTSTR(&STR,&SSTR5,&SSTR5.LENGTH);

-TYPE STRING: &STR
-TYPE COUNT OF '&SSTR1' : &COUNT1
-TYPE COUNT OF '&SSTR2' : &COUNT2
-TYPE COUNT OF '&SSTR3' : &COUNT3
-TYPE COUNT OF '&SSTR4' : &COUNT4
-TYPE COUNT OF '&SSTR5' : &COUNT5

I'm testing for " OR " and "OR"...


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
Virtuoso
posted Hide Post
To allow for significant trailing blanks, change the parameter list -- either add a length parameter for the second string, or require the second string to include leading and trailing delimiters (e.g., '/ OR /' for the problem presented in this topic)


- 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
Thanks Jack, I decided on the length for the second string.


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
Member
posted Hide Post
Really awesome...
Thanks for all the help guys! This solved my problem.


WebFOCUS 7.6
Windows 2000 Server, Windows XP
Output: HTML, XLS, PDF, Delimited Flat File
 
Posts: 3 | Registered: August 04, 2009Report 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     How to get multiple string variables from a parameter? [SOLVED]

Copyright © 1996-2020 Information Builders