Customizing the metamodel > What you can do with USRPROPS/SAPROPS > Conditional commands
  
Conditional commands
There are two types of conditional commands that can be used with SAPROPS:
ifdefs and ifndefs
TestProcs
Ifdef command
if def (if definition) tests properties selected on an encyclopedia-wide level in the Configuration Dialog box. For example, an ifdef statement in SAPROPS tests if Java properties have been turned on for the encyclopedia, and if they have, additional properties specific to Java are added to the appropriate definition, for example, class, method, and attribute definition.
if not def tests if a property has not been selected.
TestProcs command
The test proc (test procedure) conditionals examine test properties that are selected on a diagram-wide level, in the Diagram properties dialog. TestProc enables the user to present a different definition for the same exact property, depending on the test string selected for the diagram. A control statement references the property, and provides a specific occurrence of it in the Definition. For example:
The attribute definition, a TestProc is used to test the database property value selected for the currently open diagram. A control statement presents a different definition for the same property, Key, depending on the selected database. The same goes for other properties treated as controls: Foreign Key and Nullity, among others.
The data domain definition, a TestProc is used to test the database property value selected for the currently open diagram. A control statement presents a different definition for the same property, Business Unit, depending on the selected database.
Note For controls to be used, they must reference a property that is called out at the top of the definition. If a control references a property that does not exist in that definition, you will get an error while parsing USRPROPS.TXT.
In the following example, the properties Key, Foreign Key, Default Nullity, and Unique are specified the first time they are mentioned in the definition of an attribute. Later, they are referenced by control statements, in other test strings.
DEFINITION "Attribute"
{
CHAPTER "General Properties (generic with comment)" LABEL "General Properties"
{ TESTPROC TestPropertyValue TESTPROPERTY "DBMS"
TESTSTRING { "Oracle 7" "Oracle 8" "OS/2 Database Manager" "Rdb" "SQLBase" "SYBASE SQL Anywhere" "Teradata" "WATCOM SQL V4" } }
GROUP "Attribute Designation" {
PROPERTY "Key"
{ EDIT Boolean Length 1 VALUESCRIPT ProcessAttrKeyChange LABEL "PK" "Primary Key"}
PROPERTY "Foreign Key"
{ EDIT BOOLEAN LENGTH 1 DEFAULT "F" LABEL "FK" "Foreign Key" READONLY }
PROPERTY "Default Nullity"
{ EDIT Boolean Length 1 Default "F" LABEL "Allow Null" "Allow Null" }
PROPERTY "Unique"
{EDIT Boolean LENGTH 1 DEFAULT "F" }
}
CHAPTER "AS400SQL, DB2, XDB General Properties"
LABEL "General Properties"
{ TESTPROC TestPropertyValue TESTPROPERTY "DBMS"
TESTSTRING { "AS/400 SQL" "AS/400 V3 SQL" "DB2 V2" "DB2 V3" "DB2 V4" "XDB V2" "XDB V3" }
}
GROUP "AS400SQL, DB2, XDB Attribute Designation" LABEL "Attribute Designation"
{
Control "DB2 Key" { REFPROP "Key" }
Control "DB2 FK" { REFPROP "Foreign Key" }
Control "DB2 Default Nullity" { REFPROP "Default Nullity" }
Control "DB2 Unique" { REFPROP "Unique" }
}
See also
What you can do with USRPROPS/SAPROPS