Changes the number of bytes in a raw variable.

Syntax

LENGTH ( variable ) = expression
variable
A variable of type RAW.
expression
An expression that returns an integer.
Note: You can use compound assignment operators (+=, -=, *=, /=) with the LENGTH statement. For more information, see += Addition assignment operator, -= Subtraction assignment operator, *= Multiplication assignment operator, and /= Division assignment operator.

Example

This procedure takes the number of bytes in the name stored in the variable r1 and truncates it to 2 bytes:

r-rawln1.p

/* You must connect to a non-OpenEdge demo database to run this procedure */
DEFINE VARIABLE r1 as RAW NO-UNDO.

FIND Customer NO-LOCK WHERE Customer.CustNum = 29.
r1 = RAW(Customer.Name).
LENGTH(r1) = 2.
The following example code uses the *= assignment operator to double the number of bytes for the variable.
/* You must connect to a non-OpenEdge demo database to run this procedure */
VAR RAW r1.

FIND Customer NO-LOCK WHERE Customer.CustNum = 29.
r1 = RAW(Customer.Name).
LENGTH(r1) *= 2.

Notes

  • If variable is the Unknown value (?), it remains the Unknown value (?).
  • If expression is greater than the number of bytes in variable, the AVM appends null bytes so that the length of variable equals the length of expression.