Greetings, Module m = read("Target Module 1") m = current Object o = current string absno = o."Absolute Number" etc...
/* This program copy the selected objects attributes from one module to another. It was created to copy the links absolute number of the module to then create links by attribute Include Outlinks and Inlinks */ //Several Target Modules ModName_ m = module("Target Module 1") Object oTarget1 = current string linkAtt1 = oTarget1."Absolute Number""" ModName_ m2 = module("Target Module 2") Object oTarget2 = current string linkAtt2 = oTarget2."Absolute Number""" ModName_ m3 = module("Target Module 3") Object oTarget3 = current string linkAtt3 = oTarget."Absolute Number""" //Source Module ModName_ m4 = module("Source Module") Object oSource oSource."LinktoTarget1" = linkAtt1 oSource."LinktoTarget2" = linkAtt2 oSource."LinktoTarget3" = linkAtt3
SystemAdmin - Tue Jun 09 15:13:59 EDT 2009 |
Re: Set module as current When you open a module, the current object in that module is not set and may be null. You need to explicitly set the current object. I am not quite sure what you are trying to do, but relying on "current" modules and objects is a very risky way of doing this. The current module can be changed by DOORS automatically opening other modules without you knowing. |
Re: Set module as current
I agree with Tony that it is risky to rely on the current Module, and if I understand correctly what you have in mind, you actually do not have to, as you can use the 'Object current(Module m)' perm to get a handle on the selected object in each module. Module targetMod1 = read("Target Module 1")
Object oTarget1 = current(targetMod1)
|
Re: Set module as current Setting a module current is as follows: current = mTarget // mTarget is type 'Module'
Module g_mCurr = current() if (null mCurr or type(g_mCurr) != "Formal"){errorBox("Run from open formal module"); halt}
Module mCurr = current() mTarget = read("/MyProject/MyFolder/MyModule", false) current = mTarget // make sure we know which module is current search for attributes in mTarget if (!null mCurr) current = mCurr
|
Re: Set module as current Hope this helps future coders! Jason |
Re: Set module as current jhaury - Wed Aug 19 19:43:01 EDT 2009
But WAIT!!! If you change the current module inside some function, you may very well mess up some code in your main program that's presuming the current module, not knowing its changed. I hate it when that happens. In fact, I hated it when it DID happen; all 15 or so times... Module fSetCurrMod(Module modNew) { // Set the "Current" module, returning the previous current // module. You cannot "clear" current by passing null. Module modPrev = current if (!null modNew and modNew != modPrev) (current ModuleRef__) = modNew return(modPrev) } // end fSetCurrMod()
Module mCurrPrevious = fSetCurrMod(mod) // deal with mod as the current module, perhaps looking at attrs. fSetCurrMod(mCurrPrevious)
Module mCurrPrevious = current() // Do things that do or might change the current module, // such as opening modules or using 'fnGetCPModulePath'. fSetCurrMod(mCurrPrevious)
//****************** Object fSetCurrObj(Object objNew) { // set the "current" object, returning the previous current // object. You cannot "clear" current by passing null. // The "current" module MAY need to be set to make this happen, // since you cannot set a current object in a non-current module. Object objPrev = current if (null objNew) return(objPrev) Module modNew = module(objNew) // Module houses the object if (null modNew) return(objPrev) // ?? Impossible error ?? fSetCurrMod(modNew) (current ObjectRef__) = objNew return(objPrev) } // end fSetCurrObj()
|