QScript RulesManager

From Q
Jump to navigation Jump to search

This feature is new in Q 4.8.

RulesManager

Allows you to create new Rule objects, or replace and reorder them. This object is always accessed via project.rules. The order of rules is fixed for the entire project, and can only be adjusted here. To determine the parameters required for rules in the functions below, use Q to build a rule and click the QScript button.

list

Lists all rules applied to items in this project.
Returns:An array of Rule objects.

moveAfter(to_move, after)

Reorders Rules applied to items in the project.
to_moveThe rule to move.
afterThe rule after which it should be placed, or null to indicate it should be placed first.

newBuiltIn(rule_name, parameters)

Creates a new Rule, ready for adding to a table using table.rules.add(). Find the parameters for this function by creating the appropriate rule in Q and clicking on the QScript button.
rule_nameQ's internal name for the rule.
parametersAn object containing any required parameters, with their values. Use null if no parameters are needed.
Returns:A new Rule object.
Example:
project.rules.newBuiltIn('CellsContain', {relationship: 'less than', value1: 20});

newCustomRule(java_script, parameters)

Creates a new Rule from Table JavaScript source code. Find the parameters for this function by creating the rule in Q and clicking on the QScript button.
java_scriptThe source code for the rule.
parametersAn object containing any required parameters, with their values. Use null if no parameters are needed.
Returns:A new Rule object.

newFromLibrary(title, parameters)

Creates a new Rule by loading it from the online library. Find the parameters for this function by creating the rule in Q and clicking on the QScript button.
titleThe title of the rule in the online library.
parametersAn object containing any required parameters, with their values. Use null if no parameters are needed.
Returns:A new Rule object.

replace(old_rule, new_rule)

Replaces a Rule with a new one. The new rule will be applied to all the tables and plots that the old one was applied to, and will be in the same position.
old_ruleA Rule object that is applied to some tables or plots in the project.
new_ruleA new rule to replace it.

type

Returns the name we use to refer to this class in the documentation.