我正在编写一个DXL脚本,它通过多个级别跟踪链接。我注意到,当模块打开时,脚本会正确地遍历这些链接。但是,大约有20个模块需要迭代,我不想打开所有这些模块。如何查看这些链接而不必手动打开链接模块?
下面是我的代码示例:
// Checks to see if the object exists or not. If not returns a null.
// This will be eventually adapted to make sure the object is from a
// specific set of modules, but for now we're just checking for ability
// to retrieve
Object getObject(Link obj_link) {
ModuleVersion other_ver = null
ModName_ other_mod = null
Object other_obj
other_ver = sourceVersion obj_link
other_mod = module(other_ver)
if (null other_mod || isDeleted other_mod) return null
other_obj = source obj_link
if (null other_obj) load(other_ver, true)
other_obj = source obj_link
if (isDeleted other_obj) return null
return other_obj
}
// Displays the object from a specific link module if it's found
void showOut(Object o) {
Link l_obj_link
string s = null
Item linkModItem = itemFromID(MODULE_ID)
string linkModName = fullName(linkModItem)
for l_obj_link in all(o <- linkModName) do {
Object test_obj
display("Test")
test_obj = getObject(l_obj_link)
if (null test_obj){
display("Null Object Found")
} else {
s = probeRichAttr_(test_obj, "Object Identifier", false)
displayRich(s)
}
}
}
// Call showOut for the object
showOut(obj)
同样,使用它作为布局DXL脚本,我可以看到对象ID当且仅当链接模块被打开。
发布于 2015-05-12 13:39:00
首先,我建议使用Analysis -> Wizard
,并确保选择用于All Modules
而不是All Open Modules
的选项来为您生成所有代码,然后修改该代码以显示您想要的内容,如果它没有给出您所需要的内容。
但是,如果您只想更新现有代码,则需要更改getObject
函数,使其包括静默地打开每个模块(要获得模块必须打开的信息,但不需要显示该模块)。
Object getObject(Link obj_link) {
ModuleVersion other_ver = null
ModName_ other_mod = null
Object other_obj
other_ver = sourceVersion obj_link
other_mod = module(other_ver)
Module m = read(fullName(other_ver), false) // false, tells it to open silently.
if (null other_mod || isDeleted other_mod) return null
other_obj = source obj_link
if (null other_obj) load(other_ver, true)
other_obj = source obj_link
if (isDeleted other_obj) return null
return other_obj
}
这也应该是可行的,但我仍然建议从分析向导开始,因为它会更干净。
https://stackoverflow.com/questions/30174589
复制相似问题