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.

In the following example, the first $LENGTH returns 5. This is the length of 74000, thecanonical version of the specified number. The second $LENGTH returns 8, the length ofthe string “+007.4e4”.WRITE !,$LENGTH(+007.4e4)WRITE !,$LENGTH("+007.4e4")In the following example, the first WRITE returns 11 the number of characters in var1(including, of course, the space character). The second WRITE returns 2, the number ofsubstrings in var1 using the space character as the substring delimiter.SET var1="HELLO WORLD"WRITE !,$LENGTH(var1)WRITE !,$LENGTH(var1," ")The following example returns 3, the number of substrings within the string, as delimited bythe dollar sign ($) character.SET STR="ABC$DEF$EFG",DELIM="$"WRITE $LENGTH(STR,DELIM)If the specified delimiter is not found in the string $LENGTH returns 1, because the onlysubstring is the string itself.The following example returns a 0 because the string tested is the null string.SET Nstring = ""WRITE $LENGTH(Nstring)The following example shows the values returned when a delimiter or its string is the nullstring.SET String = "ABC"SET Nstring = ""SET Delim = "$"SET Ndelim = ""WRITE !,$LENGTH(String,Delim) ; returns 1WRITE !,$LENGTH(Nstring,Delim) ; returns 1WRITE !,$LENGTH(String,Ndelim) ; returns 0WRITE !,$LENGTH(Nstring,Ndelim) ; returns 0Notes$LENGTH, $PIECE, and $LIST$LENGTH• $LENGTH with one argument returns the number of characters in a string. This functioncan be used with the $EXTRACT function, which locates a substring by position andreturns the substring value.<strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong> 239

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

Saved successfully!

Ooh no, something went wrong!