Re: check if file open by mr_unreliable
mr_unreliable
Wed Feb 28 20:02:12 CST 2007
hi again RdS,
You might try "FileExists".
Or, you might try "Brute Force"
--- <air code> ---
bFileWrittenTo = False
code to create file...
code to write file...
bFileWrittenTo = TRUE
code to test value change...
if (bFileWrittenTo) then
close the file...
create new file.
loop back to continue testing for value change
Else
create new file
loop back to continue testing for value change
End If
--- <end air code> ---
cheers, jw
RdS wrote:
> thanks for your reply.
>
> I don't want to delete the file, but only close the current file assigned to
> my fso object and create a new file.
>
> The process should be:
> 1) create a new file
> 2) write data to the new file...loop until a value I am reading from another
> file changes.
> 3) when value in file I am reading changes then I need to close the current
> file I am writing to and create a new file.
>
> My problem is how do I check to see if there is a file I am already writing
> to (ie. the first time I write to a new file there would be no file I am
> writing to)?
>
> thanks again.
>
> "mr_unreliable" wrote:
>
>> hi RDS,
>>
>> I suggest re-reading the documentation on "Close" and "Delete".
>>
>> In other words, closing the file doesn't get rid of it,
>> it only makes the file available to other apps. And your
>> "file object" remains, containing a reference to the file.
>>
>> Rather than "Close" it, I suggest, close + delete + set
>> your file object to nothing. That should get rid of it.
>>
>> cheers, jw
>> ____________________________________________________________
>>
>> You got questions? WE GOT ANSWERS!!! ..(but,
>> no guarantee the answers will be applicable to the questions)
>>
>>
>> RdS wrote:
>>> hi,
>>>
>>> I have the following code that writes to a text file.
>>>
>>> set objDestinationFile = objFSO.CreateTextFile(strDestinationFilename,true)
>>> .
>>> .
>>> .
>>> objDestinationFile.WriteLine FileTypeVal & "," & FileTypeVal
>>>
>>> After I write lines to the file and when a field changes I need to close the
>>> file and create a new one for writing. How do I check to see if the file is
>>> open by my code so that I can issue a close? If it isn't open I don't want
>>> to close it, I just want to create new file. The only time it wouldn't be
>>> open is the first time the script executes. Would doing the following
>>> accomplish my goals and be correct?
>>>
>>> if isobject(objDestinationFile) then objDestinationFile.Close
>>>
>>> After I issue close do I need to set the object variable to nothing or can I
>>> simply issue above set again.
>>>
>>> thanks alot
>>>
>>>