How to go step-by-step in DialogBox

Hi,

I wanna firstly set which module I wanna use in a dialog box, then by using these values, the selected module's attributes is updated automatically for that DBE.

For the following code, I first read the folder's modules and make a choice DBE. In here I have problems with reading the selected module's attributes. In my code only selected module's attributes can be displayed.

I have a ordering problem for the code. I want to first, choose the module, and by choosing the module, below DBE for the selected module attributes is displayed...

Need your help...
 

//Source Module should be OPEN!
 
pragma runLim, 0
 
Module mCurrent = current
 
if (null mCurrent) {
         infoBox "Open the source module first and Edit DXL!"
         halt
}
string smName = name mCurrent
Module mAttr = read (smName)
AttrDef attr
 
// Define array size
int counter2 = 0
 
for attr in mAttr do counter2++
 
string sAttr[counter2]
 
counter2 = 0
// Define array
for attr in mAttr do {
         string stName = attr.(name) 
         sAttr[counter2] = {stName}
         counter2++
}
 
// Define array size
int counter1 = 0
Item i
for i in current Folder do counter1++
 
string moduleList[counter1] 
counter1 = 0
 
// Define array 
for i in current Folder do {
         string sName = name i
         moduleList[counter1] = {sName}
         counter1++
}
 
DB dylgBx = create ("My dialog box")
DBE dbeSrc = choice (dylgBx, "Select Source Module", moduleList, sizeof(moduleList), 0, 20, true)
DBE dbeAttr = list (dylgBx, "Select the attribute including link numbers", 100, 5, sAttr, sizeof (sAttr))
 
void getValues (DB dylgBx) {
         string nameSrc = get dbeSrc
 
         string nameAttr = get dbeAttr
         
         Module sourceModule = edit(nameSrc)
 
 
}
 
apply (dylgBx, "Accept!", getValues)
show dylgBx

ozguraltay - Tue Jan 31 11:49:24 EST 2012

Re: How to go step-by-step in DialogBox
Rolan - Tue Jan 31 12:14:52 EST 2012

If you look in your DOORS installation, you should be able to locate the example dxl file LinkByKey.dxl, which I believe actually does what you want.
It allows you to select a target module and then updates a list of attributes for that module from which you can make a selection.
I find this file on my machine at C:\Program Files(x86)\IBM\Rational\DOORS\9.3\lib\dxl\example\LinkByKey.dxl.

Re: How to go step-by-step in DialogBox
ozguraltay - Tue Jan 31 13:48:17 EST 2012

Rolan - Tue Jan 31 12:14:52 EST 2012
If you look in your DOORS installation, you should be able to locate the example dxl file LinkByKey.dxl, which I believe actually does what you want.
It allows you to select a target module and then updates a list of attributes for that module from which you can make a selection.
I find this file on my machine at C:\Program Files(x86)\IBM\Rational\DOORS\9.3\lib\dxl\example\LinkByKey.dxl.

This code was just an example, not actually doing something.

I need a simple code to select a module first, and get the attributes of it. That example is hard to simplify for me...

Re: How to go step-by-step in DialogBox
llandale - Tue Jan 31 13:56:41 EST 2012

Yes you need a two-stage dialog; present the names of the modules and when one is selected, then open that module and present a list of its attributes.

The 2nd part should be "blocked" to make sure the user doesn't close the module while the dialog is open. I would make this two small dialogs, the first is hidden and destroyed during the "read the module" part, and then "block" the second.

I suggest you skip the first step and make this script one that requires a "Module" as scope. Open the module edit, then run the script from it. Following code will help.

Module g_mCurr = current
if (null g_mCurr or !isEdit(g_mCurr))
{ errorBox("Run from edited open module")
halt
}
-Louie

Be advised that your dialog code can get activated via a button the user pushes, but you can also assign a callback to a DBE, so when the user clicks in the DBE your code auto-fires.
void clbkModuleSelect(DBE dbeXX)
{ int iModNum = read(dbeModuleList)
figure out which module
if invalid //
then show (again) the dialog
else hide and destroy dialog, open, read, present 2nd dialog
}
...
dbeList = the module list DBE
set(dbeList, clbkModuleSelect) // assign callback

Re: How to go step-by-step in DialogBox
ozguraltay - Wed Feb 01 04:23:35 EST 2012

llandale - Tue Jan 31 13:56:41 EST 2012
Yes you need a two-stage dialog; present the names of the modules and when one is selected, then open that module and present a list of its attributes.

The 2nd part should be "blocked" to make sure the user doesn't close the module while the dialog is open. I would make this two small dialogs, the first is hidden and destroyed during the "read the module" part, and then "block" the second.

I suggest you skip the first step and make this script one that requires a "Module" as scope. Open the module edit, then run the script from it. Following code will help.

Module g_mCurr = current
if (null g_mCurr or !isEdit(g_mCurr))
{ errorBox("Run from edited open module")
halt
}
-Louie

Be advised that your dialog code can get activated via a button the user pushes, but you can also assign a callback to a DBE, so when the user clicks in the DBE your code auto-fires.
void clbkModuleSelect(DBE dbeXX)
{ int iModNum = read(dbeModuleList)
figure out which module
if invalid //
then show (again) the dialog
else hide and destroy dialog, open, read, present 2nd dialog
}
...
dbeList = the module list DBE
set(dbeList, clbkModuleSelect) // assign callback

I think I coulnd't explain my problem well.

For example for the following code I can list the modules in folder and attributes in module independently. I want the attributes DBE to change, according to the value I choose for selected module on the top.
 

pragma runLim, 0
 
Module mCurrent = current
 
