Programmer Guide/Command Reference/LINELENGTH: Difference between revisions

From STX Wiki
Jump to navigationJump to search
m (1 revision: Initial import)
No edit summary
Line 1: Line 1:
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
{{DISPLAYTITLE:{{SUBPAGENAME}}}}
==LINELENGTH==


<code><var>var</var> := LINELENGTH <var>string</var></code>
The <code>LINELENGTH</code> command returns the length of its arguments, all concatenated and separated by one space character from one another.
<var>var</var> := LINELENGTH <var>arg<sub>1</sub></var> ... <var>arg<sub>n</sub></var>


-> var = 'numberofcharacters'
// returns 5 (3 arguments of 1 character each, plus 2
// whitespace characters, one separating "a" from "b", the
// other separating "b" from "c"
#a := linelength a b c
// also returns 5 (3 arguments of 1 character each, plus 2
// whitespace characters, one separating "a" from "b", the
// other separating "b" from "c"
#a := linelength  a    b      c
// returns 5 - due to quoting, the first argument now is "a b c"
#a := linelength 'a b c'


Get the length of the string <var>string</var> including delimiters.
// returns 6 - there is exactly one quoted argument, and under
// quotes, each whitespace character counts
#a := linelength 'a  b c'


E.g.
Compare this with the <code>[[Programmer_Guide/Command_Reference/LENGTH|LENGTH]]</code> command returning the length of its first argument only:


<pre>
// returns 5 (length of "hello")
#len := length hello world
#len := linelength hello world
// #len == 5
 
#len := linelength hello world
// returns 11 (length of "hello", plus one delimiting character,
// #len == 11
// plus length of "world")
</pre>
#len := linelength hello world

Revision as of 17:40, 11 April 2011


The LINELENGTH command returns the length of its arguments, all concatenated and separated by one space character from one another.

var := LINELENGTH arg1 ... argn
// returns 5 (3 arguments of 1 character each, plus 2
// whitespace characters, one separating "a" from "b", the
// other separating "b" from "c"
#a := linelength a b c

// also returns 5 (3 arguments of 1 character each, plus 2
// whitespace characters, one separating "a" from "b", the
// other separating "b" from "c"
#a := linelength  a    b       c

// returns 5 - due to quoting, the first argument now is "a b c"
#a := linelength 'a b c'
// returns 6 - there is exactly one quoted argument, and under
// quotes, each whitespace character counts
#a := linelength 'a  b c'

Compare this with the LENGTH command returning the length of its first argument only:

// returns 5 (length of "hello")
#len := linelength hello world
// returns 11 (length of "hello", plus one delimiting character,
// plus length of "world")
#len := linelength hello world

Navigation menu

Personal tools