循环遍历项目以打开特定模块的只读视图

huangapple go评论49阅读模式
英文:

Loop through a project to open read-only view for a specific module

问题

我是dxl的新手,但在互联网上找不到我需要的信息。我能够以只读模式打开一个模块,使用以下方法:

module m = read("D/Fruits/ColorRed/Apples")

但如果我只有项目名称,即“Fruits”,那么如何循环遍历其中的文件夹和模块,例如以只读模式打开Apples呢?

我尝试了以下代码,但它不起作用:

string MODULE_NAME = "Apples"
string PROJECT_NAME = "Fruits"

Module mod = null
for mod in PROJECT_NAME do (
   if (mod.name == MODULE_NAME)(
     read(mod.name)
    )
)

我尝试了以下内容:

英文:

I am new to dxl and I could not find on the internet what I am looking for. I am able to open a module in read-only mode using:

module m = read("D/Fruits/ColorRed/Apples") //Where Project fruits, contains many folders Like ColorRed, ColorYellow, and in Color Red folder there are modules like apples, Cherries, Strawberries etc. which I would like to access

But If I am only given the project name i.e. Fruits. Then how do I loop through the folders and modules inside and open for example Apples in read-only mode?

I have tried out the following code but it does not work,

Here's what I have tried,

string MODULE_NAME = "Apples"
string PROJECT_NAME = "Fruits"

Module mod = null
for mod in PROJECT_NAME do (
   if (mod.name == MODULE_NAME)(
     read(mod.name)
    )
)

答案1

得分: 0

请参考 DXL 手册,链接为 https://www.ibm.com/docs/en/SSYQBZ_9.7.0/com.ibm.doors.requirements.doc/topics/dxl_reference_manual.pdf,第 16 章 "Rational DOORS hierarchy",了解不同的循环可用。我认为您需要循环 "for all items in project",它具有操作 "Assigns itemRef to be each successive undeleted item (for which the user has read access) in project, looping recursively through contained folders and projects."。在您的情况下,这将是

string MODULE_NAME = "Apples"
string PROJECT_NAME = "Fruits"

Project p = project "/Fruits"
Item itemRef
Module mod = null

for itemRef in p do {
 // print fullName(itemRef) "\n"
 if (name (itemRef) == MODULE_NAME) {
   mod = read (fullName itemRef)
 }
}

if (!null mod) {
   …do something with the module…
   close (mod)
}
英文:

Check the DXL manual at https://www.ibm.com/docs/en/SSYQBZ_9.7.0/com.ibm.doors.requirements.doc/topics/dxl_reference_manual.pdf, chapter 16 "Rational DOORS hierarchy", about the different loops available. I think you will need the loop "for all items in project", which has the operation "Assigns itemRef to be each successive undeleted item (for which the user has read access) in project, looping recursively through contained folders and projects.". In your case this would be

string MODULE_NAME = "Apples"
string PROJECT_NAME = "Fruits"

Project p = project "/" PROJECT_NAME
Item itemRef
Module mod = null

for itemRef in p do {
 // print fullName(itemRef) "\n"
 if (name (itemRef) == MODULE_NAME) {
   mod = read (fullName itemRef)
 }
}

if (!null mod) {
   …do something with the module…
   close (mod)
}

huangapple
  • 本文由 发表于 2023年7月3日 22:11:21
  • 转载请务必保留本文链接:https://go.coder-hub.com/76605572.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定