BayES BayES

2.7 Strings

Strings of characters constitute another data type in BayES. Strings are defined as words or phrases enclosed in double quote marks and they can be assigned id values, which can be subsequently used to refer to them. These can be concatenated or substrings extracted from them. Strings are used primarily for printing information on the BayES console or when working with directory statements. Example 2.6 demonstrates many of BayES’ capabilities in working with strings. The full list of functions that operate on strings is given in section B.15.

Example 2.6
▼ Input ▼ Output
 
// Define two strings, s1 and s2 
s1 = "Hello "; 
s2 = "World!"; 
 
// Concatenate s1 and s2 and print the 
// result on the console 
s = strcat(s1,s2); 
print(s); 
 
// Print characters 1 to 5 from s 
print(substr(s,1:5)); 
 
// Compare two strings 
r1 = "BayES strings are "; 
if ( strcmp(s2,"WORLD!") ) 
    r2 = "not case sensitive "; 
else 
    r2 = "case sensitive "; 
end 
print(strcat(r1,r2)) ;

 
Hello World! 
Hello 
BayES strings are case sensitive 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Share this content:
Facebook Twitter LinkedIn Email
© 2016–20 Grigorios Emvalomatis