Programmer Guide/Command Reference/LINELENGTH: Difference between revisions
From STX Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 4: | Line 4: | ||
The following example returns 5 (3 arguments of 1 character each, plus 2 whitespace characters, one separating "a" from "b", the other separating "b" from "c": | The following example 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 | #a := linelength a b c | ||
This also returns 5 (3 arguments of 1 character each, plus 2 whitespace characters, one separating "a" from "b", the other separating "b" from "c": | This 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 | #a := linelength a b c | ||
This also also returns 5 - due to quoting, there is only one argument with the value of "a b c" | This also also returns 5 - due to quoting, there is only one argument with the value of "a b c" | ||
#a := linelength 'a b c' | #a := linelength 'a b c' | ||
This returns 6 - there is exactly one quoted argument, and under quotes, each whitespace character counts: | This returns 6 - there is exactly one quoted argument, and under quotes, each whitespace character counts: | ||
#a := linelength 'a b c' | #a := linelength 'a b c' | ||
Line 18: | Line 18: | ||
// returns 5 (length of "hello") | // returns 5 (length of "hello") | ||
#len := length hello world | #len := length hello world | ||
// returns 11 (length of "hello", plus one delimiting character, | // returns 11 (length of "hello", plus one delimiting character, | ||
// plus length of "world") | // plus length of "world") | ||
#len := linelength hello world | #len := linelength hello world |
Revision as of 16:43, 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
The following example 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
This 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
This also also returns 5 - due to quoting, there is only one argument with the value of "a b c"
#a := linelength 'a b c'
This 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 := length hello world // returns 11 (length of "hello", plus one delimiting character, // plus length of "world") #len := linelength hello world