Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Count Shalls in Project formal modules
Topic Summary:
Created On: 3-Nov-2006 17:20
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Michael Cors, on Tuesday, March 13, 2007 2:29 PM

Answer:

Looks like you need something more like this:

Project thisProject = current

Item thisItem

Module thisModule

Object thisObject

for thisItem in thisProject do {

   ...

   if( type(thisItem) == "Formal") {

      thisModule = read(fullName(thisItem) , false)

      ...

      for thisObject in thisModule do {

         ...

      }

      close(thisModule)

   }

}

I have the same code for a folder. I think it will work for a project also, but did not test it.

 3-Nov-2006 17:20
User is offline View Users Profile Print this message


Chris Annal

Posts: 36
Joined: 14-Dec-2005

I have a script that originally provided information about all the contents of a project. This originally came from the Beaver consultants site. I modified it to remove some of the items I didn't want in my spreadsheet, and also to search through the object text of formal modules for "shalls" (using a regular expression) to provide a count of shalls for each module in the project.
The script below and attached works for capturing module types, paths and module names, but doesn't exclude those modules that aren't "Formal", even though my script calls out if (tempItemType == "Formal").
I also haven't yet figured out how to access the "count" integer from inside the loop, in order to associate that number with each module that was parsed for shalls. I have a separate script for counting
shalls that this was pulled from. It works fine in the original script, but I'm having trouble accessing the variable in the modified script below/attached. Any help would be appreciated.
thanks,
Chris Annal
chrisa@sensis.com

// Document the module structure of a project

/********************************

Script : CountShallsInProject.dxl

(The original script was downloaded from the Beaver Computer Consultants sites and modified

to remove some items not desired (UniqueID and path) in the output report and for the purpose of

counting "shalls" in all the formal modules of a project. The text below is the original text

as it accompanied the script. Chris Annal 11/03/2006)

In the DOORS project explorer select a project and then run this script, which recursively passes

through all folders for the current project, and returns the values of:

- Type of item in project (e.g. formal, descriptive, link,folder,prject - these can then be filtered)

- Full path name of item (DXL funciton fullName)

- uniqueID of item (the module, folder etc, this is whats used in many wizard layout dxl scripts)

- item name (e.g. just the module name)

- path of project / folder being processed.

The output to the dialog box is in csv format, it is suggested the user copies the ouput, pastes into

Excel, and converts text to columns, to format. Alternatively can export the results to a user specified

file, the export checks to see if file already exists and warns if true.

This script is free software; you can redistribute it and/or modify it, and is distributed in

the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of

MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Beaver does not 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 script.

Copyright Beaver Computer Consultants Limited 2003-2005

paul@beaver-consulting.co.uk www.beaver-consulting.co.uk

ToDo

Tabs to show output in both comma separated format and column format.

Add export buttons to Excel and then Word (as a table).

*************/

//Declare variables

Item itemRef

Module m = current

Object o

string results = "", results2 = "", initFile = "c:\\filename.csv", s = ""

string tempFullName,tempName,tempItemType,testFile = ""

Project p = current

Stream outData

//First check we are in a project, if not exit the script

if(null current Project)

{ack " Please select a project in the\n Project Explorer before running this script"

halt}

//**** Function

void collectProjDetails() {

//List the structure for a given module.

results = results "Project : " name p "\n"

results = "Type,Full Path Name,Item Name,ShallCount\n"

for itemRef in current Project do {

// Capture the info

tempFullName = fullName(itemRef)

tempName = name(itemRef)

tempItemType = type(item tempFullName)

// End Capture

// Print info

//for modules in current Project do...

for m in p do {

//If the type of module is Formal, create variables for counting.

if (tempItemType == "Formal") {

Object o

int from = 0

int sstart = 0

int send = 0

int count = 0

Buffer inBuf = create

Buffer outBuf = create

Regexp re = regexp "([Ss]hall)"

//for every object in the module parse the object text for "shall"...

for o in m do

{

inBuf = richTextWithOle(o."Object Text")

outBuf = ""

from = 0

sstart = 0

send = 0

// search inBuf for regexp and apply format tags

while (search(re, inBuf, from))

{

// start and end functions return regexp position relative to where

// search started. Must add starting position to get absolute position

sstart = from + start 0

send = from + end 0

count++

outBuf += inBuf[from:sstart]

from += end 0+1

outBuf += inBuf[from:]

}//end while (search...

 

 

}//end for o in m do...

delete(inBuf)

delete(outBuf)

}//end if module Type is Formal...

}//end for ItemRef in current Project...

results = results tempItemType "," tempFullName "," tempName "\n" //need to access the "count" variable here

// End Print Info

 

} //End loop in items in project

 

ack "Use the dialog box editor using right mouse click to \nselect all and copy to the clipboard\n\nPaste into Excel and convert text to column if needed or use\nexport file function and follow instructions to import to Excel."

}

//**** End function

 

 

DB docuDialog = topMost ("Document project structure") //topMost makes DB stay on top. Alternative to centered "Form View"

DBE exportFile

DBE resultsDisplay

DBE filename

resultsDisplay = text(docuDialog,"",results, 950, 400, true)

filename = fileName(docuDialog, initFile, "*.csv", "Export to file name")

 

collectProjDetails //Calls the main function when script is run

set (resultsDisplay,results)

 

void exportFileFunc (DBE) {

selectedFile = get(filename)

if (results == "")

{infoBox " Please run to populate the\n \"Output\" window before exporting"

return}

string filenameData = selectedFile

testFile = canOpenFile(filenameData,false) ""

if (testFile == "false")

{outData = write filenameData

outData << results

close outData

s = ""

set (resultsDisplay,s)

s = s ("Copied saved to " filenameData "\n\nNote results overwrite not append\n\n\n" results)

set (resultsDisplay,s)

infoBox "File created\n\n\nTo import in to Excel use;\n\nData > Get External Data\nSpecify UniqueID column as type text to preserve any leading zeros"

} //End false output

else

{if (confirm "File already exists. Do you want to overwrite?")

{outData = write filenameData

outData << results

close outData

s = ""

set (resultsDisplay,s)

s = s ("Copied saved to " filenameData "\n\nNote results overwrite not append\n\n\n" results)

set (resultsDisplay,s)

infoBox "File created\n\n\nTo import in to Excel use;\n\nData > Get External Data\nSpecify UniqueID column as type text to preserve any leading zeros"}

else

halt

} //End true output

} //Close exportFileFunction

 

exportFile = button(docuDialog,"Export files to specified location", exportFileFunc)

show docuDialog




Report this to a Moderator Report this to a Moderator
 8-Nov-2006 22:25
User is offline View Users Profile Print this message


Michael Cors

Posts: 7
Joined: 17-Aug-2006

Answer Answer

Looks like you need something more like this:

Project thisProject = current

Item thisItem

Module thisModule

Object thisObject

for thisItem in thisProject do {

   ...

   if( type(thisItem) == "Formal") {

      thisModule = read(fullName(thisItem) , false)

      ...

      for thisObject in thisModule do {

         ...

      }

      close(thisModule)

   }

}

I have the same code for a folder. I think it will work for a project also, but did not test it.

Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 2 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.