I have written a function that is supposed to get all in-links and out-links and display them within an HTML file. I've tried to write the script as similar to what is in the reference manual, but the in-link section isn't working. And, yes, I did the stupidity test and made sure that some of the objects indeed have in-links. Here is the code as I have it written: Buffer getLinks(Object obj) { Link oLnk; Link iLnk; ModName_ targetMod; ModName_ sourceMod; Buffer links = create; Object targetObj = null; Object sourceObj = null; string modPrefix = ""; string pathName = ""; //In-Links for iLnk in obj<-"*" do { infoBox("InLink"); sourceMod = source iLnk; read(fullName(sourceMod), false); sourceObj = source(iLnk); modPrefix = identifier(sourceObj); links += modPrefix "<br>\n"; } //Out-Links for oLnk in obj->"*" do { infoBox("Outlink"); targetMod = target oLnk; read(fullName(targetMod), false); targetObj = target(oLnk); modPrefix = identifier(targetObj); links += modPrefix "<br>\n"; } return links; } When I run this code, I don't get any errors and only get the infoBox for out-links, so it isn't getting into the In-Links loop. Anyone's help would be greatly appreciated.
Chris Christopher Cote - Wed Dec 14 11:19:54 EST 2016 |
Re: Trouble getting object in-links From the reference manual regarding "for inlink in object":
"Note: This loop only assigns to Therefore you should use the loop: for all link referencesSyntax for linkRef in (Object tgtObject) <- (string linkModName) do { ... } And use that to open all inlinked modules. That will then make the inlinks visible to the ""for inlink in object" loop. |
Re: Trouble getting object in-links So, would I put the "for inlink in object" loop inside the for linkRef loop? Or do I put it after the linkRef loop? for lRef in oObj<-"*" do { infoBox("Link Ref"); for iLnk in all(oObj<-"*") do { infoBox("InLink"); sourceMod = source iLnk; srcMod = read(target iLnk, false); sourceObj = source(iLnk); modPrefix = identifier(sourceObj); } } } but I'm not getting the LinkRef infoBox. I'm sorry if these seem like stupid questions, but I haven't worked with links in DXL before. |
Re: Trouble getting object in-links Christopher Cote - Wed Dec 14 13:01:14 EST 2016 So, would I put the "for inlink in object" loop inside the for linkRef loop? Or do I put it after the linkRef loop? for lRef in oObj<-"*" do { infoBox("Link Ref"); for iLnk in all(oObj<-"*") do { infoBox("InLink"); sourceMod = source iLnk; srcMod = read(target iLnk, false); sourceObj = source(iLnk); modPrefix = identifier(sourceObj); } } } but I'm not getting the LinkRef infoBox. I'm sorry if these seem like stupid questions, but I haven't worked with links in DXL before. The structure you want is for linkRef in object get name of source module of linkRef open source module in read only for link in object (they are all now visible, as all the modules have been opened above) do your action
|