You are on page 1of 3

Ranges Defined Within a Program for the Add Attribute Command

The range clause allows you to use a program to define range values. This allows the
flexibility to change range values depending on conditions. Use the range program
clause to specify the name of the program to execute.
Note: Dimensions are not supported with attributes that have range values.

For example:

range program
SetRanges;

In this example, the name of the program to execute is SetRanges.

You can define arguments to be passed into the program. Your program could change the
attribute range depending on the argument passed. For example:

range program SetRanges


attrang1;

When you pass arguments into the program they are referenced by variables within the program.
Variables 0, 1, 2. . . and so on are reserved by the system for passing in arguments.

Environment variable “0” always holds the program name and is set automatically by the system.

Arguments following the program name are set in environment variables “1”, “2”, . . . and so on.

Programs should return the list of choices in the variable that has the same name as the program
name, which can be obtained through argument “0.” Be sure to use the global keyword on your
set env command when passing the list back.

The following is output from a MQL session. The attribute type ‘designerName’ produces the
choices ‘Tom,’ ‘Dick,’ ‘Harry,’ ‘Larry,’ ‘Curly,’ and ‘Moe.’ An attribute type can have any number of
ranges, but only one range can be of type program.

MQL<1>print attr designerName;


attribute designerName
type string
description
default Tom
range = Tom
range = Dick
range = Harry
range uses program nameRange
not multiline
MQL<2>print prog nameRange;
program nameRange
mql
description
code 'tcl;
eval {
# set the event
set event [mql get env EVENT]
# set the choices
set names {Larry Curly Moe}
# set the output variable (arg 0 is this program's name)
set output [mql get env 0]
# test event, and either generate choices, or test value
if { $event == "attribute choices"} {
# note that choices are returned in a global RPE variable
mql set env global $output $names
} else {
# assume that it is safe to unset global RPE variable during value
test
mql unset env global $output
# set the value
set value [mql get env ATTRVALUE]
# test the value
if {[lsearch -exact $names $value] == -1} {
# value not in list, return non-zero
exit 1
} else {
# value in list, return zero
exit 0
}
}
}
The following macros are available to Range Programs:

 Owning item information macros:


 If the attribute is “owned” by a business object, these macros are available:
OBJECT, TYPE, NAME, and REVISION.
 If a relationship instance “owns” the attribute, the RELID macro is provided.
 During query formulation the owner is unknown so no owner macros are
available.
 INVOCATION will always equal “range”.
 EVENT and possibly ATTRVALUE. For example:
 When the range program is being asked to produce all legal values, EVENT
equals “attribute choices”.
 When the range program is being asked to check the legality of a given value,
EVENT equals “attribute check” and the ATTRVALUE macro is also provided.
 ATTRNAME and ATTRTYPE. For example:

ATTRNAME=designerName

ATTRTYPE=String

 Basic information: VAULT, USER, TRANSACTION, HOST, APPLICATION, and


LANGUAGE.

For more information about macros, see Appendix: Macros.

Trigger Clause for the Add Attribute Command

Event Triggers provide a way to customize 3DSpace behavior through Program


Objects. Triggers can contain up to three Programs, (a check, an override, and an action
program) which can all work together, or each work alone. Attributes support the use of
triggers on the modify event.

For more information, see Trigger Event Macros. The syntax for the trigger clause is:

trigger modify {action|check|override} PROG_NAME [input


ARG_STRING];

For example, to assign a check trigger called OnApprove, you would use:

trigger modify check


OnApprove;

In this example, the name of the program to execute is OnApprove.

You can define arguments to be passed into the program. For example:

trigger modify check OnApprove input


ChngChk;

In this example, the argument passed into the OnApprove program is ChngChk.

When you pass arguments into the program they are referenced by variables within the program.
Variables 0, 1, 2… and so on. are reserved by the system for passing in arguments.

Environment variable “0” always holds the program name and is set automatically by the system.

Arguments following the program name are set in environment variables “1”, “2”,… and so on.

You might also like