Len()

This function tells you how long a string is.

Usage

nStringLength = LEN( cString )
That's it, just the length of the string you pass it. Except for one thing. There's a gotcha when you use LEN() on a character field (it works fine on memo fields). Fields in FoxPro are fixed-length, so strings that don't fill the allocated space get filled with trailing blanks. When you apply LEN() to a character field, you get back the defined size of the field, not the size of the actual contents. Apply TRIM() or ALLTRIM() before LEN() if you want to know how many characters you've actually put in a field.Like most of the string-handling functions, LEN() has a double-byte alternative, LENC(), useful for handling strings in languages that have larger character sets.

Example

? LEN("abcdef")      && returns 6
? LEN(LastName)      && returns defined length of LastName field
? LEN(TRIM(LastName)) && returns length of LastName for 
                      && current record

See Also

AllTrim(), FSize(), LenC(), Trim()


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .