// Export module tree /* Export the complete module tree to a file */ // ------------------------------------------------------------------- pragma runLim, 0 // ------------------------------------------------------------------- const string OUT_FILE = "H://Desktop//DOORS_moduleTree.csv" const string ITEM_PROJECT = "Project" const string ITEM_FOLDER = "Folder" const string ITEM_FORMAL = "Formal" const string ITEM_LINK = "Link" const Stream OUTPUT int nMod = 0 // ------------------------------------------------------------------- bool writeFileHeader(string filename) { // Try to open output file bool returnValue = false if (canOpenFile(filename, true)) { // User can write to Stream returnValue = true OUTPUT = write filename OUTPUT << "\"Name\",\"Full path\",\"Type\"," OUTPUT << "\"Modification date\",\"User\"\n" } // User can write to Stream return returnValue } // Try to open output file // ------------------------------------------------------------------- void addModuleInfo(Item i, Buffer &buf) { // For modules, add specific information Module mod Date d if (type i == ITEM_FORMAL) { // Item is a formal module mod = read(fullName i, false) if (!null mod) { // Successfully opened module buf += "," buf += "\"" d = mod."Last Modified On" buf += d "" buf += "\"" buf += "," buf += "\"" buf += mod."Last Modified By" "" buf += "\"" close mod; mod = null } // Successfully opened module else { // Problems opening module buf += "," buf += "\"" buf += "Failed to read module" buf += "\"" } // Problems opening module } // Item is a formal module mod = null } // For modules, add specific information // ------------------------------------------------------------------- void printItemInfo(Item i) { // Print information on item Buffer buf = create if (type i != ITEM_LINK) { // Item is no link module buf = "\"" buf += name i buf += "\"" buf += "," buf += "\"" buf += fullName i buf += "\"" buf += "," buf += "\"" buf += type i buf += "\"" OUTPUT << tempStringOf buf close OUTPUT buf = "" OUTPUT = append OUT_FILE //addModuleInfo(i, buf) buf += "\n" OUTPUT << tempStringOf buf } // Item is no link module delete buf } // Print information on item // ------------------------------------------------------------------- void scanItem(Item i) { // Loop through folder string item_type Folder f Project p Item i_loop if (!null i) { // Item is not null item_type = type(i) printItemInfo(i) if (item_type == ITEM_PROJECT) { // Item is a project f = folder fullName i for i_loop in f do {scanItem(i_loop)} } // Item is a folder else if (item_type == ITEM_FOLDER) { // Item is a folder f = folder i for i_loop in f do {scanItem(i_loop)} } // Item is a folder or project } // Item is not null } // Loop through item // ------------------------------------------------------------------- void scanCurrentFolder() { // Scan the current folder Folder f if (writeFileHeader(OUT_FILE)) { // Open output file and loop through current folder f = current scanItem(item fullName f) close OUTPUT } // Open output file and loop through current folder } // Scan the current folder // ------------------------------------------------------------------- void scanDatabase() { // Scan the complete database Item i if (writeFileHeader(OUT_FILE)) { // Open output file and loop through database i = item "/" scanItem(i) close OUTPUT } // Open output file and loop through database } // Scan the complete database // ------------------------------------------------------------------- scanDatabase() // ------------------------------------------------------------------- ----------------------