门数所有内联

时间:2018-09-25 08:33:39

标签: ibm-doors

我想计算IBM Doors项目中所有模块中所有对象的所有内联。 (使用DXL)

这就是我的操作方式(主要是即时调用函数goThroughFolders(current Folder)):

  1. 浏览项目中的每个文件夹,检查是否有模块,是否有模块调用函数“ checkLinks(Module m)”

        void goThroughFolders(Folder f)
        {
            Item itm
            if (null f) return
    
            for itm in f do{
    
                    print("\nScanning folder...")
                    if (null itm) continue
                    if (isDeleted(itm)) continue
    
                    else if ((type (itm) == "Project") || (type (itm) == "Folder"))
                        {
                      goThroughFolders(folder(itm))
                        }
                    else if (type (itm) == "Formal") {
                        print("\nFound Module")
                        checkLinks(module(itm))
                        }
    
            }
    } 
    
    1. 检查模块中的链接

      void checkLinks(Module m)
      {
          string objType = ""
          Object o = null
          Link anyLink
          for o in m do {
      
      objType = o."Object Type" ""
      
      // Check if the type is right
      if ( ( objType == "Req" ) || ( objType == "Obj" ) ) {
          // Check for any outlinks at all
          for anyLink in o <- "*" do{
      
      
      
         LinkCount++
      
         }
      

      } } }

所以我的问题是checkLinks(module(itm))中的函数调用goThroughFolders(Folder f)似乎交出了null对象。

Error:

    -R-E- DXL: <Line:11> null Module do loop parameter was passed
    Backtrace:
        <Line:69> 
        <Line:78> 
    -I- DXL: execution halted

但是我不知道为什么?你能帮我吗?

1 个答案:

答案 0 :(得分:1)

做好发现缺少的步骤的工作。您可能想做的另一件事是在完成分析后关闭模块,否则,您可能会忘记并将它们保持打开状态,从而牺牲内存,直到退出DOORS。

为了达到这个目的,我在下面做了一些修改和补充-如果不清楚,请随时询问。

理查德

Module m
Skip skLinkSourceMods = create() // Create a skip list to hold references to all modules opened for link analysis

int linkCount = 0

void checkLinks(Item itm, Skip skOpenMods) // Function signature changed to pass in the skip list - not strictly necessary, but clean
{
    m = read (fullName(itm), false, true)
    put(skOpenMods, m, m) // Add the opened module to the skip list, so we can easily close it later
    string objType = ""
    Object o = null
    Link anyLink

    for o in m do {
        objType = o."Object Type" ""

        // Check if the type is right
        if ( ( objType == "Req" ) || ( objType == "Obj" ) ) {

        // Check for any outlinks at all
            for anyLink in o <- "*" do {
               linkCount++
           }
       }
    }
}

void goThroughFolders(Folder f)
{
    Item itm
    if (null f) return

    for itm in f do {
        print("\nScanning folder...")
        if (null itm) continue
        if (isDeleted(itm)) continue

        else if ((type (itm) == "Project") || (type (itm) == "Folder"))
        {
          goThroughFolders(folder(itm))
        }
        else if (type (itm) == "Formal") {
            print("\nFound Module")

            checkLinks(itm, skLinkSourceMods) // Function signature changed (see above) to pass in the skip list - not strictly necessary, but clean
        }
    }
}

void closeModules(Skip skOpenMods)
{
    for m in skOpenMods do // Loop through each module in the skip list
    {
        close(m, false) // Close the module without saving changes (we shouldn't have any - they were opened read-only anyway!)
    }
}

goThroughFolders(current Folder)
print "\n" linkCount " links."
closeModules(skLinkSourceMods)
delete(skLinkSourceMods)