![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
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 |
![]() |
![]()
|
![]() 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 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
|
|||
![]() |
|||
![]() |
|||
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) } } |
|||
![]() |
Telelogic DOORS
» DXL Exchange
»
Count Shalls in Project formal modules
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.