Text
Package: Libraries.Language.Types · Inherits from: Libraries.Language.Object
The Text class is the object representation of the primitive type text.
Example Code
class Main
action Main
text name = "melissa"
Text result = test(name)
end
action test(Text value) returns Text
return value
end
end
Actions
Compare(Libraries.Language.Object object)
This action compares two object values and returns an integer. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.
Parameters
objectLibraries.Language.Object: The object to compare to.
Returns
integer: The Comprare result, Smaller, Equal, or Larger.
Example
Text o
Text t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)
CompareIgnoringCase(Libraries.Language.Object object)
This action compares two object values (ignoring case) and returns a CompareResult. The compare result is either larger if this hash code is larger than the object passed as a parameter, smaller, or equal.
Parameters
objectLibraries.Language.Object: The object to compare to.
Returns
integer: The Comprare result, Smaller, Equal, or Larger.
Example
use Libraries.Language.Support.CompareResult
Text o
Text t
integer result = o:CompareIgnoringCase(t) //1 (larger), 0 (equal), or -1 (smaller)
Contains(text val)
This action returns true if the Text value contains the text from the parameter or if the parameter is a substring in the text variable.
Parameters
valtext
Returns
boolean: True if the text contains a substring passed to the action.
Example
Text a
a:SetValue("hello ")
boolean result = a:Contains("lo")
DoubleQuote(text content)
This action returns this text followed by the given words in double quotes. It doesn't change this text. Like LineFeed and Tab, it returns text, so calls can be chained.
Parameters
contenttext: The words to put in double quotes.
Returns
text: This text, then the words in double quotes.
Example
text message = "Quorum Studio says "
message = message:DoubleQuote("Placed"):LineFeed("Done")
output message
EndsWith(text suffix)
This action returns true if the Text value ends with the given suffix.
Parameters
suffixtext: The value to check for a substring.
Returns
boolean: True if the text ends with the given suffix.
Example
Text a
a:SetValue("hello ")
boolean result = a:EndsWith("lo")
Equals(Libraries.Language.Object object)
This action determines if two objects are equal based on their values.
Parameters
objectLibraries.Language.Object: The to be compared.
Returns
boolean: True if the values are equal and false if they
are not equal.
Example
Text o
Text t
boolean result = o:Equals(t)
EqualsIgnoringCase(Libraries.Language.Object object)
This action determines if two objects are equal based on their values(the case is ignored).
Parameters
objectLibraries.Language.Object: The to be compared.
Returns
boolean: True if the values are equal and false if they
are not equal.
Example
Text o
Text t
boolean result = o:EqualsIgnoringCase(t)
GetCarriageReturn()
This action gets the carriage return text value. This allows a carriage return to be added to a text variable without using the literal value.
Returns
text: The carriage return text value.
Example
text a = "hello world"
a = a + a:GetCarriageReturn() + "My name is"
output a
GetCharacter(integer index)
This action gets the character specified by the given index and returns it.
Parameters
indexinteger: The index to get. Must be greater than or equal to zero.
Returns
text: the character at the specified index
Example
Text a
a:SetValue("abcd")
output a:GetCharacter(0)
GetDoubleQuote()
This action gets the double quote text value. This allows a double quote to be added to a text variable without using the literal value.
Returns
text: The double quote text value.
Example
text a = "hello world"
a = a + a:GetDoubleQuote() + "My name is" + a:GetDoubleQuote()
output a
GetHashCode()
This action gets the hash code for an object. In this case, GetHashCode is overriden to be equivalent to the hash code of its containing object, value.
Returns
integer: The integer hash code of the object.
Example
Object o
integer hash = o:GetHashCode()
GetLineFeed()
This action gets the line feed text value. This allows a line feed to be added to a text variable without using the literal value.
Returns
text: The line feed text value.
Example
text a = "hello world"
a = a + a:GetLineFeed() + "My name is"
output a
GetSize()
This action returns the length of the text object.
Returns
integer: the length of the text object.
Example
Text a
a:SetValue("X")
output a:GetSize()
GetSubtext(integer startIndex, integer endIndex)
This action returns a substring of the text object.
Parameters
startIndexinteger: The starting indexendIndexinteger: The ending index
Returns
text: The substring
Example
use Libraries.Language.Types.Text
Text a
a:SetValue("hello world")
output a:GetSubtext(0, 5)
GetSubtext(integer startIndex)
This action gets a subtext value between the given start index and the end. This includes the value at the start index. A start index equal to the size of the text gives an empty text; one past it, or below 0, raises an InvalidLocationError.
Parameters
startIndexinteger: The start of the subtext.
Returns
text: The subtext from the text.
Example
use Libraries.Language.Types.Text
Text a
a:SetValue("hello ")
text result = a:GetSubtext(1)
GetTab()
This action gets the tab text value. This allows a tab to be added to a text variable without using the literal value.
Returns
text: The tab text value.
Example
text a = "hello world"
a = a + a:GetTab() + "My name is"
output a
GetUnicodeInteger(integer index)
This action gets a unicode symbol integer value. This allows any unicode symbol to be converted from text to the actual integer.
Parameters
indexinteger
Returns
integer: The unicode symbol's integer value
Example
text a = "hello world�?"
output "h as a unicode integer value is: " + a:GetUnicodeInteger(0)
GetUnicodeValue(integer twosCompliment)
This action gets a unicode symbol text value. This allows any unicode symbol to be added to a text variable without using the literal value.
Parameters
twosComplimentinteger: the twos compliments value associated with each unicode symbol.
Returns
text: The unicode symbol's text value.
Example
text a = "hello world"
a = a + a:GetCarriageReturn() + "My name is" + a:GetUnicodeValue(2318)
output a
GetValue()
This action gets the value from the text object.
Returns
text: The value of the object.
Example
Text name
text result = name:GetValue()
IndexOf(text subText, integer index)
This action returns the index location of the first occurrence of the sub-text, starting from the given index location.
Parameters
subTexttext: The value to check for an index.indexinteger: The index to start searching for the sub-text
Returns
integer: The index location of the first occurrence of the sub-text.
Example
Text a
a:SetValue("hello ")
integer result = a:IndexOf("l", 3)
IndexOf(text subText)
This action returns the index location of the first occurrence of the sub-text.
Parameters
subTexttext: The value to check for an index.
Returns
integer: The index location of the sub-text.
Example
Text a
a:SetValue("hello ")
integer result = a:IndexOf("o")
IsEmpty()
This action returns true if the text is empty and false if it contains any value.
Returns
boolean: True if the text is empty.
Example
Text a
a:SetValue("hello ")
boolean result = a:IsEmpty()
LineFeed(text content)
This action returns this text, a line feed, and then the given words. It doesn't change this text. Use LineFeed("") to end a line.
Parameters
contenttext: The words that start the next line.
Returns
text: This text, a line feed, then the words.
Example
text message = "First line"
message = message:LineFeed("Second line")
output message
ParseBoolean()
This action parses a text value and translates it into a boolean. The text "true", in any mix of upper and lower case, gives true; any other text gives false, including "false", "yes", "1", " true" and the empty text. It never alerts an error.
Returns
boolean: The boolean value contained in the text value.
Example
text a = "true"
boolean result = a:ParseBoolean()
ParseInteger()
This action parses a text value and translates it into an integer if the text value is a valid integer value. If the text value is not an integer then the user will be alerted by an Error.
Returns
integer: The integer value contained in the text value.
Example
text a = "12"
integer result = a:ParseInteger()
ParseNumber()
This action parses a text value and translates it into a number if the text value is a valid number value. If the text value is not a number then the user will be alerted by an Error.
Returns
number: The number value contained in the text value.
Example
text a = "12.5"
number result = a:ParseNumber()
Replace(text old, text replacement)
This action replaces a specific subtext with a new value.
Parameters
oldtext: The subtext to be replaced.replacementtext
Returns
text: The modified text after replacing all occurrence of the old subtext.
Example
Text a
a:SetValue("hello ")
text result = a:Replace("l", "z")
SetValue(text i)
This action sets the value of the text object.
Parameters
itext: The text value.
Example
Text name
name:SetValue("Melissa")
Split(text delimiter)
This action splits the text at every place the delimiter appears and returns the pieces, without the delimiter. It is the same as Split(delimiter, false): the delimiter is plain text, empty pieces in the middle are kept, and empty pieces at the end are left out.
Parameters
delimitertext: The delimiter to split by.
Returns
Libraries.Containers.Array<text>: An array of the pieces.
Example
use Libraries.Language.Types.Text
use Libraries.Containers.Array
Text a
a:SetValue("hello world")
Array<text> values = a:Split("l")
Split(text delimiter, boolean include)
This action splits the text at every place the delimiter appears and returns the pieces, without the delimiter. The delimiter is plain text of any length, never a pattern. Pieces are found from left to right and don't overlap, so "aaa" split by "aa" gives "" and "a". Empty pieces between two delimiters are kept. An empty delimiter gives the whole text as one piece, and an empty text gives one empty piece.
Parameters
delimitertext: The delimiter to split by.includeboolean: True to keep the empty pieces at the end (after a final delimiter); false to leave them out, so a text made only of delimiters gives no pieces.
Returns
Libraries.Containers.Array<text>: An array of the pieces.
Example
use Libraries.Language.Types.Text
use Libraries.Containers.Array
Text a
a:SetValue("a,b,,")
Array<text> all = a:Split(",", true)
Array<text> some = a:Split(",", false)
output all:GetSize() + " " + some:GetSize()
SplitIntoLines()
This action splits a text values into lines and returns them in an array.
Returns
Libraries.Containers.Array<text>: An array that contains each line.
Example
use Libraries.System.File
use Libraries.Containers.Array
use Libraries.Containers.Iterator
File file
file:SetAbsolutePath("Some/File.txt")
text value = file:Read()
Array<text> lines = value:SplitIntoLines()
Iterator<text> iterator = lines:GetIterator()
repeat while iterator:HasNext()
text value1 = iterator:Next()
output value1
end
StartsWith(text prefix)
This action returns true if the Text value starts with the given suffix.
Parameters
prefixtext: The value to check for a substring.
Returns
boolean: True if the text starts with a given prefix.
Example
Text a
a:SetValue("hello ")
boolean result = a:StartsWith("h")
Tab(text content)
This action returns this text, a tab, and then the given words. It doesn't change this text.
Parameters
contenttext: The words after the tab.
Returns
text: This text, a tab, then the words.
Example
text row = "Name"
row = row:Tab("Score"):Tab("Rank")
output row
ToLowerCase()
This action converts a text value to all lower case.
Returns
text: The text with all lower case characters.
Example
Text a
a:SetValue("HeLlo ")
text result = a:ToLowerCase()
ToUpperCase()
This action converts a text value to all upper case.
Returns
text: The text with all upper case characters.
Example
Text a
a:SetValue("HeLlo ")
text result = a:ToUpperCase()
Trim()
This action trims the white space from the beginning and end of the text value.
Returns
text: The text that has been trimmed of white space from the beginning and end of the text value.
Example
Text a
a:SetValue(" hello ")
text result = a:Trim()