comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » check if other routine is accessing a text file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: check if other routine is accessing a text file [message #88224 is a reply to message #88223] Mon, 31 March 2014 08:14 Go to previous message
chris_torrence@NOSPAM is currently offline  chris_torrence@NOSPAM
Messages: 528
Registered: March 2007
Senior Member
On Sunday, March 30, 2014 8:42:27 PM UTC-6, Jim P wrote:
> On Sunday, March 30, 2014 7:26:54 PM UTC-6, hoiti...@gmail.com wrote:
>
>> Hi,
>
>>
>
>>
>
>>
>
>> I'm trying to read/write (openw,openu,openr) the same text file using multiple IDL prompts. The different prompts usually read/write the file at different time, but there is a tiny chance that they read/write at the same time. Is there any keywords or routines that can test if other program is using the file?
>
>>
>
>>
>
>>
>
>> Ideally, I'd like to do something like this:
>
>>
>
>>
>
>>
>
>> test_if_someone_writing?
>
>>
>
>> yes: wait for 3 seconds and try again
>
>>
>
>> no: go ahead and read/write
>
>>
>
>>
>
>>
>
>> Thanks!
>
>
>
> There is nothing in IDL's file I/O library that will do this directly. You might consider using a semaphore around your openw and openr statements. See the docs for SEM_CREATE, SEM_LOCK, SEM_RELEASE, and SEM_DELETE. They're intended primarily to prevent conflicts and collisions on system resources, disk files included.
>
>
>
> Jim P.

Jim's suggestion is a good one. Another possibility is to create another copy of the file (file_copy), write all your data to it, and then use file_move to give it the correct name. That way you don't need to worry about writing new data while the file is still being read in another IDL process. You would probably need to put a catch (or on_ioerror?) to make sure the file_move didn't fail.

Cheers,
Chris
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: check if other routine is writing a text file
Next Topic: stregex fails to match underscore

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 07:19:59 PDT 2025

Total time taken to generate the page: 3.60047 seconds