module level string variables declared and initialized
Code: Select all
' SharpBASIC string-05
' --------------------
incl "lib/sys.sbi";
dim Title: str = "This is SharpBASIC.";
dim title: str * 26 = "a new programming language";
main do
print(Title);
print(title);
print();
end;
Code: Select all
incl "lib/sys.sbi";
decl sub Hello();
main do
Hello();
end;
sub Hello()
dim var: str = "This is SharpBASIC.";
dim fix: str * 26 = "a new programming language";
do
print(var);
print(fix);
print();
end;
Note that the string datatype is called str rather than string. This is for the same reason that we use int rather than integer which makes the language more consistent and less verbose.
Also note that the print-statement no longer requires an argument. print();simply prints a linefeed and performs better than print(sbLF);