For example:
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:
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
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:
For more information about macros, see Appendix: Macros. |