Libraries.Language.Types.Text Documentation

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

Inherits from: Libraries.Language.Object

Actions Documentation

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

Return

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

Return

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

  • text val

Return

boolean: True if the text contains a substring passed to the action.

Example

Text a
a:SetValue("hello ")
boolean result = a:Contains("lo")

EndsWith(text suffix)

This action returns true if the Text value ends with the given suffix.

Parameters

  • text suffix: The value to check for a substring.

Return

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

Return

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

Return

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.

Return

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

  • integer index: The index to get. Must be greater than or equal to zero.

Return

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.

Return

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.

Return

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.

Return

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.

Return

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

  • integer startIndex: The starting index
  • integer endIndex: The ending index

Return

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.

Parameters

  • integer startIndex: The start of the subtext.

Return

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.

Return

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

  • integer index

Return

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

  • integer twosCompliment: the twos compliments value associated with each unicode symbol.

Return

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.

Return

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

  • text subText: The value to check for an index.
  • integer index: The index to start searching for the sub-text

Return

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

  • text subText: The value to check for an index.

Return

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.

Return

boolean: True if the text is empty.

Example

Text a
a:SetValue("hello ")
boolean result = a:IsEmpty()

ParseBoolean()

This action parses a text value and translates it into a boolean if the text value is a valid boolean value. If the text value is not a boolean then the user will be alerted by an Error.

Return

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.

Return

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.

Return

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

  • text old: The subtext to be replaced.
  • text replacement

Return

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

  • text i: The text value.

Example

Text name
name:SetValue("Melissa")

Split(text delimiter)

This action splits the string based on the given non-empty delimiter. The delimiter can be of any length. The string will be split by the given delimiter and an array of text objects will be returned, without the delimiter.

Parameters

  • text delimiter: The non-empty delimiter to use.

Return

Libraries.Containers.Array: An array of text objects corresponding to the splits by the delimiter.

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 string based on the given non-empty delimiter. The delimiter can be of any length. The string will be split by the given delimiter and an array of text objects will be returned, without the delimiter.

Parameters

  • text delimiter: The non-empty delimiter to use.
  • boolean include: Include any trailing values after the delimiter, including the empty string.

Return

Libraries.Containers.Array: An array of text objects corresponding to the splits by the delimiter.

Example

use Libraries.Language.Types.Text
use Libraries.Containers.Array
Text a
a:SetValue("hello world")
Array<Text> values = a:Split("l")

SplitIntoLines()

This action splits a text values into lines and returns them in an array.

Return

Libraries.Containers.Array: 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

  • text prefix: The value to check for a substring.

Return

boolean: True if the text starts with a given prefix.

Example

Text a
a:SetValue("hello ")
boolean result = a:StartsWith("h")

ToLowerCase()

This action converts a text value to all lower case.

Return

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.

Return

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.

Return

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()