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: Closing streams
Topic Summary:
Created On: 15-Nov-2007 19:51
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.
 15-Nov-2007 19:51
User is offline View Users Profile Print this message


Andrea Varriale

Posts: 17
Joined: 22-Mar-2007

Hello.
Is there a way to check if a stream has already been closed?
I have a piece of code with some branches and it sometimes happens that I try to close a stream twice...
I hope the question does not sound too stupid
Andrea
Report this to a Moderator Report this to a Moderator
 15-Nov-2007 19:56
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

In every place its closed, assign the Stream handle to null after closing it. Then, also around each place its closed, check if the handle to the stream is null before closing it. Also when you first declare the Stream, assign it to null.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
 16-Nov-2007 10:58
User is offline View Users Profile Print this message


Andrea Varriale

Posts: 17
Joined: 22-Mar-2007

Thanks David
Report this to a Moderator Report this to a Moderator
 19-Nov-2007 15:16
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Ignore Pechacek's sound, sensible, and resonable response, demonstrating proper software practices. But if you don't ignore it, then consider writing and using the function attached.

I think you could surround your 'close(s)' commands with 'noError' and 'lastError' commands:
noError()
close(s)
lastError() // Ignore close errors

My solution may perhaps be better to bandaid an existing script, but Pechacek's is obviously better.

- Louie
Report this to a Moderator Report this to a Moderator
 19-Nov-2007 15:30
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

Yeah adding a function that cuts down on lines of code and lowers the amount of repetitive code is probably better.

Way to refactor my answer Lou.

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

Edited: 19-Nov-2007 at 15:31 by David Pechacek
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 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 2 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.