String

String parameters may be of a required fixed length (documented like "Str,4" or "S,4"), a recommended minimum length (like "Str,30+"), or an unspecified length ("Str" or "String" without a number). In the latter case, the determination of an appropriate size—i.e., sufficient to accommodate the expected data—is left to the programmer's judgment. If you specify a string variable that is shorter than the number of characters that would otherwise be returned into that variable, the data will be truncated to fit the variable. If the string variable is longer than needed, the data will be null terminated.

When passing variable length string parameters to embedded SBR routines, as a general rule you should allow space for an explicit trailing null byte. This is not an issue for BASIC functions, procedures and SBX routines, which are able to recognize the physical end of the string, but may be an issue for embedded SBR routines that link to libraries written in C, where strings are typically assumed to have trailing null bytes.

In rare cases, which are always explicitly noted, subroutines may be able to auto-expand dynamic (S,0) output string parameters. But unless otherwise noted, you should assume not, and pre-initialize any such output string parameters to the expected maximum size.