PreviousNextIndex

LENGTH function

Returns, as an INTEGER value, the number of characters, bytes, or columns in a string, an expression of type RAW, or a BLOB field.

Syntax

LENGTH ( { string | raw-expression | blob-field }[ , type ] ) 

string
raw-expression
blob-field
type
Examples

This procedure produces a report that contains item information. Because the information on the report fills the entire width of the screen, this procedure shortens the information in the description field for each item. If the description of an item is longer than eight characters, the procedure converts the description to the first eight characters followed by ellipses.

r-length.p
DEFINE VARIABLE short-name AS CHARACTER NO-UNDO FORMAT "x(11)" LABEL "Desc". 
FOR EACH Item NO-LOCK: 
  IF LENGTH(Item.ItemName, "CHARACTER") > 8 THEN 
    short-name = SUBSTRING(Item.ItemName,1,8, "FIXED") + "..." . 
  ELSE  
    short-name = Item.ItemName. 
  DISPLAY Item.ItemNum short-name Item.OnHand Item.Allocated 
    Item.ReOrder Item.OnOrder Item.Price FORMAT "$>>>9.99". 
END. 

In this procedure, the LENGTH function returns the number of bytes in the Name of number 29. The procedure returns a 15, the number of bytes in the Name, Bug in a Rug-by.

r-rawlen.p
DEFINE VARIABLE ix AS INTEGER NO-UNDO. 
FIND Customer NO-LOCK WHERE Customer.CustNum = 29. 
ix = LENGTH(Customer.Name, "RAW"). 
DISPLAY Customer.Name ix LABEL "Byte Length". 

Note

If the value of the expression is the Unknown value (?), the LENGTH function returns the Unknown value (?).


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex