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.
I'm trying to trim white-space off a string from our database, but it doesn't appear to work.
I have something similar to this:
DEFINE FILE CAR
CR/A1 = HEXBYT(13, 'A1');
LF/A1 = HEXBYT(10, 'A1');
A1/A100V = COUNTRY | ' ';
B1/A100V = COUNTRY | CR;
C1/A100V = COUNTRY | LF;
D1/A100V = COUNTRY | ' '|CR|LF;
A2/A100V = TRIMV('B', A1, 100, ' '|CR|LF, 3, A2) | 'x';
B2/A100V = TRIMV('B', B1, 100, ' '|CR|LF, 3, B2) | 'x';
C2/A100V = TRIMV('B', C1, 100, ' '|CR|LF, 3, C2) | 'x';
D2/A100V = TRIMV('B', D1, 100, ' '|CR|LF, 3, D2) | 'x';
END
TABLE FILE CAR
PRINT A2 B2 C2 D2
ON TABLE PCHOLD FORMAT PDF
ON TABLE SET STYLE *
$
TYPE=REPORT, LINEBREAK='LF',$
ENDSTYLE
END
For some reason the strings don't get trimmed. Does trim actually support patterns, or is it just looking for the substring specified as the "pattern"? In that case the D2 string should have been trimmed, and that doesn't seem to be the case... hmm... Perhaps because COUNTRY isn't actually a VARCHAR field (my real field is)?
How do people trim such strings???This message has been edited. Last edited by: Kerry,
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
For a moment I thought that would be THE solution, but it appears that the concatenation operator stops stripping white-space on encountering a newline (decimal value 10).
Unfortunately I have lines that end in byte sequences of (32 32 10 32 32) sometimes, and the newline characters (either 10 or 13) are really what I wanted to strip off the end of the text, as they kind of mess up the layout.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
That would work if you would know beforehand what specific white-space patterns occur in your data, but that's not usually the case.
I was thinking defining a recursive function would solve the issue, but that it would probably be a pretty big performance hit aside, it seems that DEFINE FUNCTION doesn't support recursion. According to the docs: "DEFINE functions can call other DEFINE functions, but cannot call themselves". I tried and you can't indeed!
Instead we decided to just ignore that there's trailing white-space in our reports, for lack of a proper solution.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
I can't do that, as I do need to keep line-breaks inside the text in my fields. I only need to trim them if they're part of leading or trailing white-space.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
It would appear that readers of this forum aren't familiar with the term "whitespace" and seem to assume that I simply mean space characters (decimal ASCII code 32). The full set of white-space characters (in ASCII, there are some more in other encodings) are codes 9 (tab), 10 (line-feed), 13 (carriage return) and 32 (space).
Any number of consecutive characters from that set in any particular order is considered whitespace.
If that's at the end of my data, I would like to remove it.
quote:
Originally posted by Edward Wolfgram: You have to be careful that the pattern is actually at the end of the field.
That's a problem, as I have no way of knowing the exact pattern beforehand. This is user-entered data which can contain some formatting (that I need to keep!) inside the body of the text.
Trailing spaces (as opposed to whitespace in general) aren't so much of a problem, it's new-lines embedded in those spaces that are causing empty lines between the records in my reports; I don't want those.
quote:
Originally posted by RReeder: Can you use the squeeze function then instead of TRIMV?
SQUEEZ(length, string, outfield)
Not only does that not remove the new-lines I need to get rid of, it will also touch the body of the text and change formatting that the users entered (quite possibly on purpose). My problem is exclusively with leading and trailing whitespace.
WebFOCUS 8.1.03, Windows 7-64/2008-64, IBM DB2/400, Oracle 11g & RDB, MS SQL-Server 2005, SAP, PostgreSQL 11, Output: HTML, PDF, Excel 2010 : Member of User Group Benelux :
Then CTRAN should still work. Change the newline field to something that trimv will not ignore. trim your fields and then ctran it back to newline. Other than that you will just have to tell you customers that the garbage they put in will just have to be put out again.
Along the lines of RReeder's suggestion, this might work - although it ain't elegant. Function PATTERN displays all of the non-printable characters as 'X's. Use function STRREP to replace the 'X's with spaces. Trim spaces from first the front and then both front and back of the string. Determine the lengths of the un-trimmed, trimmed-leading, and trimmed-both strings, and use them to calculate the actual starting position and length of the fully trimmed string. Use function SUBSTV to cut the fully trimmed string from the original string. This method should preserve non-printable characters in the middle of the string.