B.15 Statements for working with strings
Strings in BayES are used, primarily, to print messages on the BayES console and in directory statements. To improve the speed of evaluation of mathematical statements, which are much more frequently used, string operations and functions form a distinct part of the BayES language. This means that indexing operations or functions that work on matrices do not work on strings. However, specialized functions that operate on strings are provided and these are documented in the following table.
Note that, as with the rest of the language, strings are case sensitive: "my string" is not the same as "My String".
Syntax  Arguments and performed function 
x = strlength(s);  x is a $1\phantom{\rule{0.3em}{0ex}}\times \phantom{\rule{0.3em}{0ex}}1$ matrix that stores the number of characters in string s. Note that escape characters are treated as separate entries. For example, the string "∖"my string∖"" contains 13 characters, with each "∖"" occupying two places in the string.

s = strcat(s1, s2 $[$, s3, s4,...$]$);  s is a string that is constructed by concatenating the strings that are passed as arguments to strcat().

s = substr(r, l:u);  s is a string that is constructed by extrancting the characters in r located from position l to u (margins included). Note that escape characters in s occupy two places in a string.

strreplace(s, r, t);
 The strreplace() function in the ﬁrst form replaces all occurrences in string s of the
characters in string r with the characters in string t. For example, the statement
strreplace(s, "∖∖", "/"); replaces all backslashes in s with forward slashes.

x = strﬁnd(s, r);  x is a $1\phantom{\rule{0.3em}{0ex}}\times \phantom{\rule{0.3em}{0ex}}1$
matrix that stores the location in string s at which the ﬁrst match occurs between
the characters in s and r. For example, if s is "Hello World" and r is "World", then x
will be equal to seven.

x = strﬁndr(s, r);  x is a $1\phantom{\rule{0.3em}{0ex}}\times \phantom{\rule{0.3em}{0ex}}1$
matrix that stores the location in string s at which the last match occurs between
the characters in s and r. For example, if s is "Hello World" and r is "World", then x
will be equal to seven.

strcmp(s, r)  The strcmp() function compares strings s and r and evaluates to true if the two
strings match exactly and false otherwise.

s = mat2str(A $[$, p$]$);  The mat2str() function produces a string s from the contents of a $1\phantom{\rule{0.3em}{0ex}}\times \phantom{\rule{0.3em}{0ex}}1$ matrix A, using up to p digits. If p is not provided then s will contain the value of A as it appears on the BayES console after a print(A); statement.
