//********************** bool fIsValidModule(string NameMod, string ModType) { // Determine if the Module name is a valid module of the specified // Type "Formal", "Link", or "Descriptive" in the current project. // Type = "*" means any type (of module). // 'Valid' modules: // o Exist and are not deleted. // o Available for Read to the current user. // Search rules for 'fFullName' above apply to this function. if (null NameMod or null ModType) return(false) bool OKname // string FullName = fFullName(NameMod) string FullName = NameMod if (null FullName or !module FullName or isDeleted(module FullName) or (ModType != "*" and type(module FullName) != ModType) ) OKname = false else OKname = true // if (!null NameMod and !null ModType) // print "fIsValidModule: " OKname " '" NameMod "' ^" ModType "^\n" // else print "fIsValidModule: bad input names\n" return(OKname) } // end fIsValidModule() const bool cl_DoInLinks = true, cl_DoOutLinks = false //********************* string fGetLinkedName(bool LinkDirection, Link lnk) { // Get the full name of the module on the other // end of the link. string OtherName if ( null lnk) { OtherName = "" } elseif (LinkDirection == cl_DoInLinks) { if (null (ModName_ source(lnk))) OtherName = "" else OtherName = fullName (source(lnk)) } else { if (null (ModName_ target(lnk))) OtherName = "" else OtherName = fullName (target(lnk)) } return(OtherName) } // end fGetLinkedName() //******************** Object fGetLinkedObj(bool LinkDirection, Link lnk) { // Get the object handle of the object on the other // end of the link Object oOther if (null lnk) oOther = null elseif (LinkDirection == cl_DoInLinks) oOther = source(lnk) else oOther = target(lnk) return(oOther) } // end fGetLinkedObj() //********************** string fGetLMName(Link lnk) { // Get the full LinkModule name associated with the link. if (null lnk) return("") else return(fullName(module(lnk))) } // end fGetLMName() //************************** bool fGetLinkInfo( Link lnk, // IN: //- bool LinkDirection, // IN: Direction //- string &OtherNameOut, // OUT: full Other module name //- string &LModNameOut, // OUT: full link module name //- Object &oLinkedOut // OUT: connected Object handle //- ) { // Get the information of the link in the specified direction. // Return true if the Link (and the 3 "xxOut" call parameters) is OK. // Returns false if link is NOT OK or for some reason this // user cannot read the information. If its not a good // link the non-null "xxOut" call parameter Information returned IS // reliable; so you can at least get some information from a "bad" link. // Note: if the function returns "false" yet parameter "oLinkedOut" has // non-null value, then the caller should presume the link is "bad" // because the other object is deleted. Object oLinked = null string NameSource = "", NameTarget = "", NameLMod = "" // Set output variables to null. Those that get reliable information // are set non-null below. OtherNameOut = "" LModNameOut = "" oLinkedOut = null if (null lnk) return(false) NameLMod = fGetLMName(lnk) // link module name containing link if (!fIsValidModule(NameLMod, "Link")) return(false) LModNameOut = NameLMod // ** LModNameOut is now valid. NameSource = fGetLinkedName(cl_DoInLinks, lnk) NameTarget = fGetLinkedName(cl_DoOutLinks, lnk) if (!fIsValidModule(NameSource, "Formal")) return(false) if (!fIsValidModule(NameTarget, "Formal")) return(false) if (LinkDirection == cl_DoInLinks) OtherNameOut = NameSource else OtherNameOut = NameTarget // ** OtherNameOut is now valid. oLinked = fGetLinkedObj(LinkDirection, lnk) oLinkedOut = oLinked // print "fGetLinkInfo, " (identifier(oLinkedOut)) "\t" (fBaseName(OtherNameOut)) "\n" if (null oLinked or isDeleted oLinked) return(false) return(true) // Survive this far? Everthing is OK; link is valid. } // end fGetLinkInfo() valid.