User Tools

Site Tools


addrule_add_a_rule_to_this_collection_.htm
Navigation:  ABC Library Reference > RuleManager > RulesCollection Class Methods >====== AddRule (add a rule to this collection) ====== Previous pageReturn to chapter overviewNext page

AddRule( name,description,expression,control,offset)

blk2blue.jpg

AddRule Adds and initializes a rule to the collection being managed by this RuleManager object
name A string constant, variable, EQUATE, or expression that contains a name for this rule. If this name is not unique, results may be unpredictable.
description A string constant, variable, EQUATE, or expression that contains a description of this rule. The primary use of this description is as a message identifying a broken rule. The description should be worded with this use in mind.
expression A string constant, variable, EQUATE, or expression that contains the logical expression which defines this rule. If the expression evaluates to False, the rule is considered broken.
control A numeric constant, variable, EQUATE, or expression that specifies the Field Equate of the control linked to this rule. If the rule is broken, an error indicator will be placed to the right of this control.
offset A numeric constant, variable, EQUATE, or expression that specifies the distance, in dialog units, between the right side of the linked control and the error indicator.

The AddRule method creates a Rule object and adds it to the broken rule queue.

Example:

Customer RulesCollection  
CODE  
 Customer.SetErrorImage('~BRuleNo.ico')
 Customer.SetDescription('Customer File Rules')
 Customer.AddRule('ShortNameReqiored','Short name is required', |
                  'cus:ShortName <;<;> OR CheckShortName()', |
                   ?cus:ShortName,3)
 Customer.AddRule('Company Boolean','Must select individual (0) or company (1)', |
     'INRANGE(cus:Company,0,1)',?cus:Company,3)
 Customer.AddRule('CompanyNameRequired','Company name is required', |
                  'cus:CompanyName <;<;> OR NOT cus:Company',?cus:CompanyName,3)
 Customer.AddRule('LastNameRequired','Last name is required', |
                  'cus:LastName <;<;> OR cus:Company',?cus:LastName,3)
 Customer.AddRule('CityRequired','City is required','cus:City <;<;> ',?cus:City,3)
 Customer.AddRule('StateRequired','State is required','cus:State <;<;> ',?cus:State,3)
 Customer.AddRule('ZipOK','Postal code must have valid format.',
                  'CheckCustomerZip()',?cus:ZipCode,3)  
 Customer.AddRule('CreditLimit','Credit limit must not exceed $1000.00',
                  'cus:CreditLimit =<;<; 1000',?cus:CreditLimit,3)
addrule_add_a_rule_to_this_collection_.htm.txt · Last modified: 2021/04/15 15:56 by 127.0.0.1