$Length()

Returns the length of a string measured in characters, or in "pieces" separated by a delimiter specified by one of its arguments.

The format for the $LENGTH function is:

$L[ENGTH](expr1[,expr2])

Examples of $LENGTH()

Example:

GTM>Write $length("KINGSTON")
8
GTM>

This uses $LENGTH() to WRITE the length in characters of the string "KINGSTON".

Example:

GTM>set x="Smith/John/M/124 Main Street/Ourtown/KA/USA"
GTM>write $length(x,"/")
7
GTM>

This uses $LENGTH() to WRITE the number of pieces in a string, as delimited by /.

Example:

GTM>write $length("/2/3/","/")
4
GTM>

This also uses $LENGTH() to WRITE the number of pieces in a string, as delimited by /. Notice that GT.M. adds one count to the count of delimiters (in this case 3), to get the number of pieces in the string (displays 4).