CabMasterPro User Guide
In This Topic
    Variable Functions
    In This Topic


    Most of these functions are used for testing which of the Data Types a variable is. The others are used for modifying a variable or checking that it exists.



    Defined
    Checks whether a specified variable has been declared
    Syntax Defined (var)
    Inputs Var is any valid variable name
    Notes This will return Yes for a variable declared at any level (ie library, drawing, page, cabinet or section level properties) including the current formula, and also includes pre-defined variables such as DocumentTitle
    Examples Defined (Author) = Yes
    See Also VarDelete, VarExist, LookupFormula

    IsBlank
    Tests if a value is an empty text string
    Syntax IsBlank (value)
    Inputs Value is an expression or a variable of any type
    Notes The only parameter IsBlank returns Yes for is the empty string, ""
    Examples IsBlank ("Some text") = No
    IsBlank ("") = Yes
    IsBlank(0) = No

    IsErr
    Tests if a value is an error code
    Syntax IsErr (value)
    Inputs Value is an expression or a variable of any type
    Notes Errors are a special type of variable which have a code number and a message associated with them. When printed, they appear as "#ERR!". You can get the message of an error code using the Error function, or create an error with a custom message using CVErr. The IsErr function returns Yes only if value is an error code
    Examples IsErr (1 / 0) = Yes (because of the divide by zero error)
    IsErr ("some text") = No
    IsErr (#ERR!) = Yes

    IsError
    Tests if a value is an error code or not available
    Syntax IsError (value)
    Inputs Value is an expression or a variable of any type
    Notes Since #N/A can be considered a type of error, this function is simply a modified version of IsErr which also returns true if value is a Not Available code. Hence it is the equivalent of "IsErr (value) OR IsNA (value)"
    Examples IsError (#N/A) = Yes
    IsError (#ERR!) = Yes
    See Also IsErr

    IsEven
    Tests if a value is an even number
    Syntax IsEven (value)
    Inputs Value is an expression or a variable of any type
    Notes If value is text, it is converted to a number first. If the text doesn't contain a number, it converts to 0 and hence returns Yes. If value is not a whole number, it is rounded off first
    Examples IsEven (3.9) = Yes
    IsEven (2") = No (assuming mm is the default units, 2" converts to 50.8mm, then rounds to 51mm which is odd)
    See Also IsOdd

    IsLogical
    Tests if a value is a boolean (Yes/No)
    Syntax IsLogical (value)
    Inputs Value is an expression or a variable of any type
    Notes IsLogical returns Yes only if value is equal to one of the boolean Constants: True, False, Yes or No. Although 1 and 0 are equal to True and False respectively, they are numbers instead of logical values
    Examples IsLogical (1) = No
    IsLogical (5 > 2) = Yes

    IsNA
    Tests if a value is N/A (Not Available)
    Syntax IsNA (value)
    Inputs Value is an expression or a variable of any type
    Notes This function only returns Yes if value equals #N/A (which is most commonly returned from Lookup Table functions)
    Examples IsNA (#N/A) = Yes
    IsNA (RowLabel ("sometable", 6)) = Yes (assuming there is less than six rows in "sometable.qid")

    IsNonText
    Tests if a value is not a text string
    Syntax IsNonText (value)
    Inputs Value is an expression or variable of any type
    Notes This function should always return the opposite result to IsText (for the same value). See the notes on IsText for more information
    Examples IsNonText ("a string") = No
    IsNonText (#ERR!) = Yes
    See Also IsText

    IsNumber
    Tests if a value is numerical
    Syntax IsNumber (value)
    Inputs Value is an expression or variable of any type
    Notes Returns Yes if value is a number, including any measurements such as $12.30 or 34mm. Text is not automatically converted to numbers
    Examples IsNumber ($12.30) = Yes
    IsNumber ("93") = No
    IsNumber (4 + "62") = Yes (note this returns Yes because the "62" is converted to a number during the evaluation of the expression. The actual result of the expression is numerical)

    IsOdd
    Tests if a value is an odd number
    Syntax IsOdd (value)
    Inputs Value is an expression or a variable of any type
    Outputs outputs
    Notes This function should always return the opposite result to IsEven (for the same value). See the notes on IsEven for more information
    Examples IsOdd (-4.8) = Yes
    IsOdd ("no numbers here") = No
    See Also IsEven

    IsText
    Tests if a value is a text string
    Syntax IsText (value)
    Inputs Value is an expression or variable of any type
    Notes Only returns Yes if value really is a text string, without using any type conversion first. What this means is, the string "5" would normally be converted to the number 5 as needed, but it is not converted for this function (as shown in the example)
    Examples IsText (123) = No
    IsText ("123") = Yes
    See Also IsNonText

    LookupFormula
    Returns the formula, if any, controlling this variable
    Syntax LookupFormula("var")
    Inputs Retrieve the formula behind any property/variable
    See Also Defined, VarExist

    SetFormula [Action Only]
    Sets the formula field of a variable to a specified value
    Syntax SetFormula (var, formula)
    Inputs Var is a string containing the name of any Defined variable. Formula is an expression that will be set as the formula of var
    Notes Using this function has the same effect as opening the Answers and Setup page, finding a variable called var in the list, clicking on its Formula column and typing in formula. The difference is that formula can be set on the fly and it can be an expression itself (as illustrated in the example).
    Note that var is actually a string, not the variable itself. To give the variable testVar a value of 123, use SetFormula ("testVar", 123), not SetFormula (testVar, 123). The latter will evaluate testVar as a string and use the result as the name of the variable to set (although this may be what you wish to do in some cases)
    Examples assuming testVar is set to 123:
    SetFormula ("var2", testVar + 25) results in var2 having a formula of "148"
    SetFormula ("var3", "testVar + 25") results in var3 having a formula of "testVar + 25"
    In both examples the variable will have a value of 148, but the difference is that when testVar changes, var3 will change accordingly but var2 remains constant at 148
    See Also SetValue

    SetValue
    Sets a variable to a specified value
    Syntax SetValue (var, value)
    Inputs Var is a string containing the name of any Defined variable. Value is an expression that will be set as the value of var
    Notes SetValue works in the same way as SetFormula except that it puts the result of an expression into the Value field. This function must be used for setting the value of any drawing level properties (incl. cabinet-level, section-level, etc). Using the other assignment Operators only works on temporary variables
    Examples SetValue ("testVar", "another") results in testVar having a value of "another"
    SetValue (testVar, 123) results in another having a value of 123
    This last case is true because the quotes were left off testVar, so the actual value of testVar was used as the variable name (which happened to be "another"). Check the note on SetFormula for an explanation
    See Also SetFormula, SetValueTimed

    SetValueTimed
    Timer sequence
    Syntax SetValueTimed (name,startvalue,finishvalue,increment,delay)
    Inputs name integer variable name which is set to startvalue, then after the specified delay in milliseconds, it increments it by the specified amount until is hits the finishvalue
    Notes Allows as many concurrent timers as required, to both increment and decrement. See also Timer Variable For Animation.
    See Also SetValue

    TypeIndex
    Finds the index for a given value
    Syntax TypeIndex (VarName)
    Inputs VarName is a variable name, not quoted
    Outputs Returns a number (0, 1, 2 etc) which is the index of the type of this variable.
    Notes The value returned is a number which is the index of this varnames type (eg 5 if it is Money etc)

    For a table of the possible types, showing the index and value strings, see Types.
    See Also TypeName

    TypeName
    Finds the name of given variable
    Syntax TypeName (VarName)
    Inputs VarName is a variable name, not quoted
    Outputs Returns a string which is the type of this variable (e.g. "Money").
    Notes Variables in the middleware always have some type (e.g. $5.20 is TYPE_MONEY and 150sqmm is TYPE_AREA)

    For a table of the possible types, showing the index and value strings, see Types.
    See Also TypeIndex

    VarDelete
    Removes the specified variable in the current context (eg cabinet action for cabinet props etc).
    Syntax VarDelete (VarName)
    Inputs VarName is a string containing a variable name
    Notes This will return Yes if a variable is deleted and No if the variable could not be deleted.
    Examples VarDelete ("abc")
    See Also Defined, VarExist

    VarExist
    Checks whether a specified variable has been declared
    Syntax VarExist (VarName)
    Inputs VarName is a string containing a variable name
    Notes This will return Yes for a variable declared at any level (ie library, drawing, page, cabinet or section level properties) including the current formula, and also includes pre-defined variables such as DocumentTitle. This differs from Defined in that it can take a string or formula and see if a variable exists with the resulting name.

    For example if you were to use VarExist(Author) it would attempt to evaluate if the value of the Author variable is the name of another variable.
    Examples VarExist ("Author") = Yes
    See Also Defined, VarDelete, LookupFormula

    VarIfExistElse
    Evaluates expression
    Syntax VarIfExistElse (VarName, DefVal)
    Inputs VarName is a string containing a variable name
    DefVal is default value
    Notes Evaluates expression, typically "abc" for variable abc, and return value if ok, else return default value of "" or default value of DefVal (no messages generated)
    See Also Defined, VarDelete, VarExist