On Jan 23, 2007, at 3:34 PM, Paul Gaspar wrote:

Joe,

what would you recommend in this situation:

I have a stream which is always open but needs to be closed regularely to force a physical write of the data to disk (because of the .Flush bug, http://www.realsoftware.com/feedback/ viewreport.php?reportid=xltobpqb).

The stream is a property in a class or module, not a local variable.

So at the end, what is the advatage of

   Stream=Nil

   Stream=F.OpenAsBinaryFile(true)  // Reopen

over this solution which I use now:

   Stream.Close

   Stream=F.OpenAsBinaryFile(true)  // Reopen

Isn't the old stream object destroyed in both cases by F.OpenAsBinaryFile?

Actually, OpenAsBinaryFile attempts to create the new stream object. It then assigns the result to Stream. Had you not called Stream.Close, your code would likely fail since you'd be trying to open a file that is still open.

In your case, there is no particular advantage. My point, which I believe is also Joe's, is that it is never better to call Close than to set the stream object to nil. By always setting a stream object to nil when you're done with it, you don't have to think which you should do.

Charles Yeomans
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

Reply via email to