printing out a view description

Using this nice script to print out the names of views for all modules in a project. I'd like to also print out the view description. anyone have a quick snippet that I can add to the for loop?

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"
// print out the view description

}
close m
}
}

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)) )
SystemAdmin - Tue May 18 08:42:55 EDT 2010

Re: printing out a view description
llandale - Tue May 18 10:48:08 EDT 2010

Use this before and after your code to make it readable: "{ c o d e }", without the quotes nor spaces.

Its convoluted, but this should work:

View      viu
ViewDef vd
string  Desc
Module  m = read(fullName(parentItem), true) 
current = m
print fullName m "\n"
string s
for s in views (m) do {
   viu  = view(s)
   vd   = get(m, viu)
   Desc = getViewDescription (vd)
   print "\t" s "\t'" Desc "'\n"
}
close m

 

 

  • Louie

 

 

Re: printing out a view description
SystemAdmin - Tue May 18 14:50:16 EDT 2010

That did it, thanks!

Re: printing out a view description
SystemAdmin - Tue May 18 14:56:21 EDT 2010

SystemAdmin - Tue May 18 14:50:16 EDT 2010
That did it, thanks!

for those who want it:
FWIW I used a buffer because I was getting weird alignment where there are multiple lines in the description or the word AND, but it didn't help. Might be the way Excel is interpreting the newlines.... Not worth worrying about right now.
 

// script to list all views in all modules of a project, with their descriptions
// select the project folder, and cancel the first dialog, and ok the second one
// otherwise it will print for the entire database
 
void recurseFoldersForFormalModules( Item parentItem ) {
View      viu
ViewDef vd
string Desc
//string        Desc
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 {
Buffer b = create
 
   viu  = view(s)
   vd   = get(m, viu)
   Desc = getViewDescription (vd)
        b += Desc
 
   print "\t" s "\t" b "\n"
delete b
 
}
close m
}
}
 
 
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

Re: printing out a view description
llandale - Tue May 18 17:24:19 EDT 2010

SystemAdmin - Tue May 18 14:56:21 EDT 2010

for those who want it:
FWIW I used a buffer because I was getting weird alignment where there are multiple lines in the description or the word AND, but it didn't help. Might be the way Excel is interpreting the newlines.... Not worth worrying about right now.
 

// script to list all views in all modules of a project, with their descriptions
// select the project folder, and cancel the first dialog, and ok the second one
// otherwise it will print for the entire database
 
void recurseFoldersForFormalModules( Item parentItem ) {
View      viu
ViewDef vd
string Desc
//string        Desc
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 {
Buffer b = create
 
   viu  = view(s)
   vd   = get(m, viu)
   Desc = getViewDescription (vd)
        b += Desc
 
   print "\t" s "\t" b "\n"
delete b
 
}
close m
}
}
 
 
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

You definately need to get that create(buffer) command out of the loop. Creating and deleting Buffers, for some reason, takes a (relatively) huge amount of time compared to using them. Create the buffer before the loop, set it to blanks at the top of the loop, delete it after the loop.

In fact, for most of my library functions that use internal buffers, I just go ahead and declare a 'global' buffer specifically for that function, created outside the function and never deleted. This has drastically speeded up DXL that end up calling these routines 100s of 1000s of times.

Buffer bufRecurseFolders = create()
void recurseFoldersForFormalModules( Item parentItem ) {
...
for s in views (m) do {
  bufRecurseFolders = ""
...


In fact, for low level functions that do not call any other function, I just use a single global buffer for each of these functions, so each doesn't need to declare its own. OK, not really 'in fact' but I'm upgrading them to do so.

 

 

  • Louie