2013-10-22 42 views
0

我已經寫了一個DXL函數,它從DOORS模塊中讀出一些屬性和輸出鏈接並將其寫入MS Excel工作表。 它工作正常。DXL:哪些鏈接通過特定的鏈接模塊

現在我想補充以下的DXL-功能:

當我打開DOORS模塊和應用過濾器 - >「鏈接」,那麼我可以說,「通過Linkmodule」,然後選擇特定的一。 (我有德國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); 
} 

我想到的是像裏面的一個if語句-loop它說:「如果linkmodule‘ABC’傳遞然後列出的信息‘對象號’&‘對象文本’&鏈接...

這是可能希望有人能幫助我這個一個

+0

你是說你想讓這個腳本提示用戶輸入一個鏈接模塊,然後只導出使用該鏈接模塊的結果?他們是在鏈接模塊中鍵入還是從列表中選擇? –

+0

我想將鏈接模塊作爲參數傳遞給函數。我的VBA代碼將運行DXL函數,並且dxl函數應只返回通過給定鏈接模塊的值。例如,我在一個模塊中有100個值(對象),但其中只有70個通過鏈接模塊,因此我只希望該函數返回那些70. Sry我沒有寫得那麼清楚,也很難解釋。 – user2644787

回答

0

你所需要做的就是將參數添加到輸入中(我在這裏添加了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); 
} 

希望這有助於!

+0

非常感謝你的工作。我應該想到這一點!...其實這很簡單.. – user2644787