Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Write to file
Topic Summary: Writing attribute values to a file
Created On: 7-May-2008 19:24
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 7-May-2008 19:24
User is offline View Users Profile Print this message


Corey Carroll

Posts: 48
Joined: 25-May-2006

I am modifying an existing dxl to do the following:

1)Search modules for a defined value in an attribute
2)Count the number of objects that contain that criteria
3)Display the path, module name, number of objects, and object identifiers of those objects.

The attached code displays the module name, identifier, and counts how many objects there are in the DXL window.

It also creates and .xls file and captures the path, module name, and number of objects.

What I want it to do is to list the objects after it reports the number of objects. The problem is below, it doesn't like the string reqnum in that section.

/*Section to write to file */
wfile << pathName "\t" moduleName "\t" reqCount "\t" reqnum "\n"

I am assuming I will need to create a buffer, but I don't exactly know how to do that. Any help is much appreciated. And keep in mind, I am not a skilled programmer, so I have to muddle my way through this stuff.

Thanks,
Corey

Edited: 7-May-2008 at 21:34 by Corey Carroll
Report this to a Moderator Report this to a Moderator
 7-May-2008 20:58
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

It doesn't like the variable reqnum because you never assign it to anything so its null.

And you can't just write out an .xls file using a stream. Excel files have a file header. Write to a .csv file which can be opened in Excel since you're already separating data by tabs.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 7-May-2008 21:37
User is offline View Users Profile Print this message


Corey Carroll

Posts: 48
Joined: 25-May-2006

Originally I was using a .csv, but one of my iterations didn't like writing to that file, so I changed it to an .xls. I re-attached the code to the origianl post. I missed a few things when I did a cleanup before I posted. Even when I define reqnum = identifier (o), it doesn't like it. I will keep playing with it.
Report this to a Moderator Report this to a Moderator
 7-May-2008 23:05
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

You have two 'reqnums'. The 'string' in the outer context is never assigned to anything. The 'Buffer' on in inner context is never deleted. By the time you are writing 'reqnum' at the bottom, the inner context is finished so you are trying to print a variable that has never had a value; no doubt you are getting 'undefined variable reference'.

Add 'reqnum = ""' at the top. Delete the Buffer reqnum. delete 'tempStringOf'. That should do it.

Actually, by the time you are printing at the bottom, what's the point of printing the last object in the module's ID?

- Louie
Report this to a Moderator Report this to a Moderator
 8-May-2008 14:16
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

DOORS doesn't care what you're writing to with a stream. It opens it as a text file and writes to it. What matters is whether or not you're writing the file properly for what application it will ultimately be opened with. If you had a problem writing out to a csv file, it wasn't that the csv file didn't like it, there was some problem with your DXL.

Edit: And actually I just realized that you're separating data with tabs, not commas. Use the tsv extension. When you open it with Excel you can choose to load the data into excel using the tab character as a delimiter.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com

Edited: 8-May-2008 at 14:28 by David Pechacek
Report this to a Moderator Report this to a Moderator
 13-May-2008 15:12
User is offline View Users Profile Print this message


Corey Carroll

Posts: 48
Joined: 25-May-2006

Thanks everybody...I haven't had time to work on it lately, but will pick it back up soon.

Concerning the tabs, I wondered myself about that. The code I used to build upon was set up that way...and for some reason opens in .csv just fine. I will change it and keep everbody posted on my progress.
Report this to a Moderator Report this to a Moderator
 20-May-2008 18:32
User is offline View Users Profile Print this message


Corey Carroll

Posts: 48
Joined: 25-May-2006

The code below is a summary of all the suggestions above. The only issue is that in the .csv file, it only displays the identifier of the last object in the module. I wanted to list the identifier for all objects that meet the criteria. How is this done, or am I asking too much of DXL?

Thanks,
Corey
Report this to a Moderator Report this to a Moderator
 20-May-2008 18:52
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

You can accumulate all the ReqNums with the outside buffer we just told you to delete. Something like attached.

- Louie
Report this to a Moderator Report this to a Moderator
 20-May-2008 19:50
User is offline View Users Profile Print this message


Corey Carroll

Posts: 48
Joined: 25-May-2006

I'm getting the following error:

null buffer parameter was passed into argument position 1

...in reference to the following line:

if (length(bufAllReqNums) == 0)

What does this mean...I can't figure out how to correct it.
Report this to a Moderator Report this to a Moderator
 20-May-2008 20:31
User is offline View Users Profile Print this message


Scott Boisvert

Posts: 348
Joined: 14-Apr-2006

It means the buffer is set to null.

So for some reason you either directly set bufAllReqNums to null or something returned null into bufAllReqNums.

-------------------------
Scott Boisvert
Engineering Tools Administrator
L-3 Communications - Avionics Systems
scott.boisvert@l-3com.com
Report this to a Moderator Report this to a Moderator
 20-May-2008 20:35
User is offline View Users Profile Print this message


ron lewis

Posts: 650
Joined: 20-Sep-2004

You may be getting this error because you deleted bufAllReqNums

Example script demos the problem and the error

Buffer bufAllReqNums=create
delete bufAllReqNums
if (length(bufAllReqNums) == 0) print "Ok"
Report this to a Moderator Report this to a Moderator
 21-May-2008 18:03
User is offline View Users Profile Print this message


Corey Carroll

Posts: 48
Joined: 25-May-2006

Thanks to all for the help! The attached code is everything so far, and it works. I'm still trying to work out the kinks. Trying to get the IDs printed after the module information, as opposed to before. Also trying to get it to not print the module info if the ReqCount = 0. Next will be working in a GUI to let the user define what needs to be reported!

Thanks again for all the help!
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.