// Move objects from flat to hierarchical based on attribute value // Version 1.0 /* Moves objects in a formal module from a flat structure to a hirearchical structure based on an attribute value named "O Level" that contains the integer level of each object. */ DB mainDB = create "Build Module Hierarchy" DBE listOfAttrDBE DBE typeOfAttrDBE string typeOfAttr[] = {"Object Level","Object Number"} int intCnt = 0 int strCnt = 0 AttrDef ad // count and store non-system object string and int attributes for ad in current Module do { if(ad.object && !ad.system) { AttrType at = ad.type attrType = at.name if(attrType == "Integer") { intCnt++ } else if(attrType == "String") { strCnt++ } } } string attrNameInts[intCnt] string attrNameStrs[strCnt] string attrType intCnt = 0 strCnt = 0 for ad in current Module do { if(ad.object && !ad.system) { AttrType at = ad.type attrType = at.name if(attrType == "Integer") { attrNameInts[intCnt++] = ad.name } else if(attrType == "String") { attrNameStrs[strCnt++] = ad.name } } } // Convert Obj Number into Obj Level int onumConvert (string oNum) { int olen = length oNum int olevel = 1 string k = "" int i for (i = 0; i < olen; i++) { k = oNum[i:i] if (k == ".") olevel += 1 } if ((i == 2 && k == "0") || k == ".") olevel -= 1 return olevel } //onumConvert // Construct hierarchy based on number or level information void buildHierarchy (string passedAttr, int selDBE) { Object o1, o2 o1 = first current Module o2 = next o1 while (!null o2) { int oLevel1, oLevel2 if(selDBE == 0) { oLevel1 = o1.passedAttr oLevel2 = o2.passedAttr } else { oLevel1 = onumConvert(o1.passedAttr "") oLevel2 = onumConvert(o2.passedAttr "") } if (oLevel2 != 1 && !cell o2) { if (oLevel2 - oLevel1 > 0) { move (o2, below o1) } else if (oLevel2 - oLevel1 < 0) { for (i = 0; i < oLevel1-oLevel2; i++) { o1 = parent o1 } //print identifier o1 "\t" identifier o2"\n" move (o2, after o1) } else { move (o2, after o1) } } if(cell o2) { Object oTabHead = parent parent o2 Object oPrev = previous oTabHead oLevel1 = level oPrev if((oLevel2 - oLevel1) > 2) { move(o2, below oPrev) } else { move(o2, after oPrev) } } else { o1 = o2 o2 = next o2 } } } //buildHierarchy // Get the DB values and build the hierarchy void getParams(DB box) { int itemPosition = get listOfAttrDBE if(itemPosition == -1) { ack("Please make a selection") return } string itemName = get(listOfAttrDBE, itemPosition) buildHierarchy(itemName, get(typeOfAttrDBE)) hide mainDB refresh current } // Dynamically replace the listDB based on radio button selection void deleteAndFill (int elemCnt, int listCnt, string varName[]) { for(i=0;i