//MergeSelectedObjects.dxl /* Join selected objects on Object Text. Also move links from deleted objects to joined object. 1. Select a set of contiguous objects. (Only their object text will be retained.) 2. Run this script to replace the object text in the first of these objects with the concatenation of the object texts of the other objects, and then delete those other objects. */ #include void moveLinks(Object fromObj, Object toObj) { // move all incoming and outgoing links from // one object to another int linksNotCopied = 0 // scan outgoing links Link l for l in fromObj->"*" do { // get link information Module lnkMod = module l string lnkModName = fullName(lnkMod) string trgModName = target l Object trgObj = target l // if trgObj is null, it is because // the target module is not open. // So open it. if ( null trgObj ) { edit(trgModName, false) trgObj = target l } // if still null, there is a problem. // So skip it. if ( null trgObj ) { linksNotCopied++ continue } // create new link Link newl = toObj->lnkModName->trgObj // copy link attributes string attrName for attrName in lnkMod do { if ( canWrite(lnkMod, attrName) ) { newl.attrName = l.attrName "" } } // delete old link delete l } // scan incoming links for l in fromObj<-"*" do { // get link information Module lnkMod = module l string lnkModName = fullName(lnkMod) string srcModName = source l Object srcObj = source l // if srcObj is null, it is because // the source module is not open. // So open it. if ( null srcObj ) { edit(srcModName, false) srcObj = source l } // if still null, there is a problem. // So skip it. if ( null srcObj ) { linksNotCopied++ continue } // create new link Link newl = toObj<-lnkModName<-srcObj // copy link attributes string attrName for attrName in lnkMod do { if ( canWrite(lnkMod, attrName) ) { newl.attrName = l.attrName "" } } // delete old link delete l } // show errors if ( linksNotCopied > 0 ) { ack linksNotCopied " links were not copied." } // flush out the deleted links flushDeletions() } Skip toDelete = create() Object firstObj = null string objText = "" int cellWdth = 0 bool hasOLE = false int numObjs = 0 Object o for o in current Module do { if ( !isSelected o ) continue // accumlate object texts objText = objText "\n" (richTextWithOle o."Object Text") "" // accumulate cell widths cellWdth += intOf o."TableCellWidth" "" /* // keep OLE if ( oleIsObject(o) ) { // this object has an OLE object if ( hasOLE ) { // already have an OLE object ack "Cannot join two OLE objects." break } hasOLE = true if ( !null firstObj ) { // move OLE to first object oleCut(o) olePaste(firstObj) } } */ if ( null firstObj ) { // record first object firstObj = o } else { // record which objects to delete numObjs++ put(toDelete, numObjs, o) } } if ( null firstObj || numObjs < 1 ) halt // update first object firstObj."Object Text" = richText objText[1:] // cut off leading "\n" if ( cell(firstObj) ) setCellWidth(firstObj, cellWdth) // copy links for o in toDelete do moveLinks(o, firstObj) // delete remaining objects // in reverse order so that children are deleted before parents for i in numObjs:1 by -1 do { if ( find(toDelete, i, o) ) { delete(o) flushDeletions() } } flushD