Focal Point
[SOLVED] Simple Trim Function help

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/7087007606

July 11, 2011, 09:09 AM
Jason K.
[SOLVED] Simple Trim Function help
I'd like to trim space characters from the beginning and end of a variable. I looked over the documentation for TRIM and I'm not sure what I'm doing wrong. This is the first time I've tried to use the TRIM function. See below...

-DEFAULT &INJK = ' KLAUS ';
-SET &INJK2 = TRIM('B',&INJK,&INJK.LENGTH,' ',1,'A&INJK.LENGTH');

The value and length of the INJK2 variable is the exact same as the INJK variable. The TRIM function as I put it in isn't doing anything at all!

Any ideas on what I missed?

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


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.
July 11, 2011, 10:11 AM
Dave
Yes...

The last argument is the output length.
You tell it to be INJK.LENGTH in length.

What happens is ( I use · as space marker in this sample )

You start with a probably German guy named:
·KLAUS·

You end up with KLAUS
And then you put it in a 7 char long variable. Extra room is filled with spaces:
KLAUS··


That's what is happening...


_____________________
WF: 8.0.0.9 > going 8.2.0.5
July 11, 2011, 10:16 AM
Francis Mariani
One possibility - left-justify, then truncate:

-SET &TEST1 = '      FRANCIS     ';
-SET &TEST2 = LJUST(&TEST1.LENGTH, &TEST1, 'A&TEST1.LENGTH');

-SET &TEST3 = TRUNCATE(&TEST2);

-TYPE &TEST1 &TEST1.LENGTH
-TYPE &TEST2 &TEST2.LENGTH
-TYPE &TEST3 &TEST3.LENGTH



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
July 11, 2011, 10:38 AM
Jason K.
Thanks Francis! Works great now!


Prod: Single Windows 2008 Server running Webfocus 7.7.03 Reporting server Web server IIS6/Tomcat, AS400 DB2 database.