Calculation Tag Syntax (Also the same Syntax used in graphics animations).

String Manipulation Functions and Examples


  • 'ToNumber': Converts a string to a number. If conversion fails, the function returns a specified default value if provided; otherwise, it defaults to 0.


Optional Parameter:

defaultValue: A fallback value to return if the input cannot be converted to a number. If omitted, the default is 0.


Examples:  


ToNumber('123.45') → 123.45

Converts the string '123.45' to a number.


ToNumber('abc') → 0

Returns 0 because the string 'abc' cannot be converted to a number, and no default is provided.


ToNumber('abc', 42) → 42

Returns the default value 42 when the string 'abc' cannot be converted.


ToNumber('', 10) → 10

Returns the default value 10 because the input is an empty string.


ToNumber('abc', 'xyz') → 0

Returns 0 because both the input and the default value are invalid.


ToNumber(VAL(SIM.Ramp1)) → Converts the value of SIM.Ramp1 to a number.

ToNumber(VAL(SIM.Text1), 5) → Returns 5 if SIM.Text1 cannot be converted to a number.

ToNumber(VAL(SIM.Random1)) → Converts the value of SIM.Random1 to a number, defaulting to 0 if conversion fails.

ToNumber(Status(SIM.Data1), 100) → Converts the status of SIM.Data1 to a number, using 100 as the fallback.


  • 'ToString': Converts any input to a string. If the input is null or invalid, the function returns a specified default value if provided; otherwise, it defaults to an empty string ("").


Optional Parameter:

defaultValue: A fallback value to return if the input is null or invalid. If omitted, the default is an empty string ("").


Examples:

ToString(123.45) → "123.45"

Converts the number 123.45 to a string.



ToString('') → ""

Returns an empty string because the input is null and no default is provided.


ToString(VAL(SIM.Ramp1)) → Converts the value of SIM.Ramp1 to a string.

ToString(VAL(SIM.Text1), 'N/A') → Returns 'N/A' if SIM.Text1 is null.

ToString(Status(SIM.Data1)) → Converts the status of SIM.Data1 to its string representation.

ToString(VAL(SIM.Random1), 'Error') → Converts the value of SIM.Random1 to a string, defaulting to 'Error' if the input is invalid.

 

  • 'Concat': Concatenates multiple strings into one.

Example: Concat('Hello', ' ', 'World') → 'Hello World'


  • 'Length': Returns the length of a specified string.

Example: Length('Hello') → 5


  • 'Trim': Removes leading and trailing whitespace from a specified string.

Example: Trim(' Hello ') → 'Hello'


  • 'ToUpper': Converts all characters in a string to uppercase.

Example: ToUpper('hello') → 'HELLO'


  • 'ToLower': Converts all characters in a string to lowercase.

Example: ToLower('HELLO') → 'hello'


  • 'Substring': Extracts a substring from a specified string starting at a given index and optionally for a specified length.

Example: Substring('Hello World', 0, 5) → 'Hello'


  • 'IndexOf': Returns the zero-based index of the first occurrence of a substring within a string.

Example: IndexOf('Hello World', 'World') → 6


  • 'Contains': Checks if a string contains a specified substring.

Example: Contains('Hello World', 'World') → 1


  • 'StartsWith': Determines if a string starts with a specified substring.

Example: StartsWith('Hello World', 'Hello') → 1


  • 'EndsWith': Determines if a string ends with a specified substring.

Example: EndsWith('Hello World', 'World') → 1


  • 'Replace': Replaces all occurrences of a substring with another substring in a specified string.

Example: Replace('Hello World', 'World', 'Universe') → 'Hello Universe'


  • 'PadLeft': Pads the left side of a string with a specified character until it reaches the desired total width.

Example: PadLeft('5', 3, '0') → '005'


  • 'PadRight': Pads the right side of a string with a specified character until it reaches the desired total width.

Example: PadRight('5', 3, '0') → '500'


  • 'IsNullOrEmpty': Checks if a string is null or empty.

Example: IsNullOrEmpty('') → 1


  • 'RegexMatch': Checks if a string matches a specified regular expression pattern.

Example: RegexMatch('abc123', '\\d+') → 1