Normal Topic Truncate lines in a report (Read 876 times)
debmckee
Full Member
***
Offline



Posts: 123
Joined: Oct 5th, 2011
Truncate lines in a report
Nov 17th, 2011 at 6:54pm
Print Post Print Post  
Is there a way to truncate your data in a report.  If i set column width it wraps the text.  I want to shorten it or truncate it.
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Truncate lines in a report
Reply #1 - Nov 25th, 2011 at 4:49am
Print Post Print Post  
You could program it using something similar to the following:
Code
Select All
ThisElement = @Left(ThisElement, 12) 


That is a very primative example, but should get you started in the right direction.


This is a much more complex example:
Code
Select All
// ========== BEGIN Custom Text Padding/Trimming Function ==========
// @cuPad(X, N, J)
// Type: Text/String
// Parameters: X as String, N as Integer, J as Integer
// Returns: String

// Returns X padded with N spaces and J justified.
// 1 = Left-Justified
// 2 = Right-Justified
// 3 = Center-Justified

// Examples of usage:

// @cuPad(Name, 32, 1)
// Returns the contents of the Name LE plus enough spaces to make a total of 32 characters,
// and it will be left-justified (i.e. the spaces will be added to the right side).

// @cuPad(@cuDecimals(Amount, 2), 8, 2)
// Returns the string value of Amount plus enough spaces to make a total of 8 characters,
// and it will be right-justified so that the decimals line up.

FUNCTION @cuPad(vStr as String, N as Int, J as Int) as String

Var vA as String
Var vSpcs as Double
Var vLt as Double
Var vRt as Double

If @Len(vStr) <= N
{
	If J = 1
		vA = vStr + @Text(N - @Len(vStr), " ")

	If J = 2
		vA = @Text(N - @Len(vStr), " ") + vStr

	If j = 3
	{
		vSpcs = ( N - @Len(vStr) ) / 2
		vLt = @Int(vSpcs)
		vRt = N - ( vLt + @Len(vStr) )
		vA = @Text(vLt, " ") + vStr + @Text(vRt, " ")
	}
}
Else
	vA = @Left(vStr, N - 2) + ".."

Return vA

END FUNCTION
// ========== END Custom Text Padding/Trimming Function ==========
 

  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged
 
debmckee
Full Member
***
Offline



Posts: 123
Joined: Oct 5th, 2011
Re: Truncate lines in a report
Reply #2 - Nov 28th, 2011 at 3:32pm
Print Post Print Post  
Thank you!  Simple (for me) is always best.  Will try it out!!
  
Back to top
 
IP Logged
 
Carl Underwood
Senior Member
Members
*****
Offline



Posts: 1351
Location: New Hampshire
Joined: Mar 11th, 2003
Re: Truncate lines in a report
Reply #3 - Nov 30th, 2011 at 2:56am
Print Post Print Post  
Whoops. I just noticed that one of the usage examples in the complex example above is using another custom function named @cuDecimals. (I wrote that to avoid some very rare errors that the built-in @Decimals funtion suffers from.)

If anyone wants to use it, you can just remove the "cu" from the @cuDecimals references, or let me know, and I can post my custom version.
  


Carl Underwood
CDU Computer Consulting LLC
Epsom, New Hampshire
Back to top
IP Logged