Difference between revisions of "SHIP:Data Types:String"

From Serious Documentation
Jump to: navigation, search
(Examples)
Line 12: Line 12:
 
|{{DataType|String}}||A sequence of UTF8 characters terminated in an implicit end-of-string character.
 
|{{DataType|String}}||A sequence of UTF8 characters terminated in an implicit end-of-string character.
 
|}</onlyinclude>
 
|}</onlyinclude>
 +
 +
String constants are written in [[SHIP:Sail|Sail Scripts]] enclosed in double quotes (&quot;), and can be concatenated using the <code>+</code> operator.
  
 
== Examples ==
 
== Examples ==
String constants are written in [[SHIP:Sail|Sail Scripts]] enclosed in double quotes (&quot;), for example
+
This is an example of assigning a {{DataType|String}} constant to a {{Node|text|text}} node within a [[SHIP:Sail|Sail script]]:
  
 
   <code>text.value = "hello";</code>
 
   <code>text.value = "hello";</code>
  
and can be concatenated with the "+" operator, for example  
+
And this example shows string concatenation:
  
 
   <code>text.value = "hello" + " " + "there";</code>
 
   <code>text.value = "hello" + " " + "there";</code>
  
Within [[SHIP:Sail|Sail Scripts]] you can access the Unicode codepoints within a string, access portions of the string, and more using the [[SHIP:Sail:Functions#String_Functions|Sail String Functions]].
+
Within [[SHIP:Sail|Sail scripts]] you can access the Unicode codepoints within a string, access portions of the string, and more using the [[SHIP:Sail:Functions#String_Functions|Sail String Functions]].
  
 
You can define strings with alternate language translations using {{Node|string|string}} and {{Node|text|text}} nodes.  These translated string resources can be combined at runtime in [[SHIP:Sail|Sail scripts]] to form larger strings, for example if you have a {{Node|string|string}} resource:
 
You can define strings with alternate language translations using {{Node|string|string}} and {{Node|text|text}} nodes.  These translated string resources can be combined at runtime in [[SHIP:Sail|Sail scripts]] to form larger strings, for example if you have a {{Node|string|string}} resource:

Revision as of 05:12, 19 April 2014

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.

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";

Within Sail scripts you can access the Unicode codepoints within a string, access portions of the string, and more using the Sail String Functions.

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";