11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Caché</strong> <strong>ObjectScript</strong> Functions$LENGTHReturns the number of characters or delimited substrings in a string.$LENGTH(expression,delimiter)$L(expression,delimiter)ParametersexpressiondelimiterThe target string. It can be a numeric value, a string literal, the nameof any variable, or any valid expression.Optional — A string that demarcates separate substrings in the targetstring. It must be a string literal, but can be of any length. Theenclosing quotation marks are required.Description$LENGTH returns the number of characters in a specified string or the number of delimitedsubstrings in a specified string, depending on the parameters used. Note that length countsthe number of characters; an 8-bit character and a 16-bit wide character are both counted asone character.• $LENGTH(expression) returns the number of characters in the string. If the expressionis a null string, $LENGTH returns a 0. If expression is a numeric expression, it is convertedto canonical form before determining its length. If expression is a string numericexpression, no conversion is performed. If expression is the $DOUBLE values INF, -INF, or NAN, the lengths returned are 3, 4, and 3, respectively.• $LENGTH(expression,delimiter) returns the number of substrings within the string.$LENGTH returns the number of substrings separated from one another by the indicateddelimiter. This number is always equal to the number of delimiters in the string, plus one.If the delimiter is the null string, $LENGTH returns a 0. If the delimiter is any othervalid string literal and the string is a null string, $LENGTH returns a 1.ExamplesIn the following example, both $LENGTH functions return 4, the number of characters inthe string.SET roman="test"WRITE !,$LENGTH(roman)," characters in: ",romanSET greek=$CHAR(964,949,963,964)WRITE !,$LENGTH(greek)," characters in: ",greek238 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!