Propeller Manual

Table Of Contents
STRSIZE – Spin Language Reference
STRSIZE
Command: Get size of string.
((PUB PRI))
STRSIZE ( StringAddress )
Returns: Size (in bytes) of zero-terminated string.
StringAddress is an expression specifying the starting address of the string to measure.
Explanation
STRSIZE is one of two commands (STRCOMP and STRSIZE) that retrieve information about a
string.
STRSIZE measures the length of a string at StringAddress, in bytes, up to, but not
including, a zero-termination byte.
Using STRSIZE
The following example assumes
Print is a method created elsewhere.
PUB Main
Print(strsize(@Str1))
Print(strsize(@Str2))
DAT
Str1 byte "Hello World", 0
Str2 byte "Testing.", 0
The above example has two zero-terminated strings in the DAT block, Str1 and Str2. The
Main method calls STRSIZE to get the length of each string. Assuming Print is a method that
displays a value, this example prints 11 and 8 on the display.
Zero-Terminated Strings
The
STRSIZE command requires the string being measured to be zero-terminated; a byte equal
to 0 must immediately follow the string. This practice is quite common and is recommended
since most string-handling methods rely on zero terminators.
Page 206 · Propeller Manual v1.1