【发布时间】:2023-03-18 05:25:01
【问题描述】:
我正在开发 Doors 中的 DXL 程序,该程序应该将所有源模块、目标、链接集和每个(源/目标)模块的版本输出到 csv 文件。我已经成功输出“源模块,目标,链接集,但我无法提取模块的版本。有人知道怎么做吗?
下面是我的代码:
【问题讨论】:
-
请避免将代码发布为图片。如果以文本形式输入,其他人会更容易提供帮助
我正在开发 Doors 中的 DXL 程序,该程序应该将所有源模块、目标、链接集和每个(源/目标)模块的版本输出到 csv 文件。我已经成功输出“源模块,目标,链接集,但我无法提取模块的版本。有人知道怎么做吗?
下面是我的代码:
【问题讨论】:
以下使用 C:\Temp 中的输出文件,但您可以轻松更改它。 它通过使用 grep 字符串匹配模块来工作,您可以再次更改以适应。 我有不同的模块类型,因此在这种情况下我可以得到前缀“STR”的结果。我决定为不同的前缀模块设置多个脚本,而不是动态传递 STR 关键字。
您需要为“modPathname”输入您的文件夹和子文件夹 然后调整正则表达式“GrepString”以适合您的命名约定 或者,您可以通过硬编码值来绕过所有这些。
string filename = "C:\\TEMP\\STR_Baseline_Info.txt"
Stream outFile = write filename
string Modtype = "STR"
void PrintAndOutput ( string s)
{
// print (s) // Enable if you want output
outFile << s
}
void DisplayResults( string Modtype )
{
Item modItem
Module mName
Regexp GrepString = regexp2 "^" Modtype "-[0-8][0-9][0-9]"
Folder modPathname = folder "/EnterYourFolderHere/AnySubFolders/" Modtype ""
string fullModuleName , CommentStr , moduleName
Baseline b
PrintAndOutput "------------------------------------------------------------------------------\n"
CommentStr = "This File is automatically produced via the " Modtype " Baseline Info.dxl script. \n" Modtype " Versions as of : " dateAndTime(today) "\n"
PrintAndOutput CommentStr
PrintAndOutput "-------------------------------------------------------------------------------\n\n"
for modItem in modPathname do
{
if (type (modItem ) == "Formal")
{
moduleName = (name modItem)
if (GrepString moduleName)
{
fullModuleName = (fullName(modItem))
mName = read(fullName modItem , false)
b= getMostRecentBaseline (mName)
if (b != null )
{
PrintAndOutput moduleName " -\tBaseline : "(major b)"."(minor b)(suffix b) " \t " (dateOf b) "\n"
}
else
{
PrintAndOutput moduleName " \t### No Baseline Information ### \t" " \n"
}
}
}
}
}
DisplayResults ( Modtype)
【讨论】: