【问题标题】:DXL: Which links pass a specific linkmoduleDXL:哪些链接通过特定的链接模块
【发布时间】:2013-10-22 12:21:39
【问题描述】:

我编写了一个 DXL 函数,它从 DOORS 模块中读取一些属性和传出链接并将其写入 MS Excel 表。 它工作正常。

现在我想在 DXL 函数中添加以下内容:

当我打开一个 DOORS 模块并应用过滤器 --> “链接”时,我可以说“通过链接模块”并选择一个特定的。 (我有德国的 DOORS 版本,所以也许它被称为有点不同)

这是我目前拥有的功能:

void WriteAllOutLinksToExcel (string sModuleName, string sBookName, string sSheetName)
{
    OleAutoObj  objExcel = oleGetAutoObject("Excel.Application")
    OleAutoObj  objBook
    OleAutoObj  objSheet = null
    OleAutoArgs oleArgs = create
    Object  oCur
    Module  mCur
    bool        excelVisible 
    string  sTemp = ""
    string  sResult = ""
    string  sNum
    int         iRow = 1
    int     iCount = 0
    int         iNum
    Link        lref
    ModName_    targetMod

    oleGet(objExcel, "Visible", excelVisible);
    if (!excelVisible) olePut(objExcel,"visible",true);

    sResult = oleGet(objExcel,"Workbooks", sBookName);

    clear oleArgs;
    put(oleArgs, sSheetName);
    sResult = oleGet(objExcel, "Sheets", oleArgs, objSheet);

    mCur = edit(sModuleName,false);
    if(mCur != null)
    {
        View v = view("_ABC");
        for oCur in mCur do
        {
            // Absolute object no..
            sTemp = oCur."Absolute Number";
            objCell = ExcelGetCell(objSheet, iRow, 1);
            olePut(objCell,"Value",sTemp);          

            // Object text
            sTemp = oCur."Object text";
            objCell = ExcelGetCell(objSheet, iRow, 2);
            olePut(objCell,"Value",sTemp);          

            // Links
            iCount = null;
            for lref in oCur -> "*" do {    
                targetMod = target lref;
                iNum = targetAbsNo(lref);
                sNum = " " iNum " ";
                if(iCount == 0)
                {
                    sTemp = fullName(targetMod) sNum;
                }
                else
                {
                    sTemp = sTemp "\n" fullName(targetMod);
                    sTemp = sTemp sNum;
                }
                objCell = ExcelGetCell(objSheet, iRow, 3);
                olePut(objCell,"Value",sTemp);
                iCount ++;
            }           
            iRow ++;
        }
    }
    close(mCur);
    oleCloseAutoObject (objExcel);
}

我正在考虑类似于 for 循环中的 if 语句:“如果传递了链接模块“abc”,则列出信息“对象编号”和“对象文本”和链接......

这可能吗?希望有人能帮我解决这个问题吗?

【问题讨论】:

  • 您是说您希望此脚本提示用户输入链接模块,然后仅导出使用该链接模块的结果吗?他们是在输入链接模块还是从列表中选择?
  • 我想将链接模块作为参数传递给函数。我的 VBA 代码将运行 DXL 函数,并且 dxl 函数应该只返回通过给定链接模块的值。例如,我在一个模块中有 100 个值(对象),但其中只有 70 个通过链接模块,所以我只希望函数返回这 70 个。对不起,我写得不够清楚,很难解释。

标签: excel vba ibm-doors ibm-rational


【解决方案1】:

您需要做的就是将参数添加到您的输入中(我在此处添加了string LinkModName),然后将"*" 替换为LinkModName"*" 表示所有链接模块,但您可以将其替换为您要使用的任何特定链接模块的字符串名称。此外,您应该确保将链接模块的完整路径传递给函数。

点赞:/Project_Name/Folder_Name/Link_Module_Name

void WriteAllOutLinksToExcel (string sModuleName, string sBookName, string sSheetName, string LinkModName)
{
  OleAutoObj  objExcel = oleGetAutoObject("Excel.Application")
  OleAutoObj  objBook
  OleAutoObj  objSheet = null
  OleAutoArgs oleArgs = create
  Object  oCur
  Module  mCur
  bool        excelVisible 
  string  sTemp = ""
  string  sResult = ""
  string  sNum
  int         iRow = 1
  int     iCount = 0
  int         iNum
  Link        lref
  ModName_    targetMod

  oleGet(objExcel, "Visible", excelVisible);
  if (!excelVisible) olePut(objExcel,"visible",true);

  sResult = oleGet(objExcel,"Workbooks", sBookName);

  clear oleArgs;
  put(oleArgs, sSheetName);
  sResult = oleGet(objExcel, "Sheets", oleArgs, objSheet);

  mCur = edit(sModuleName,false);
  if(mCur != null)
  {
     View v = view("_ABC");
     for oCur in mCur do
     {
        // Absolute object no..
        sTemp = oCur."Absolute Number";
        objCell = ExcelGetCell(objSheet, iRow, 1);
        olePut(objCell,"Value",sTemp);          

        // Object text
        sTemp = oCur."Object text";
        objCell = ExcelGetCell(objSheet, iRow, 2);
        olePut(objCell,"Value",sTemp);          

        // Links
        iCount = null;
        for lref in oCur -> LinkModName do {    
            targetMod = target lref;
            iNum = targetAbsNo(lref);
            sNum = " " iNum " ";
            if(iCount == 0)
            {
                sTemp = fullName(targetMod) sNum;
            }
            else
            {
                sTemp = sTemp "\n" fullName(targetMod);
                sTemp = sTemp sNum;
            }
            objCell = ExcelGetCell(objSheet, iRow, 3);
            olePut(objCell,"Value",sTemp);
            iCount ++;
        }           
        iRow ++;
    }
  }
  close(mCur);
  oleCloseAutoObject (objExcel);
}

希望这会有所帮助!

【讨论】:

  • 非常感谢它有效。我早该想到的!...其实很简单..
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多