How to create a column using a script?

Hello,

In the DXL script attached below, if we manually create a column 'Is a Req' in a module,and then run the script it gets populated. Instead I want the column to be created automatically when I run the script.

Please assist.

Thank You,


kswathi2 - Mon Feb 24 04:53:53 EST 2014

Re: How to create a column using a script?
MichaelGeorg - Mon Feb 24 06:39:08 EST 2014

Hello kswathi2,

first of all you should become aware of the difference between a column and an attribute.

  • Attributes contain information about a module or an object. They are stored in the module and contain the information permanently, regardless if they are currently displayed or not.
  • Columns on the other hand are stored as part of a view and display the information contained in some attribute or in case of Layout-DXL columns the information calculated by the Layout-DXL code.

Anyhow, if you have the module open in edit mode and available as current module you can create a new attribute with the command:

create object type "Text" attribute "Is a req"  //for a text attribute called "Is a req" (see also DXL Reference about AttrDef for more details.)

So if you put this statement before the start of your loop the script should do what you want. 

However your script does only set the information for all object at the time it is executed. If you want the column to be always up to date and show if currently an object "Is a req" you need to use a Layout-DXL column or a DXL Attribute. (See  DXL Reference "Layout DXL" and "Attribute Definitions" for more details.)

 - Michael

Re: How to create a column using a script?
kswathi2 - Tue Feb 25 04:43:46 EST 2014

Hello,

I want to modify the above script such that when I run that script a column should be created "Is a Req" and it should verify the object text of every object for 'shall' and flag the result accordingly in 'Is a Req' column.

Please assist.

Thank You,

Re: How to create a column using a script?
GregM_dxler - Tue Feb 25 10:52:07 EST 2014

kswathi2 - Tue Feb 25 04:43:46 EST 2014

Hello,

I want to modify the above script such that when I run that script a column should be created "Is a Req" and it should verify the object text of every object for 'shall' and flag the result accordingly in 'Is a Req' column.

Please assist.

Thank You,

At the beginning of your script, you can add a column by the commands:

insert (column 1) //insert the column to the left of the second column

attribute(column 1, Srcattr) //sets the column data to your attribute

width(column1, 150) //specifies the width of the column so it is not skinny

refresh currentModule //refresh so it gets displayed

You might want to think if you want to first check to see if that attribute is already displayed in a column.

Hope this helps,

Greg