Programmer Guide/Command Reference/LENGTH: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==LENGTH==
{{PG_StringCommands}}
The <code>LENGTH</code> command returns the length in characters of its first argument:


<code><var>var</var> := LENGTH <var>string</var></code>
<var>var</var> := LENGTH <var>string</var>


-> var = 'numberofcharacters'
Note that any surplus arguments are ignored. See <code>[[Programmer Guide/Command Reference/LINELENGTH|LINELENGTH]]</code> for an alternative command retrieving the length of all arguments, including argument delimiters (e.g. whitespace).


Get the length of the string <var>string</var>. See <code>[[Programmer Guide/Command Reference/LINELENGTH|LINELENGTH]]</code> for an alternative, which can retrieve the length of a line including delimiters (e.g. whitespace).
// returns 1 - the first argument is "a"
#a := length a b c
// returns 5 - due to quoting, the first argument now is "a b c"
#a := length 'a b c'
// returns 6 - under quotes, every whitespace character counts
#a := length 'a b c'

Latest revision as of 10:17, 4 March 2016

The LENGTH command returns the length in characters of its first argument:

var := LENGTH string

Note that any surplus arguments are ignored. See LINELENGTH for an alternative command retrieving the length of all arguments, including argument delimiters (e.g. whitespace).

// returns 1 - the first argument is "a"
#a := length a b c

// returns 5 - due to quoting, the first argument now is "a b c"
#a := length 'a b c'

// returns 6 - under quotes, every whitespace character counts
#a := length 'a  b c'

Navigation menu

Personal tools