07-29-2009 09:47 AM
hi mike,
Thank your explanation. I don't know that ini file open function will close after reading all content automatically.
hi, Jonnie
Can you tell me how to set file permissions? Do you mean set permissions function in advanced file functions?
I will try it.
When i open access right before i want to call close config data funciton to write data to file, at this time, is there possible that other suvbi open this config
data and modify it? If I can make sure other subvi cannot share this file with current subvi, it is better. I can implemente this by set permission function,
right?
Thank all your help.
07-29-2009 12:59 PM - edited 07-29-2009 01:00 PM
mmm2006 wrote:
....When i open access right before i want to call close config data funciton to write data to file, at this time, is there possible that other suvbi open this config
data and modify it?
...
Hi mmm2006,
if you really need this, then you have to integrate the access change function into the "open config data" function. Additionally you should store the reference of your ini file and make sure that the file stay open at all the time, til you use the "close config data" function. With this, it should be possible that you write data to the file but other processes can't.
Mike
07-29-2009 02:44 PM - edited 07-29-2009 02:48 PM
mmm2006 wrote:
I just want to write test result to a ini file in a test subvi, and read content from it in another display subvi.
Each file has a very nice semaphore you can use. This is the archive bit.
Is this file always a new file? Then you can do the following: Open Config Data will create the file with the archive bit set. Then write the data and at last make a Close Config Data. Now reset the archive bit using the normal file functions. The display subvi will see this file and the archive bit set. It will ignore the file. After it sees the reset archive bit it will read in the data.
Be aware that you cannot use backup shemes using the archive bit to determine to backup the file.
The file is always the same and the results will be appended? This is a little bit more complicated since it involves data queues, renaming of files and error handling. Let say the normal filename is test_result.ini. Before writting rename the file to test_result_writting.ini. Now update the data in the file. After that rename the file to test_result_written.in. This file will be read by the display subvi and then renamed to test_result.ini.
The writer VI will come to a situation where the display VI will not have completed and therefore the file test_result.ini is not existant. You have to queue the data. Both VIs have the need to check the existance of the source file during rename. You can just try a rename and check the error cluster for error 7. Error 7 means the source file does not exist.
Both solutios make no assumption where the writer and display VIs are running. The maybe running in the same application, different applications even on different machines.
If we can make the assumption that both VIs are running in the same application we have a very simple solution. This will only involve a synchronization object named semaphore. Make in Help >> Find Examples a search for semaphore. You need only one semaphore for the file. The VI who will have access to the file will try to lock the semaphore. When it got the lock handle the file and then release the lock.
07-29-2009 11:51 PM
Hi Mike,
But how can i make sure the config data file is kept in open status?
You had said that config file will be closed automatically after it opened.
Thanks.
wt.
07-30-2009 12:00 AM
Hi, Waldemar,
Thank your help.
I think it is a good idea that changing file name. In my application, Main vi start a test vi and display vi. So i think they are in
a application, right?
I can try to using a semaphore firstly.
Thank your help again.
br.
wt.
07-30-2009 01:24 AM
Hi mmm2006,
you can copy the config.llb to a new location and make your changes there. Add a file refnum constant to the data typedef and store the file refnum there. Insert the "deny access" function into the "Open Config data" function and delete the "close file" function. In the "Close config data" function you write first your data to the file, because you have the access rights and then you close the file. You can use the stored refnum for it. The access rights will be changed automatically.
Mike
07-30-2009 10:58 AM
Hi Mike,
I have checked "Open Config data" function. it don't
close after open config data. My enviroment is labview8.5.
Is it the problem of different version?
Thanks.
07-31-2009 01:30 AM - edited 07-31-2009 01:30 AM
Hi mmm2006,
it's not a problem of different version. See the attached pictures, made from LabVIEW 8.5.
Mike
07-31-2009 01:32 AM
Hi mmm2006,
attached you'll find some pictures which show how you can implement the access right change into the config vi's. I recommend to to copy the config.llb before you change something.
Mike
08-01-2009 10:01 AM
HI, Mike,
You are very nice. THank you very much. I must try them because some icons of function
is not familiar to me.
br
mwt.