Echo and Strings
You can print information into the CAESES console which is helpful for debugging (e.g. printing current values) but also for showing information such as warnings, errors and status etc.
Echo Command
In order to print a message into the console, use the echo command:
echo("Hello World")
In case you want to print values, use the + character to concatenate strings:
parameter valueA(1)
echo("value A = " + valueA )
// you can also use simple double values
double valueB(3)
echo("value B = " + valueB )
Global commands like the following date-command can be used for printing information, too.
echo("The current date is " + dateTime() )
Here is the result:
You can clear the console through the context menu, as shown in the screenshot above.
Clear Console
Within features, you can also use the command clearConsole() in order to remove all previous messages from the console as soon as your feature updates. For instance, you could put this command right at the beginning of the feature code to make sure you only see the messages from the last update. Note that this will also remove messages from other objects.
Strings
You can convert numbers into strings and vice versa. For instance, you can format numbers and store them in a string to write them into a file.
Convert Numbers into Strings
In order to have a string of a number, use the following syntax where a global command is used:
// for float values
int fieldwidth(10)
int precision(7)
string fillchar("0")
string result( asString( 1.23456789, fieldwidth, precision, fillchar) )
// result = 001.234568
// now for integer values
// which is slightly different
string result( asString( 12, fieldwidth, fillchar) )
// result = 0000000012
The field width, precision and fill character are optional arguments, i.e., there are default setting for this so that you do not have to provide it if not needed.
// this works as well
string result( asString( 1.23456789 ) )
Typical fill characters are often blanks: string fillchar(" ")
Convert Strings into Numbers
If you read string data e.g. from external files, you can convert them back into numbers by using the following global conversion commands:
string s("123.456")
double nf(toDouble(s))
int ni(toInt(s))
echo("number 1 = " + nf) // number 1 = 123.456
echo("number 2 = " + ni) // number 2 = 123