Hello together, Link in_lnk Module md = current Object md_entry_ptr,src_obj for md_entry_ptr in md do { //loop over LinkModule links (incoming) of the entry: for in_lnk in all ((md_entry_ptr) <- ("name_of_LinkModule")) do { my code }
... { //loop over all links (incoming) of the entry: for in_lnk in all ((md_entry_ptr) <- ("*")) do { fnm = name module in_lnk print fnm "\n" }
... { //loop over LnkMod links (incoming) of the entry: for in_lnk in all ((md_entry_ptr) <- ("LnkMod")) do { my code }
SystemAdmin - Fri Nov 11 10:00:12 EST 2011 |
Re: looping over incoming links of certain link Module
The mistery is, that a "Link" is only available if the source module (i.e. the module where the link comes from is loaded). So you cannot use "for Link in Object do" if you want to interate all links. The proper approach for iterating over links is: Object o Link lnk for o in entire current Module do { // Outlinks can be iterated, since the source is already loaded for lnk in all o -> "*" do { // load target ModuleVersion mvTarget = targetVersion lnk Module modTarget = data mvTarget if (null modTarget) modTarget = load(mvTarget, false) if (null modTarget) { /* error handling */; continue } // get target object Object oTgt = target lnk if (null oTgt) { /* error handling */; continue } if (isDeleted oTgt) { /* error handling */; continue } print "Out: '" (oTgt."Object Text") "'\n" } // load source modules of in-link references LinkRef lr; for lr in all (o <- "*") do { ModuleVersion mvSource = sourceVersion lr Module modSrc = data mvSource if (null modSrc) modSrc = load(mvSource, true) } // Iterate in-links and navigate (source modules are now open) for lnk in all (o <- "*") do { Object oSrc = source lnk if (null oSrc) { /* error handling */; continue } if (isDeleted oSrc) { /* error handling */; continue } print "In: '"(oSrc."Object Text") "'\n" } }
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: looping over incoming links of certain link Module i'm happy with using load(mvTarget, false)
|
Re: looping over incoming links of certain link Module limengale - Fri Nov 11 11:47:08 EST 2011 i'm happy with using load(mvTarget, false)
You are right, thanks for the hint. You would need to surround the load function by noError(); ... lastError(); ... noError() if (null modTarget) modTarget = load(mvTarget, false) lastError() ...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: looping over incoming links of certain link Module Mathias Mamsch - Fri Nov 11 16:18:29 EST 2011
You are right, thanks for the hint. You would need to surround the load function by noError(); ... lastError(); ... noError() if (null modTarget) modTarget = load(mvTarget, false) lastError() ...
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
I don't recall if I've trapped no-such-incude-file errors or not. |
Re: looping over incoming links of certain link Module
Yes, you must load the source module in order to see the "Link" in the target. for lnk in obj <- "*" do { NameFullLM = fullName(module(lnk)) if (!matches("MyLinkModFolder/LnkMod", NameFullLM)) continue // Ignore this link
|
Re: looping over incoming links of certain link Module the simpliest method did work with minor adjustments. The crucial thing was that if the name of the table is in German then my IDE probably doesn't come clear with the umlauts. |
Re: looping over incoming links of certain link Module |