Developer Documentation Library > Mobile SDK > Disconnected mobile application reference > Expression Evaluator reference > Categorical
 
Categorical
Categorical values are typically represented in mrScriptBasic in a manner that is not valid JavaScript (for example, {north} or {8}). The values can be enclosed in quotation marks (for example, "{north}"), but this solution introduces the problem of determining whether the value is a string or a categorical. To resolve this problem, categorical values are represented with a Categorical object.
Internally, the Categorical stores category names as String objects in an Array object. The strings are always stored in lowercase, and are converted to lowercase before comparison. The Categorical class is designed to represent categories as strings that hold the category name. The class can not convert between category names and category values, like the CDMVariant class, because it does not have a category map. This means that category operations are slower because they operate on strings rather than numbers. The difference is important during data processing operations, but is not a significant consideration on mobile devices that only conduct interviews.
Supported categorical arguments
Argument
Example
No arguments
new Categorical()
Constructs a categorical with no categories.
Single string argument
new Categorical('{north, south}')
Constructs a Categorical by parsing the categories out of the string.
Multiple string arguments
new Categorical('north', 'south')
Constructs a Categorical from the listed categories.
Categorical object methods
Operators are represented as methods because JavaScript does not support operator overloading.
add
Adds an item into the Categorical object.
Arguments: String
Return type: None
difference
Returns a new Categorical, which consists of categories that are in the current Categorical or the specified Categorical.
Arguments: Categorical
Return type: Categorical
equals
Returns true when the current Categorical has the same categories as the specified Categorical, regardless of category order.
Arguments: Categorical
Return type: boolean
greaterThan
Returns true when the current Categorical categories are an appropriate super-set of the specified Categorical categories.
Arguments: Categorical
Return type: boolean
greaterThanOrEquals
Returns true when equals() or greaterThan() return as true.
Arguments: Categorical
Return type: boolean
hasIntersection
Returns true when the intersection of the current Categorical, and the specified Categorical, are not empty.
Arguments: Categorical
Return type: boolean
intersection
Returns a new Categorical that consists of the categories that are in both the current Categorical and the specified Categorical.
Arguments: Categorical
Return type: Categorical
isNotNull
Returns true when the categories include any item.
Arguments: None
Return type: boolean
isNull
Returns true when the categories do not include any items.
Arguments: None
Return type: boolean
lessThan
Returns true when the current Categorical categories are an appropriate subset of the specified Categorical categories.
Arguments: Categorical
Return type: boolean
lessThanOrEquals
Returns true when equals() or lessThan()return as true.
Arguments: Categorical
Return type: boolean
notEquals
Returns true when equals() returns as false.
Arguments: Categorical
Return type: boolean
remove
Removes an item from the Category object.
Arguments: String
Return type: None
subtract
Returns a new Categorical that consists of the current Categorical. The categories for the specified Categorical are removed.
Arguments: Categorical
Return type: Categorical
toString
Returns the categories of the current Categorical, concatenated together, separated by commas, and enclosed in braces. For example, "{north, south}".
Arguments: None
Return type: String
union
Returns a new Categorical that consists of the current Categorical, combined with the categories from the specified Categorical.
Arguments: Categorical
Return type: Categorical
See
Expression Evaluator reference