I have a IBM DOORS database and inside of it there is an project called "Test" which has a symbol as blue folder. Inside of it there is another folder called "ayberk_dxl" which is a yellow folder. What I want to do is, I need to export all formals in ayberk_dxl folder and its sub directories. I am newbie on writing dxl scripts. I have managed to write a script that should perform this operation but there is some errors and I can't solve them. Can anyone give ideas what is wrong with my script please?
Here is my dxl script:
// Define the filePath to save HTML files
string filePath = "C:\\\\Users\\\\t22283srv\\\\Desktop\\\\DOORS_EXPORT"
// Recursive function to process folder and its subfolders
void processFolder(Folder folder) {
Item item
for item in folder do {
if (isModule(item)) {
string itemPath = fullName(item)
Module mod = read(itemPath)
// Check if the "Object Text" attribute exists in the module
if (null != find(mod, "Object Text")) {
string modName = name(mod)
string fileName = filePath "\\\\" modName ".html"
// Export the module to an HTML file
string options = "-html"
export(mod, fileName, options, "", "", "", "")
close(mod)
}
}
if (type(item) == "Folder") {
// Process subfolders
string folderPath = fullName(item)
Folder subFolder = find(folderPath)
processFolder(subFolder)
}
}
}
// Get the main folder
Folder mainFolder = find("/TEST/ayberk_dxl")
// Call the function to process the main folder and its subfolders
processFolder(mainFolder)
This gives errors shown below:
-E- DXL: <Line:14> incorrect arguments for function (export)
-E- DXL: <Line:20> incorrect context for binary op (=)
-E- DXL: <Line:26> incorrect context for binary op (=)
-I- DXL: All done. Errors reported: 3. Warnings reported: 0.
I'm afraid it won't be so easy. There is no DXL perm for a HTML export. You might want to have a look at tools like perhaps http://www.smartdxl.com/content/?p=803, using its function emitView
. Or do you use a library that already contains a function named "export"? If so, look at the definition of that function to determine which are the correct arguments. The DXL manual, which resides at https://www.ibm.com/support/knowledgecenter/SSYQBZ_9.6.1/com.ibm.doors.requirements.doc/topics/dxl_reference_manual.pdf, will assist you in finding the correct parameters for each perm.
Your recursive function is generally correct, though "Object Text" is a standard attribute of every formal module, i.e. instead of "isModule" (a perm that does not exist anyway in DOORS, where did you get this code from?), use if type (item) == 'Formal'
. And: don't use variable names that have the same name as a perm, instead of item
use e.g. it
, instead of folder
use e.g. f
, otherwise you will have a hard time understanding the error messages.
all in all, your function can look like this
void processFolder(Folder f) {
Item it
for it in f do {
if (type(it) == "Formal") {
string itemPath = fullName(it)
Module mod = read(itemPath)
string modName = name(it)
// do something with the module...
print modName "-"
close(mod)
}
if (type(it) == "Folder") {
// Process subfolders
Folder subFolder = folder(it)
processFolder(subFolder)
}
}
}
processFolder (folder "/myProject")