string smName = name mCurrent
Module mAttr = read (smName)
AttrDef attr
 
// Define array size
int counter2 = 0
 
for attr in mAttr do counter2++
 
string sAttr[counter2]
 
counter2 = 0
// Define array
for attr in mAttr do {
    string stName = attr.(name) 
        sAttr[counter2] = {stName}
        counter2++
}
 
// Define array size
int counter1 = 0
Item i
for i in current Folder do counter1++
 
string moduleList[counter1] 
counter1 = 0
 
// Define array 
for i in current Folder do {
        string sName = name i
        moduleList[counter1] = {sName}
        counter1++
}
 
DB dylgBx = create ("My dialog box")
DBE dbeSrc = choice (dylgBx, "Select Source Module", moduleList, sizeof(moduleList), 0, 20, true)
DBE dbeAttr = list (dylgBx, "Select the attribute including link numbers", 100, 5, sAttr, sizeof (sAttr))
 
 
void getValues (DB dylgBx) {
        string nameSrc = get dbeSrc
 
        string nameAttr = get dbeAttr
        
        Module sourceModule = edit(nameSrc)
        
}
 
apply (dylgBx, "Accept!", getValues)
show dylgBx

Re: How to go step-by-step in DialogBox
llandale - Wed Feb 01 14:29:16 EST 2012

ozguraltay - Wed Feb 01 04:23:35 EST 2012

I think I coulnd't explain my problem well.

For example for the following code I can list the modules in folder and attributes in module independently. I want the attributes DBE to change, according to the value I choose for selected module on the top.
 

pragma runLim, 0
 
Module mCurrent = current
 
string smName = name mCurrent
Module mAttr = read (smName)
AttrDef attr
 
// Define array size
int counter2 = 0
 
for attr in mAttr do counter2++
 
string sAttr[counter2]
 
counter2 = 0
// Define array
for attr in mAttr do {
    string stName = attr.(name) 
        sAttr[counter2] = {stName}
        counter2++
}
 
// Define array size
int counter1 = 0
Item i
for i in current Folder do counter1++
 
string moduleList[counter1] 
counter1 = 0
 
// Define array 
for i in current Folder do {
        string sName = name i
        moduleList[counter1] = {sName}
        counter1++
}
 
DB dylgBx = create ("My dialog box")
DBE dbeSrc = choice (dylgBx, "Select Source Module", moduleList, sizeof(moduleList), 0, 20, true)
DBE dbeAttr = list (dylgBx, "Select the attribute including link numbers", 100, 5, sAttr, sizeof (sAttr))
 
 
void getValues (DB dylgBx) {
        string nameSrc = get dbeSrc
 
        string nameAttr = get dbeAttr
        
        Module sourceModule = edit(nameSrc)
        
}
 
apply (dylgBx, "Accept!", getValues)
show dylgBx

OK. User selects module A and you react by opening it invisibly, reading its attribute names, and displaying them in the list. When user selects module B then you erase the previous list and build a new one.

Sorry I don't recall the syntax
You must remove all rows of the previous list; usually that's this:

for (iRow = NumCurrentRows-1; iRow >= 0; iRow--)
{  delete(dbeList, iRow)
}
// or this
for (i = 0; i < NumCurrentRows; i++)
{  delete(dbeList, 0)
}
// when you delete row zero, the other rows are demoted and there is a new row zero.


Once the DBE is empty, you must insert the new rows. Without a doubt its easier to insert them from row zero on up; as if you insert two row zeros then the 1st is prompted to row 1 and its hard to keep track of it.

int iRow = 0
for NameAttr in the module I want to display
{  set(dbeList, iRow, NameAttr)
   iRow++
   put(skpListNames, iRow, NameAttr)
}
Store iRow globally (NumCurrentRows = iRow) so the remove code above knows how many rows there are.

When a user selects an attribute, you read the list number and can deduce the attribute name selected:

 

iRowSelected = get(dbeList)
find(skpListNames, iRowSelected, NameAttr)

-Louie

 

Re: How to go step-by-step in DialogBox
ozguraltay - Fri Feb 03 02:33:26 EST 2012

llandale - Wed Feb 01 14:29:16 EST 2012

OK. User selects module A and you react by opening it invisibly, reading its attribute names, and displaying them in the list. When user selects module B then you erase the previous list and build a new one.

Sorry I don't recall the syntax
You must remove all rows of the previous list; usually that's this:

for (iRow = NumCurrentRows-1; iRow >= 0; iRow--)
{  delete(dbeList, iRow)
}
// or this
for (i = 0; i < NumCurrentRows; i++)
{  delete(dbeList, 0)
}
// when you delete row zero, the other rows are demoted and there is a new row zero.


Once the DBE is empty, you must insert the new rows. Without a doubt its easier to insert them from row zero on up; as if you insert two row zeros then the 1st is prompted to row 1 and its hard to keep track of it.

int iRow = 0
for NameAttr in the module I want to display
{  set(dbeList, iRow, NameAttr)
   iRow++
   put(skpListNames, iRow, NameAttr)
}
Store iRow globally (NumCurrentRows = iRow) so the remove code above knows how many rows there are.

When a user selects an attribute, you read the list number and can deduce the attribute name selected:

 

iRowSelected = get(dbeList)
find(skpListNames, iRowSelected, NameAttr)

-Louie

 

I coulnd't get into that...

I'm working on the code you give to integrate into my code, but no success. Can you help me with that?

And I think there must be another way to do this. the example code in "C:\Program Files (x86)\Telelogic\DOORS_8.3\lib\dxl\example" linkbykey.dxl has the function I need, but I coulnd't simplify it...