I am aware of the dxl in the help file to list views in a module, but I would like to be able to run a script from the database window on a project to see what views are in each module in a project.
I have created a template view and am propagating it to various projects, but it seems to be working intermittently. Rather than open the hundreds of modules to verify the propagation, I'd rather run a script, but have been unable to modify the "list views in module" dxl in the help file.
Would appreciate any assistance.
Rich
From Help File:
///////////////////////
for view in module
Syntax
for s in views(Module m) do {
...
}
where:
s is a string variable
m is a module of type Module
Operation
Assigns the string s to be each successive view name in the module m.
Example
This example prints all views in the current module:
string name
for name in views current Module do
print name "\n"
///////////////////////
richmason - Mon Mar 02 08:58:23 EST 2009 |
|
Re: List Views in Project kbmurphy - Mon Mar 02 14:31:52 EST 2009
You'll need to recurse through the entire project. Lookup the recursefoldersforformalmodules function in the old telelogic forums.
Once you do that, the logic is quite sound.
//code snippit
Module m = read(fullName(parentItem), true)
print fullName m "\n"
string s
for s in views (m) do
print "\t" s "\n"
close m
//end code snippit
|
|
Re: List Views in Project llandale - Mon Mar 02 15:40:08 EST 2009 kbmurphy - Mon Mar 02 14:31:52 EST 2009
You'll need to recurse through the entire project. Lookup the recursefoldersforformalmodules function in the old telelogic forums.
Once you do that, the logic is quite sound.
//code snippit
Module m = read(fullName(parentItem), true)
print fullName m "\n"
string s
for s in views (m) do
print "\t" s "\n"
close m
//end code snippit
Yup.
The notion of 'current Module' only really applies when you are running a DXL from an open module. Even then, scripts should routinely do this: Module mCurr = current at the top of the DXL, and refer to variable 'mCurr' when they want to do stuff, like loop through the views.
As for views, you need to load the view in order to query its columns, and that means the module must be open visibly, and that takes an ENOURMOUS amount of time; measured in minutes rather than seconds.
|
|
Re: List Views in Project richmason - Mon Mar 02 16:48:43 EST 2009 llandale - Mon Mar 02 15:40:08 EST 2009
Yup.
The notion of 'current Module' only really applies when you are running a DXL from an open module. Even then, scripts should routinely do this: Module mCurr = current at the top of the DXL, and refer to variable 'mCurr' when they want to do stuff, like loop through the views.
As for views, you need to load the view in order to query its columns, and that means the module must be open visibly, and that takes an ENOURMOUS amount of time; measured in minutes rather than seconds.
thanks, will give it a try and report back. I do not need to know any other info about a view than it's name so I don't think I have to worry about column reading.
|
|
Re: List Views in Project richmason - Tue Mar 03 08:10:02 EST 2009 kbmurphy - Mon Mar 02 14:31:52 EST 2009
You'll need to recurse through the entire project. Lookup the recursefoldersforformalmodules function in the old telelogic forums.
Once you do that, the logic is quite sound.
//code snippit
Module m = read(fullName(parentItem), true)
print fullName m "\n"
string s
for s in views (m) do
print "\t" s "\n"
close m
//end code snippit
wasn't able to find the function you referenced at the old forums.
looked here: https://forum.telelogic.com/customer/doors/index.cfm?vid=340
am still lost
thanks
|
|
Re: List Views in Project richmason - Tue Mar 03 09:24:37 EST 2009 richmason - Tue Mar 03 08:10:02 EST 2009
wasn't able to find the function you referenced at the old forums.
looked here: https://forum.telelogic.com/customer/doors/index.cfm?vid=340
am still lost
thanks
Ok, so as it happens I was able to find the recurse code, by accident in another script I had for listing all modules in the database, and as advertised, it took forever to compile.
the code below will look through the entire database and list all modules and their views.
next thing I need to work on for it is to only look at the current project and not all projects. AND/OR not have to open the modules. Is that possible?
thanks
///////////
void recurseFoldersForFormalModules( Item parentItem ) {
string itemType = type( parentItem )
if ( ( itemType == "Folder" ) || ( itemType == "Project" ) ) {
Item childItem
for childItem in folder( parentItem ) do {
recurseFoldersForFormalModules( childItem )
}
}
if ( itemType == "Formal" ) {
print fullName( parentItem ) "\n"
Module m = read(fullName(parentItem), true)
//print fullName m "\n"
string s
for s in views (m) do {
print "\t" s "\n"
}
close m
}
}
recurseFoldersForFormalModules( item( "/" ) )
////////////////
|
|
Re: List Views in Project llandale - Tue Mar 03 18:25:57 EST 2009 richmason - Tue Mar 03 09:24:37 EST 2009
Ok, so as it happens I was able to find the recurse code, by accident in another script I had for listing all modules in the database, and as advertised, it took forever to compile.
the code below will look through the entire database and list all modules and their views.
next thing I need to work on for it is to only look at the current project and not all projects. AND/OR not have to open the modules. Is that possible?
thanks
///////////
void recurseFoldersForFormalModules( Item parentItem ) {
string itemType = type( parentItem )
if ( ( itemType == "Folder" ) || ( itemType == "Project" ) ) {
Item childItem
for childItem in folder( parentItem ) do {
recurseFoldersForFormalModules( childItem )
}
}
if ( itemType == "Formal" ) {
print fullName( parentItem ) "\n"
Module m = read(fullName(parentItem), true)
//print fullName m "\n"
string s
for s in views (m) do {
print "\t" s "\n"
}
close m
}
}
recurseFoldersForFormalModules( item( "/" ) )
////////////////
Change the 'true' to 'false' in the 'read' command; you don't need the modules open visibly; runs much faster when invisible.
Replaced the last line with the following:
if (confirm("All Modules in entire database?")) recurseFoldersForFormalModules( item( "/" ) )
elseif(!null current Project and confirm("All modules in current Project and below"))
recurseFoldersForFormalModules( item( fullName(current Project)) )
elseif(confirm("All modules in current Folder and below?"))
recurseFoldersForFormalModules( item( fullName(current Folder)) )
else{} // nothing to do
The current project prompt is actually a little misleading. If this project has a nested project, that nested project will be recursed as well; oh well.
While I've got some scripts that work on the current Project, the vast majority of my scripts work on the current folder, and all subordinate folders and modules; and optionally subordinate Projects. These scripts have this:
Folder g_fCurr = current at the top, and my main functions work on a Folder parameter (instead of an Item parameter, as in this script).
>Louie
|
|
Re: List Views in Project richmason - Wed Mar 04 07:02:55 EST 2009 llandale - Tue Mar 03 18:25:57 EST 2009
Change the 'true' to 'false' in the 'read' command; you don't need the modules open visibly; runs much faster when invisible.
Replaced the last line with the following:
if (confirm("All Modules in entire database?")) recurseFoldersForFormalModules( item( "/" ) )
elseif(!null current Project and confirm("All modules in current Project and below"))
recurseFoldersForFormalModules( item( fullName(current Project)) )
elseif(confirm("All modules in current Folder and below?"))
recurseFoldersForFormalModules( item( fullName(current Folder)) )
else{} // nothing to do
The current project prompt is actually a little misleading. If this project has a nested project, that nested project will be recursed as well; oh well.
While I've got some scripts that work on the current Project, the vast majority of my scripts work on the current folder, and all subordinate folders and modules; and optionally subordinate Projects. These scripts have this:
Folder g_fCurr = current at the top, and my main functions work on a Folder parameter (instead of an Item parameter, as in this script).
>Louie
smooth like silk. 1000 cocktails to you sir.
thanks for everybody's help.
|
|