Crystal Reports for Eclipse Designer Guide

Length (str)

Length and Len (str) are equivalent functions.
Description
Length returns the number of characters in a text string that you enter into the formula, or in a text string stored as a value in a data field.
Arguments
  • str is a text string.
  • Returns
    Whole Number
    Action
    Length returns the number of characters in a text string that you enter into the formula, or in a text string stored as a value in a data field.
    Text strings must be enclosed in either double or single quotation marks (" " or ` '). Any blank spaces are included as part of the character count.
    Typical uses
    Use this function any time you have a manipulation, comparison, or calculation that is dependent on the length of a text string.
    Examples
    Length("Account")
    Returns 7.
    Length("Text_String") 
    Returns 11.
    Length("__Center__")
    Returns 10.
    Length(ToText({orders.ORDER AMOUNT})) 
    Returns 9, where {orders.ORDER AMOUNT} is 14233.08, and ToText ({orders.ORDER AMOUNT}) returns the String "14,233.08". Here, the comma and period have been specified in the Number format for the formula field as the thousands and decimal separators respectively,
    Length(ToText({orders.ORDER AMOUNT}, 2, "", ".")) 
    Returns 8 where {orders.ORDER AMOUNT} = 14233.08, and ToText ({orders.ORDER AMOUNT}, 2, "", ".") returns the String "14233.08". Here, the null character and period have been specified in the Number format for the formula field as the thousands and decimal separators respectively.
    Length("BOB")
    Returns 3.
    Length("SMITH")
    Returns 5.
    Length("BOB SMITH")
    Returns 9. (The blank space between BOB and SMITH is counted as a character.)
    Length({customer.CUSTOMER NAME})
    The length of the text string stored as a value in {customer.CUSTOMER NAME}.
    {customer.CUSTOMER NAME}[Length({customer.CUSTOMER NAME})-2]
    Returns the third character from the right in the Customer Name. This can also be used to extract a substring from a String that always starts at a fixed position from the end of the String.
    In the following example, an address line contains the province name and postal code. Full province names are of different lengths, but the first character of the postal code is always the seventh from the last character. The formula determines the length of the address line, subtracts 7 from it, and uses the result to identify the first character of the postal code in the address line.
    Local StringVar addressLine;
    Local NumberVar addrLength;
    addressLine := "British Columbia V6X 3W2";
    addrLength := Length (addressLine);
    addressLine [addrLength-7+1 to addrLength]
    



    SAP BusinessObjects
    http://www.sap.com/sapbusinessobjects/
    Support services
    http://service.sap.com/bosap-support/
    Product Documentation on the Web
    http://help.sap.com/