//Documents modules attribute definitions, types, enumerations, defaults, and views with any filters, sorts or show deletes /* Script name : moduleAtrribsView20.dxl Produces listing of ; - attribute definitions, its underlying type (including whether its attribute dxl), and the default value if set - attribute types, and if applicable, their enumerations - list of views - for each view, list for each column the title, underlying attribute (definition, main, or layout dxl),and any filters or sorts If the results show an attribute definition or column uses DXL, then these need to be documented separately to ensure the full behaviour is captured.. This script is freeware; feel free to redistribute or modify. It is provided without any warranty and no guarantee of fitness for any 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 2002-2004 www.beaver-consulting.co.uk comments to : paul@beaver-consulting.co.uk Version Details V14 PSR Converted to use dialog box V15 PSR Split listing of module and object attrib definitions V16 PSR Added get sort update V17 PSR Fixed problem with checking for existing export file and canceling correctly. V18 PSR Includes output to indicate if attribute definition includes attribute dxl and add warnings to results V19 PSR Filters out RTF attributes which are not system defined but created as user defined when the standard RTF import is run V20 PSR Shows whether the view is set to show deleted objects and divider line between views */ //Definitions Module m = current Object o string results = "", results2 = "", initFile = "c:\\filename.txt", s Filter f = current string tempFilter = "", sortOnView = "", viewDeletedObjects = "" Sort viewSort AttrDef ad AttrType at string objAttrName, d = "", dx = "" int attribDXL = 0, viewDXL = 0 //End definitions //Test to ensure a formal module is open and is current if (null current Module) {infoBox "Please run this script from a formal module" halt} //End Test to ensure a formal module is open and is current //**** Function void collectStabData() { results = "Information model for module : " m."Name" "\nDescription : " m."Description" "\nPrefix : " m."Prefix" "\n\n" results = results "******** Module \"attribute definitions\" (user defined) in module : " m."Name" " ****\n\n" for ad in current Module do { at = ad.type {if (ad.module "" == "true" && ((ad.name "" != "Color Table") && (ad.name "" != "File Table" ) && (ad.name "" != "Font Table" )&& (ad.name "" != "Rev Table") && (ad.name "" != "RTF Author") && (ad.name "" != "RTF DocFormat") && (ad.name "" != "RTF Header") && (ad.name "" != "RTF Info") && (ad.name "" != "RTF Operator") && (ad.name "" != "RTF Subject") && (ad.name "" != "RTF Title") && (ad.name "" != "Style Sheet"))) {if (! ad.system) {if (ad.defval) {d = ad.defval} if (ad.dxl) {dx = ad.dxl attribDXL++} results = results ad.name " : Type - " at.name if (d != "" && dx == "") results = results " : Default - " d "\n" if (d != "" && dx != "") results = results " : Default - " d ": Attribute DXL\n" if (d == "" && dx != "") results = results " : Attribute DXL\n" if (d == "" && dx == "") results = results "\n" d = "" dx = ""} } //If on RTF's (swap this order) } //if ad.system } results = results "\n\n******** Object \"attribute definitions\" (user defined) in module : " m."Name" " ********\n\n" for objAttrName in (current Module) do { ad = find(current Module, objAttrName ) if (ad.defval) {d = ad.defval} if (ad.dxl) {dx = ad.dxl attribDXL++} at = ad.type if (! ad.system && ((objAttrName != "RTF Objclass") && (objAttrName != "RTF Objdata") && (objAttrName "" != "RTF Object") && (objAttrName "" != "RTF Pict"))) {results = results objAttrName " : Type - " (at.name ) if (d != "" && dx != "") results = results " : Default - " d ": Attribute DXL\n" if (d != "" && dx == "") results = results " : Default - " d "\n" if (d == "" && dx != "") results = results " : Attribute DXL\n" if (d == "" && dx == "") results = results "\n" d = "" dx= "" } } //for objAttrName results = results "\n\n******** \"Attribute types\" (user defined) in module : " m."Name" " ********\n\n" for at in current Module do { if (! at.system) results = results at.name " : " (at.type) "\n" } results = results "\n\n******** Enumerations list for \"Attribute Types\" in module ********\n\n" int atCount = 0 string enum_item2 int tmp = 0, cnt = 0 for at in current Module do { if (! at.system) { results = results at.name " : " (at.type) "\n\n" if ((at.type "" == "Enumeration") && (atCount == 0)) {atCount++} atCount = 0 tmp = at.size for (cnt = 0;cnt < tmp;cnt=(cnt + 1)) {results = results "\t" cnt " " at.strings[cnt] "\n"} results = results "\n" } //End if } results = results "******** List of views in module ********\n\n" string name int countViews = 0 //First count the number of views in module so we can specify the array size for name in views current Module do { countViews++ } //End view count //Create array and reset countViews string viewList[countViews] countViews = 0 //reset //End array create and reset //Build array list and list out the views for name in views current Module do { results = results "\t" name "\n" viewList[countViews] = name countViews++ } //End build array string showview = "" countViews = countViews - 1 results = results "\n\n******** View contents ********\n\n" //Take each view name from array and list columns Column c string vname while (countViews >= 0) { showview = viewList[countViews] load view(showview) countViews = countViews - 1 vname = currentView(m) results = results "\n\nView : " vname "\n\n" // Get any filters that have been applied f = current if (! null f) {tempFilter = stringOf(m,f) results = results "Filter is : " tempFilter "\n\n" tempFilter = ""} else results = results "No filter\n\n" // Get any sorts that have been applied viewSort = current if (! null viewSort) {sortOnView = stringOf(viewSort) results = results "Sort is : " sortOnView "\n\n" sortOnView = ""} else results = results "No sort\n\n" // Get whether the view shows deleted objects viewDeletedObjects = showDeletedObjects() "" if (viewDeletedObjects "" == "true") {results = results "Deleted objects shown\n\n"} else results = results "Deleted objects not shown\n\n" // Now list the contents of the view results = results "\tAttribute : (Column Title)\n\n" for c in m do { if (null attrName c) {if (main(c)) results = results "\t
: " (title c) "\n" else {results = results "\t : " (title c) "\n" viewDXL++}} else {results = results "\t<" (attrName c) "> : " (title c) "\n"} }//End for c in m results = results "\n-------------------------------------------------------------------------------------------------------------------------------------------------------------------\n" } if (attribDXL != 0) results = "Warning - One or more attributes contains attribute dxl - this needs to be documented separately\n\n" results "\n\n" if (viewDXL != 0) results = "Warning - One or more views contains layout DXL - this needs to be documented separately\n\n" results } //**** End function //Dialog box DB exBox = topMost ("Document Module") //topMost makes DB stay on top. Alternative to centered "Form View" DBE exportFile DBE calcStab DBE t1 DBE fn void calcStability (DBE) { collectStabData() results2 = results set (t1,results) } //finish calStab void exportFileFunc (DBE) { string selectedFile = get(fn) if (results2 == "") {infoBox " Please run to populate the\n \"Output\" window before exporting" return} string filenameData = selectedFile testFile = canOpenFile(filenameData,false) if (testFile "" == "true") {if (confirm "File \"" filenameData "\" already exists. Confirm to proceed to overwrite?") else halt} {Stream outData = write filenameData results2 = results2 "\n" outData << results2 close outData s = "" set (t1,"Copied saved to " filenameData "\n\nNote results overwrite not append\n\n**************\n\n" results) infoBox "File \"" filenameData "\" created." } //Close on "if confirm" file export } //Close exportFileFunction t1 = text(exBox,"",results, 950, 400, true) fn = fileName(exBox, initFile, "*.txt", "Export to file name") exportFile = button(exBox,"Export files to specified location", exportFileFunc) beside exBox calcStab = button(exBox,"Run module documentation", calcStability) show exBox