String calculations

Calculations involving strings and string values are also common in Dexterity-based applications.

Appending strings

Appending strings together is a common sanScript operation. For example, the following code appends the Company Name variable into a string.

local string result;

result = "Company " + 'Company Name' + " is eligible for a discount.";

String commands

Several sanScript commands are available to work with strings. Some commands retrieve information about a string. Other commands manipulate the string and return the results. For example, the length() function returns the number of characters in a string. The substring() function returns the specified portion of a string.

Comparing strings

When strings are compared in boolean expressions, the ASCII values of the characters in the strings are compared, one character at a time from left to right, until a character doesn’t match or one of the strings has no more characters.

If two corresponding characters don’t match, the result of their comparison is returned as the result of the string comparison. If all of the characters in the two strings match up to the point where one of the strings runs out of characters, the shorter string is considered less than the longer string.

ASCII values for lowercase characters are larger than ASCII values for uppercase characters.


The following table lists sample string comparisons.

[spacer]

String1

<

<=

=

<>

>=

>

String2

"A"

F

T

T

F

T

F

"A"

"A"

T

T

F

T

F

F

"AB"

"B"

F

F

F

T

T

T

"AB"

"A "

F

F

F

T

T

T

"A"

"ABC"

T

T

F

T

F

F

"ABCD"

"ABC"

T

T

F

T

F

F

"Z"


 

 


Documentation Feedback