SHIP:Data Types:String

From Serious Documentation
Jump to: navigation, search

See Also

String

Stings in SHIP are a sequence of UTF8 characters terminated in an implicit end-of-string character.

Data Type Description
String A sequence of UTF8 characters terminated in an implicit end-of-string character.

String constants are written in Sail Scripts enclosed in double quotes ("), and can be concatenated using the + operator.

String constants with alternate language translations can be created using string and text nodes in the resources area.

Sail String Functions enable you to access the Unicode codepoints within a String, count the character length of the String, access subsets of the String, and more.

Examples

This is an example of assigning a String constant to a text node within a Sail script:

 text.value = "hello";

And this example shows string concatenation:

 text.value = "hello" + " " + "there";

You can define strings with alternate language translations using string and text nodes. These translated string resources can be combined at runtime in Sail scripts to form larger strings, for example if you have a string resource:

tWelcome
  enUS: Welcome
  frFR: Bienvenue

a Sail script can combine these using simple concatenation:

text.value = tWelcome + " Terry";

The text.value will be assigned either Welcome Terry or Bienvenue Terry depending on the value of the shiplanguage system variable at the time of the assignment. This script can be wrapped in a listener that is listeningto the shiplanguage system variable such that whenever the system language changes, the text.value is automatically updated to the current translation available.