如何修改Analysis Wizard生成的DXL以提取指定深度2模块数据
解决方案
先修正代码里的拼写/语法错误,再添加指定模块的过滤逻辑,就能实现只提取目标深度2模块的数据,具体操作如下:
1. 修正基础错误
原代码存在多处拼写和语法问题,先逐一修正:
bool doneOne = flase→bool doneOne = false(布尔值拼写错误)string s - null→string s = null(赋值运算符错误)!isDelected otherMod→!isDeleted otherMod(方法名拼写错误)load(otherVerion,false)→load(otherVersion,false)(变量名拼写错误)id (depth < 2)→if (depth < 2)(条件判断关键字错误)- 所有
line[depth-1]→lines[depth-1](数组名拼写错误) if (depth = showAtDepth)→if (depth == showAtDepth)(赋值运算符改为相等判断)
2. 添加目标模块过滤
定义目标模块名称,在遍历链接时只处理匹配的模块,修改后的完整代码如下:
pragma runLim, 0 // 替换为你需要提取的深度2模块的精确名称 string targetModuleName = "你的目标深度2模块名" int lines[2] = {0, 0} void adjustLines(int depth, int showAtDepth) { int count for (count = 0; count < 2; count++) { while (lines[depth-1] < lines[count]) { if (depth == showAtDepth) displayRich("\pard " " ") lines[depth-1]++ } } } void showIn(Object o, int depth) { link l LinkRef lr ModName_ otherMod = null Module linkMod = null ModuleVersion otherVersion = null Object othero string disp = null string s = null string plain, plainDisp int plainTextLen int count bool doneOne = false string linkModName = "*" for lr in all(o<-linkModName) do { otherMod = module (sourceVersion lr) if (!null otherMod) { if ((!isDeleted otherMod) && (null data(sourceVersion lr))) { load((sourceVersion lr),false) } } } for l in all(o<-linkModName) do { otherVersion = sourceVersion l otherMod = module(otherVersion) // 过滤逻辑:仅处理目标模块 if(null otherMod || isDeleted otherMod || name(otherMod) != targetModuleName) continue othero = source l if (null othero) { load(otherVersion,false) othero = source l } if (null othero || isDeleted othero) continue int oldLines = lines[depth-1] adjustLines(depth, 2) bool kick = (doneOne) && (lines[depth-1] == oldLines) if (kick) { lines[depth-1]++ if (depth ==2) displayRich("\pard " " ") } if (depth < 2) { showIn(othero, depth+1) } doneOne = true if (depth == 2) { s = (identifier othero) if (s == "") displayRich("\pard " " ") else displayRich("\pard " s) s = probeRichAttr_(othero, "User-Defined Attribute", false) if (s == "") displayRich("\pard " " ") else displayRich("\pard " s) } lines[depth-1] += 4 } } showIn(obj, 1)
关键修改说明
- 顶部新增
targetModuleName变量,替换为你需要提取的深度2模块的精确名称 - 在遍历链接的循环中,添加
name(otherMod) != targetModuleName判断,不匹配的模块直接跳过 - 修正所有基础错误后,代码可正常运行
后续为另外两个深度2模块创建属性时,只需复制这段代码,修改targetModuleName的值即可。
内容的提问来源于stack exchange,提问作者SysEng91
相关产品推荐
相关产品推荐

