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.
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,
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, 2007
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, 2007
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.
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, 2007
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
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, 2005