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     TRIM function not work for me

Read-Only Read-Only Topic
Go
Search
Notify
Tools
TRIM function not work for me
 Login/Join
 
Guru
posted
I'm trying to use the TRIM function in Dialogue Manager and for some reason its not removing the trailing blanks on the string.


To work around this problem I did this:
-SET &TOKEN = '''' || &TOKEN || '''' || ';';
-SET &TOKEN = &TOKEN.EVAL
I have included the none working code and working code. Maybe I'm doing something wrong and someone can tell me what it is.

Also can you see any reason why I should not use my work around.

-TYPE None working code
-* Variable passed by GUI.
-SET &RPT_MULTI = 'Hello People,This is the End';
-*
-* Report variables.
-TYPE RPT_MULTI: &RPT_MULTI
-SET &LP_STEP = 1;
-SET &INDX = 1;
-RUN
-*
-* Find the number of Report Tokens in the string.
-REPEAT :RPT_TOK1 WHILE &LP_STEP NE -1;
-SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20');
-SET &TOKEN = TRIM('B', &TOKEN, 20, ' ', 1, 'A20');
-TYPE > &TOKEN <
-SET &INDX_CUR = &LP_STEP - 1;
-SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1;
-:RPT_TOK1
-*
-SET &INDX_RPT = &INDX_CUR;
-TYPE Number of RPT: &INDX_RPT
-TYPE Working code.
-* Variable passed by GUI.
-SET &RPT_MULTI = 'Hello People,This is the End';
-*
-* Report variables.
-TYPE RPT_MULTI: &RPT_MULTI
-SET &LP_STEP = 1;
-SET &INDX = 1;
-RUN
-*
-* Find the number of Report Tokens in the string.
-REPEAT :RPT_TOK2 WHILE &LP_STEP NE -1;
-SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20');
-SET &TOKEN = '''' || &TOKEN || '''' || ';';
-SET &TOKEN = &TOKEN.EVAL
-TYPE > &TOKEN <
-SET &INDX_CUR = &LP_STEP - 1;
-SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1;
-:RPT_TOK2
-*
-SET &INDX_RPT = &INDX_CUR;
-TYPE Number of RPT: &INDX_RPT

This message has been edited. Last edited by: <Maryellen>,
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Report This Post
Guru
posted Hide Post
I agree, TRIM does not seem to work in DM, but you might try this.

-SET &STR = 'THIS IS A STRING ';
-SET &LEN = ARGLEN(&STR.LENGTH,&STR,'I2');
-SET &STR2 = SUBSTR(&LEN,&STR,1,&LEN,&LEN,'A|&LEN');

/H�kan
 
Posts: 319 | Location: Stockholm, Sweden | Registered: February 04, 2004Report This Post
Virtuoso
posted Hide Post
TRIM "works" -- it's just that the Format argument stretches the result back to a fixed length.

ARGLEN + SUBSTR (with 'A&LEN.EVAL' to make the format dynamic) overcomes that, as HL noted.
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Guru
posted Hide Post
I forgot about ARGLEN.


I modified the code to us TRIM and ARGLEN and it now works fine.

-* Variable passed by GUI.
-SET &RPT_MULTI = 'Hello People,This is the End';
-*
-* Report variables.
-TYPE RPT_MULTI: &RPT_MULTI
-SET &LP_STEP = 1;
-SET &INDX = 1;
-RUN
-*
-* Find the number of Report Tokens in the string.
-REPEAT :RPT_TOK1 WHILE &LP_STEP NE -1;
-SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20');
-SET &LEN = ARGLEN(&TOKEN.LENGTH,&TOKEN,'I2');
-SET &TOKEN = TRIM('B', &TOKEN, 20, ' ', 1, 'A&LEN.EVAL');
-TYPE > &TOKEN <
-SET &INDX_CUR = &LP_STEP - 1;
-SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1;
-:RPT_TOK1
-*
-SET &INDX_RPT = &INDX_CUR;
-TYPE Number of RPT: &INDX_RPT

