Strings

<< Click to Display Table of Contents >>

Navigation:  Reference >

Strings

Language designers struggle with the best way to handle strings. Some leave all string processing up to their libraries (but still have language support to define string constants), others make strings be a special type with language support. GPScript adopts a hybrid approach. There are numerous library functions for manipulating strings but the + operator is overloaded so that strings can be concatenated together. More importantly, if you start an expression with a string type, then the RHS of the + operator can be one of several other types (such as integer, double, boolean, SysEx) and the value will be automatically converted to a string type. This makes it easy to write such things as:

Print("The value is " + i) // Display the value of i in the script log window

 
and is mainly intended for debugging purposes although it can be convenient to use this mechanism to set the caption of a label or widget, for example:

SetWidgetCaption(w, "Value: " + v)