Reputation: 2613
I want to code a loop in DXL that reads something from every Object linked to by an Object named "req".
The naive solution, ommitting req's initialization, would be this:
Object req
Object parent
Link baselink
for baseLink in req -> "*" do{
parent = target(baseLink)
...
}
This does not work unless all of the modules where these "parent" objects exist are already open. For any that are still not open, the "parent" variable just receives a Null value.
Given this situation, I'd like a way to programatically open them all.
The DXL Reference Manual provides a solution that works only for incoming links (from "child" objects):
ModName_ srcModRef
for srcModRef in o<-"*" do
read(fullName(srcModRef), false)
Unfortunately, I can't find a solution for outgoing links. Replacing "<-" with "->" in the example above fails. I've searched in the Manual and the web.
I want to avoid opening all the links pointed to by the entire Link Module, because that involves other sources.
Does anybody know how to programatically open all Modules linked to by an Object? I doubt there is a way to access an object without opening the Module it's in, but that would also solve my problem.
Upvotes: 1
Views: 5501
Reputation: 1892
Here is your solution:
Object req
ModName_ parentModName
Module parentMod
Object parent
Link baselink
for baseLink in req -> "*" do{
parentModName = target(baseLink)
parentMod = read(fullName(parentModName), false)
parent = target(baseLink)
...
close parentMod
}
Even though the Module is not open you can get the ModName_ handle and then open it. Then you can get the target object reference. Don't forget to close the linked modules after you are done with them to free up the resources.
Hope this helps!
Upvotes: 2