This message has been edited. Last edited by: <Maryellen>,
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Report This Post
Expert
posted Hide Post
quote:
How to Remove Leading and Trailing Occurrences
TRIM(trim_where, string, string_length, pattern, pattern_length,
outfield)
where:
trim_where
Alphanumeric
Is one of the following, which indicates where to remove the pattern:
'L' removes leading occurrences.
'T' removes trailing occurrences.
'B' removes both leading and trailing occurrences.
string
Alphanumeric
Is the source character string enclosed in single quotation marks, or the field
containing the string.
string_length
Integer
Is the length of the string in characters.
pattern
Alphanumeric
Is the pattern to remove enclosed in single quotation marks.
pattern_length
Integer
Is the number of characters in the pattern.
outfield
Alphanumeric
Is the field to which the result is returned, or the format of the output value enclosed in
single quotation marks.
In Dialogue Manager, the format must be specified.
That last line from the documentation seems to defeat the purpose of the function.
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Guru
posted Hide Post
Mickey PM'ed me last night and asked why I was not using the function TRUNCATE. I don't know why I did not think of it?


Here is the updated code using TRUNCATE:
-* Variable passed by GUI.
-SET &RPT_MULTI = 'Hello People,This is the End';
-*
-* Report variables.
-TYPE RPT_MULTI: &RPT_MULTI
-SET &LP_STEP = 1;
-SET &INDX = 1;
-RUN
-*
-* Find the number of Report Tokens in the string.
-REPEAT :RPT_TOK1 WHILE &LP_STEP NE -1;
-SET &TOKEN = GETTOK(&RPT_MULTI,&RPT_MULTI.LENGTH,&LP_STEP,',',&RPT_MULTI.LENGTH,'A20');
-SET &TOKEN = TRUNCATE(&TOKEN);
-TYPE > &TOKEN <
-SET &INDX_CUR = &LP_STEP - 1;
-SET &LP_STEP = IF &TOKEN EQ '' THEN -1 ELSE &LP_STEP + 1;
-:RPT_TOK1
-*
-SET &INDX_RPT = &INDX_CUR;
-TYPE Number of RPT: &INDX_RPT
This really makes the code a lot cleaner and easier to read.

Well I don't know what I was programming yesterday but it was not FOCUS.

This message has been edited. Last edited by: <Maryellen>,
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Report This Post
Expert
posted Hide Post
I guess TRUNCATE is a new function in 7.1.

It will be years before my client will be upgrading.
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Expert
posted Hide Post
Correction!

It's just not documented.

I did not find any reference to the TRUNCATE function in the PDF documentation for WebFOCUS 5.3.2 Functions, but it's there in the Developing Application PDF documentation.

I learnt something new today.
 
Posts: 10577 | Location: Toronto, Ontario, Canada | Registered: April 27, 2005Report This Post
Guru
posted Hide Post
I believe this function will work in WF 4.3. But don't hold me too it, I remember it from a couple years back.

Here is a link to some doc.
http://techsupport.informationbuilders.com/tech/ibm/ibm_nf_nf778.html
 
Posts: 406 | Location: Canada | Registered: May 31, 2004Report This Post
Virtuoso
posted Hide Post
Not in 4.3.1 (at least, not my client's copy):

(FOC263) EXTERNAL FUNCTION OR LOAD MODULE NOT FOUND: TRUNCATE
 
Posts: 1925 | Location: NYC | In FOCUS since 1983 | Registered: January 11, 2005Report This Post
Gold member
posted Hide Post
I recently came across this problem and follg worked for me -

-*Remove Leading. Only 'L' worked. The 'B' and 'T' didnt work.
-SET &pSTR= TRIM('L',&pSTR,64,' ',1,'A64');
-*Remove Trailing
-SET &pSTR= TRUNCATE(&pSTR);


WebFOCUS 5.3.3 MRE - Solaris - Sun Web Server - Weblogic
 
Posts: 85 | Registered: December 20, 2005Report 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     TRIM function not work for me

Copyright © 1996-2020 Information Builders