CabMasterPro User Guide
In This Topic
    Miscellaneous Functions
    In This Topic


    These are the functions which do not fit into any other categories, and deal with areas such as colour manipulation, debugging and formula evaluation.



    _OnEditChange [Action Only]
    Postprocessing for changed value of system-reserved answer.
    Syntax _OnEditChange(string)
    Inputs String is a string.
    Notes Unused

    _OnLoadAction
    If present in the drawing properties when a drawing is loaded, it will execute this formula string.
    Syntax _OnLoadAction(Formula)
    Inputs Formula is a string which evaluates as a formula
    Notes It will execute just prior to looking for the optional AutoMerge.tab file, which will be merged if present. So there is the potential to copy a different AutoMerge.tab file into place (but this may in practice be more cumbersome than simply getting the action to explicitly merge the desired file).
    See Also _OnSaveAction

    _OnOpenPage [Action Only]
    Page initialisation for FPS which display specific sets of system-reserved answers.
    Syntax _OnOpenPage(string)
    Inputs String is a string.

    _OnSaveAction
    If present in the drawing properties (or currently selected library properties) it will execute this string instead of performing the usual Save or SaveAs menu options when you try to save the drawing.
    Syntax _OnSaveAction(Formula)
    Inputs Formula is a string which evaluates as a formula
    Notes If present and the formula when evaluated returns No then it will proceed to the default Save or SaveAs action that would have taken place.
    See Also _OnLoadAction

    _OnShow
    Formula which is evaluated whenever the Friendly Page tab in Define area goes on display.
    Syntax _OnShow(Formula)
    Inputs Formula is a string which evaluates as a formula
    Notes There is also an optional _OnShow variable in item level "All Answers" and this is executed whenever the item is selected into the preview pane.

    The control in the Define tabs area can be used for additional control of the preview pane, or for other things, depending on the choice of formula.

    _SystemAction [Action Only]
    Page initialisation for FPS which display specific sets of system-reserved answers.
    Syntax _SystemAction(string)
    Inputs String is a string.
    Examples _SystemAction("UpdateFolding") - see Sliders and Updatefolding

    _UpdateProps [Action Only]
    Updates editmode focus item.
    Syntax _UpdateProps(num)
    Inputs num is a number. 0 to 99 focal point. 100 to 199 focal HSection.
    Notes Unused

    AverageColor
    Calculates the overall color of a specified image
    Syntax AverageColor (imageFile)
    Inputs ImageFile is the location of the image to average. If no path is included, BITMAP_FOLDER is assumed
    Outputs If the image is not found, 0 (black) is returned
    Notes If no file extension is included with imageFile, the image Search Order rule is applied
    Examples AverageColor("rosewood.jpg") =   this color   where rosewood.jpg looks like this: Rosewood
    See Also RGB

    Choose
    Selects a specified value from a list of values
    Syntax Choose (index, value1, value2, ...)
    Inputs Index indicates which of the values is to be returned. Value1, value2, ... are the values to select from, you can provide several
    Outputs If index is out of range, an empty string is returned
    Notes As with an Array, the index of the first item is one, not zero
    Examples Choose (3, "red", "indigo", "orange", "green") = "orange"

    CVErr
    Generates an error message
    Syntax CVErr (message)
    Inputs Message is reported as the cause of the error
    Notes The result of CVErr is just like any other error, and can hence be detected by the Error function
    Examples CVErr ("Could not find pricing table")
    See Also Error

    Debug
    Displays the steps taken when a formula is evaluated for debugging purposes
    Syntax Debug (formula)
    Inputs Formula is the statement to be debugged
    Outputs Messages are added to the program log describing the steps.
    Notes The purpose of this function is so that when a formula is returning an unexpected result, you can put a Debug around it and see which parts of the formula are not working correctly. See also All Answers
    Examples Debug (5 + (2 * 4)) produces two log entries: "(2 * 4) evaluates to 8" and "5 + (2 * 4) evaluates to 13"

    Error
    Returns the message describing a specified error
    Syntax Error (errCode)
    Inputs ErrCode is a code produced by an error
    Notes You should use IsErr first to check that errCode actually is an error. Because error codes are just numbers, using Error on a formula that produces a number will result in message, even when there was most likely no actual error
    Examples Error (1 / 0) = "Cannot DIV(), division by zero"

    Eval
    Evaluates a string as a formula
    Syntax Eval (expression)
    Inputs Expression is a string which is evaluated as a formula
    Outputs Indirect and Val are equivalent to Eval. Eval returns the output of the original expression
    Notes Eval works exactly the same as if you had typed expression into a formula box. Also note that strings with a leading : or = will be evaluated just before use. This is called deferred evaluation and is useful when variables required are not defined in the context of the formula, but will be defined at the time you plan to use it.
    Examples Eval ("if (1+1=2) then yes else no") = Yes

    Format
    Display a formatted version of a date string
    Syntax Format (date, format)
    Inputs Date is the date to be formatted. Commonly you would use such variables as Create_DTM (Date drawing was created) and Lastsave_DTM (Date drawing was last saved) or Now (The current time) for this value (see the list of Constants).
    Format controls the format which the date is in. There are five values that you can use for this, 0 through to 4, and the result of these can be seen in the examples. Alternatively you can use the formatting information found here Web Link to create your own format. (If you have trouble with this link google msdn strftime or see Strftime)
    Outputs A string containing the date in the format you requested.
    Notes Creating your own format string can be a complicated task, and should only be attempted by advanced users. If you cannot understand how to do it, simply use one of the preset values.
    Examples Format ("Wednesday, 28 January 2004 11:56:34 AM",0)
    = Wednesday, 28 January 2004 11:56:34 AM

    Format ("Wednesday, 28 January 2004 11:56:34 AM",1)
    = 28/01/2004 11:56:34 AM

    Format ("Wednesday, 28 January 2004 11:56:34 AM",2)
    = Wednesday, 28 January 2004

    Format ("Wednesday, 28 January 2004 11:56:34 AM",3)
    = 28/01/2004

    Format ("Wednesday, 28 January 2004 11:56:34 AM",4)
    = 11:56:34 AM

    Format ("Wednesday, 28 January 2004 10:23:00 PM","Created on a %A in %Y")
    = Created on a Wednesday in 2004

    Formula
    Returns a representation of a value which can be evaluated as a formula
    Syntax Formula (value)
    Inputs Value is an expression which needs to be converted to a formula
    Notes This function effectively turns value into a string, the same as the Text function. The difference is that if value already is a string, it will be enclosed in double quote marks so that when it is evaluated, the result is the original string. Ie, if the string "x" is evaluated with Eval("x"), the program will look for a variable called x. But if Formula("x") is evaluated with Eval(Formula("x")), the result is the string "x". This means that you should put a value through the Formula function before passing it to Eval, just in case it is a string
    Examples Formula ("a string") = ""a string""
    Formula(5) = "5"
    See Also Eval

    HasDeveloper
    Tests for presence of the developer addon in hasp lock
    Syntax HasDeveloper
    Inputs None
    Outputs Returns Yes if Developer addon present

    HasHost
    Tests if there is a Host ready to receive messages
    Syntax HasHost
    Inputs None
    Outputs Returns Yes if Host is ready to receive messages
    Notes This allows a library to provide conditional support for actions that only make sense in a host/guest environment

    Info
    Displays requested system information
    Syntax Info(k)
    Inputs Specify k to request various types of information. Info(k) has no default, returns empty value for invalid k
    Outputs Returns k=1:userid, k=2:usercode, k=3:username, k=4:ver, k=5:build
    Notes Info(101) returns name of Layer override table for DXT if in use.
    Note that this tests the current Options DXTasXML value first, and returns an empty string if there is no active layer override table. Currently layer mappings only happen for DXTasXML=7 (Biesse Nest), but other future formats may use layer mapping.

    The string returned is the name of the layer override table (relative to Table folder). The default name is "Machining\Layers\LayerOverride.qlt" but this string can be overridden by the optional reg Options string DXTAsXMLLayerOverride
    Examples k=1 UserID eg lockid (hex) or cloud userid (^800123)
    k=2 usercode eg "ABC12", k=3 username eg "ABC Kitchens"
    k=4 version eg "11.1.0.123" returns library version by reading !version.txt in Library folder
    k=5 build eg "2022.3.1.20"
    k=6 libver eg "11.0.0.44)"
    See Also USERID

    LibraryList
    Returns all codes in the Library or catalog, as pipe separated string
    Syntax LibraryList (library,matchcode,matchtype,matchsubtype)
    Inputs Library currently loaded or user defined
    Outputs LibraryList() all codes in the currently loaded library, equivalent to LibraryList(""). Variations of this function with extra parameters for filtering do also accept "" to indicate the currently loaded library.

    library - selected library, e.g. LibraryList("CM-Cabinets\Extras") lists all codes in Extras.qil (or Extras.qim if there is a catalog).

    matchcode,matchtype - all codes matching the regular expression matchcode and type matching the regex matchtype.

    matchsubtype - all codes with subtype matching the regex matchsubtype.

    Notes This is really one function internally with lots of calling options. Things to note...
    ".*" - means match everything
    "abc" - means the substring "abc" must appear somewhere
    ^ - matches beginning of string
    $ - matches end of string
    "^abc$" - matches only if the whole string is "abc"
    Lots of characters need to be escaped with a backslash, e.g. to match (copy) you need to write "\(copy\)".

    Note regex in general is case dependent, however, for AMS middleware everything is matched in a case independent way, as library codes are not case dependent.
    Examples Here is a simple library (3 Cab Library) with a catalog and the full list of codes is as shown in the drop list.
    Librarylist

    LibraryListByType
    Return pipe separated list of codes matching the regex provided for type.
    Syntax LibraryListByType (library,matchtype,matchsubtype)
    Inputs matchtype - LibraryListByType("MyLibName","Floor") lists all codes with any name but type must contain the string "floor" (case independent).

    matchsubtype - LibraryListByType("MyLibName",".*","Floor") lists all codes with any name, any type but subtype contains the string "floor" (case independent). Note that the regex ".*" matches everything.

    ResolveImagePath
    Returns the full filename
    Syntax ResolveImagePath(filename stub)
    Inputs Filename stub is used to look for a matching file in the system
    Outputs Returns either the full filename if something appropriate is found, or an empty string if it is not
    See Also ResolveModelPath

    ResolveModelPath
    Returns the full filename
    Syntax ResolveImagePath(filename)
    Inputs Filename is used to look for a matching file in the system
    Outputs Returns either the full filename if something appropriate is found, or an empty string if it is not
    See Also ResolveImagePath

    RGB
    Produces a color code from the specified red, green and blue values
    Syntax RGB (red, green, blue)
    Inputs Red, green, blue are the values of the three color components, each between 0 and 255
    Notes For pre-defined common colors - see the list of Constants. See also the Colours Tutorial.
    Examples RGB (255, 0, 0) = pure red
    RGB (128, 128, 128) = gray
    See Also AverageColorPickColor

    Stopwatch
    Returns time taken in mSec to evaluate the expression
    Syntax Stopwatch(expression)
    Inputs Expression is a string which is evaluated as a formula
    Outputs Time taken in milliseconds
    Notes This implementation actually clobbers the result of the expression EVAL
    See Also EVAL

    TotNHoles
    Counts all drill holes in the machining for a cabinet, optionally filtered by layer, diameter and depth
    Syntax TotNHoles(Layer,Diameter,Depth)
    Inputs

    Layer (if not "") filters and only counts holes in layer specified

    Diameter (if not 0) filters and only counts holes with diameter specified

    Depth (if not 0) filters and only counts holes with depths specified

    Notes All parameters are optional. Context must be a cabinet or be within a cabinet, and then holes anywhere in that cabinet will be counted
    Examples

    TotNHoles() counts all holes

    TotNHoles("",5mm) counts all 5mm diameter holes

    TotNHoles("Shelf") counts all holes in the layer "Shelf"


    UserID
    Displays user identification
    Syntax UserID()
    Inputs None (you still need to use the empty brackets)
    Outputs Returns lockid (hex) or cloud userid (^800123)
    Examples Equivalent to INFO(1)
    See Also INFO

    UsingMetricUnits
    Determines if metric or imperial unit systems used
    Syntax UsingMetricUnits( )
    Inputs None (you still need to use the empty brackets)
    Outputs Returns true if the user is in a metric length unit system, or false for imperial unit systems