Inference and scripting

When variables (attributes, strings, etc.) are being used within XpertRule scripting or JavaScript, it is up to the XpertRule developer to ensure that these attributes and strings are declared (i.e. that they exist in the Knowledge Explorer), otherwise a run time error will be reported.

It is also good programming practice (if not essential) that variables and arrays are initialised before calculations and string manipulations are performed using them. For example, the initial state of a numeric attribute called Counter within XpertRule is not ZERO but 'unused'. If the attribute is used in an Assign command like this: @Assign Counter = Counter + 1 then an error would occur because Counter has no initial value.

The 'inference' process will automatically seek values for attributes occurring in the decision tree logic of the application. However, attributes within @commands should be used with the same standard procedural programming techniques that would normally be applied to any procedural language.

If needed, you can force a value to be obtained for an attribute, even if the inference process does not require it to yet have a value. This can be done by inserting it as an attribute in the decision tree PRIOR to the procedure (the script sequence), and selecting None for the split. Regardless of the value entered, the decision tree then follows one path. Alternatively, use a set of Assign commands from your main agenda to initialise any attributes/variables.

Once an attribute's tied procedure script has been executed note that the inference process then considers that the attribute has been 'evaluated'. i.e. once a value has been obtained, it will not be sought again - unless you clear the value or set the status to Evaluate or have set the optional isDynamic property for the attribute. The tied procedure is ONLY executed whenever the attribute needs to be evaluated. See also the topic on Static and Dynamic objects.