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
Note Operators are represented as methods because JavaScript does not support operator overloading.
add
Arguments: String
Return type: None
Adds an item into the Categorical object.
difference
Arguments: Categorical
Return type: Categorical
Returns a new Categorical, which consists of categories that are in the current Categorical or the specified Categorical.
equals
Arguments: Categorical
Return type: boolean
Returns true when the current Categorical has the same categories as the specified Categorical, regardless of category order.
greaterThan
Arguments: Categorical
Return type: boolean
Returns true when the current Categorical categories are an appropriate super-set of the specified Categorical categories.
greaterThanOrEquals
Arguments: Categorical
Return type: boolean
Returns true when equals() or greaterThan() return as true.
hasIntersection
Arguments: Categorical
Return type: boolean
Returns true when the intersection of the current Categorical, and the specified Categorical, are not empty.
intersection
Arguments: Categorical
Return type: Categorical
Returns a new Categorical that consists of the categories that are in both the current Categorical and the specified Categorical.
isNotNull
Arguments: None
Return type: boolean
Returns true when the categories include any item.
isNull
Arguments: None
Return type: boolean
Returns true when the categories do not include any items.
lessThan
Arguments: Categorical
Return type: boolean
Returns true when the current Categorical categories are an appropriate subset of the specified Categorical categories.
lessThanOrEquals
Arguments: Categorical
Return type: boolean
Returns true when equals() or lessThan()return as true.
notEquals
Arguments: Categorical
Return type: boolean
Returns true when equals() returns as false.
remove
Arguments: String
Return type: None
Removes an item from the Category object.
subtract
Arguments: Categorical
Return type: Categorical
Returns a new Categorical that consists of the current Categorical. The categories for the specified Categorical are removed.
toString
Arguments: None
Return type: String
Returns the categories of the current Categorical, concatenated together, separated by commas, and enclosed in braces. For example, "{north, south}".
union
Arguments: Categorical
Return type: Categorical
Returns a new Categorical that consists of the current Categorical, combined with the categories from the specified Categorical.
See
Expression Evaluator reference