Hello. There is this kitchen dxl "applymods", and he works perfectly. I write the atribute, then the value and the dxl apply the filter. But I wanted somenthing more complex. For example: I choose atribute "Absolute Number", but I don't want just the object that the absolute number == 8, I want a bigger filter, 8 || 10 || 11 There is a way to do it in this dxl? Someone can give me a tip?
// Apply a filter to all open modules
/*
Applies a simple filter to all open modules.
*/
/*
Kitchen Tools for customizing DOORS with DXL V7.1
-------------------------------------------------
DISCLAIMER:
This programming tool has been thoroughly checked
and tested at all stages of its production.
Telelogic cannot accept any responsibility for
any loss, disruption or damage to your data or
your computer system that may occur while using
this script.
If you do not accept these conditions, do not use
this customised script.
-------------------------------------------------
*/
/* History: Who When What
JD 99/11/05 Creation
*/
if ( !confirm "This script will apply an attribute filter to all open modules.\n\n" //-
"Continue?"
)
{
halt
}
//////////////////////////////////////////////
// Constants
const string modChoices[] = { "All open modules", "Current module only" }
//////////////////////////////////////////////
// Variables
Module currMod = current
//////////////////////////////////////////////
// Regular expressions
//////////////////////////////////////////////
// Dialogue boxes
DB applyFilterDB = null
DBE attrName = null
DBE attrVal = null
DBE useRegExp = null
DBE applyChoices = null
DBE applyButton = null
//////////////////////////////////////////////
// Auxiliary functions
//////////////////////////////////////////////
// Call-backs
void doFilter(DB db)
{ // apply filter to modules
current = currMod
int chce = get(applyChoices)
bool allMods = ( modChoices[chce] == "All open modules" )
bool useRE = get(useRegExp)
string an = get(attrName)
string av = get(attrVal)
Skip mods = create()
Module m = current
put(mods, m, m)
if ( allMods )
{ // collect handles on all open formal modules
for m in current Project do
{ // loop through all open modules
if ( type(m) != "Formal" ) continue
put(mods, m, m)
}
}
// process modules
for m in mods do
{ // loop through all selected modules
current = m
if ( !exists attribute an )
{ // named attribute does not exist in current module
ack "Attribute '" an "' does not exist in module '" (m."Name" "") "'"
continue
}
filtering(off)
if ( useRE )
{ // apply filter as regular expression
Regexp re = regexp av
Object o
for o in m do
{ // loop through all objects
if ( isDeleted(o) ) continue
if ( re (o.an "") ) accept o
else reject o
}
} else
{ // construct standard filter
set(m, attribute an == av)
}
filtering(on)
refresh(m)
}
}
//////////////////////////////////////////////
// Main program
applyFilterDB = create("Apply filter to multiple modules")
attrName = field (applyFilterDB, "Name of attribute:", "", 40)
attrVal = field (applyFilterDB, "Value of attribute:", "", 40)
useRegExp = toggle(applyFilterDB, "Use regular expression", false)
applyChoices = radioBox(applyFilterDB, "Apply filter to:", modChoices, 0)
applyButton = apply(applyFilterDB, "Filter", doFilter)
show applyFilterDB
Bruwbruw - Fri Feb 20 12:22:18 EST 2015 |
Re: Kitchen Filter dxl Greetings, I've done a similar type of filter where you can specify a list of object identifiers and then it will filter for them. To do this, you will need to modify the script to parse the attribute value entry and then change the set filter to use the accept/reject instead of a set. For the parsing, a code snippet like this will work. It parses the data and puts it into a skip list (not all dxl code is here)
For the filtering, you use the following routine instead of the set(m attribute an=av). It loops through the objects and the skip list and accept the ones it finds and reject the ones it doesn't.
Hope this helps, Greg |