LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

After open a ini file, can i set deny attribute using deny access function?

Solved!
Go to solution

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.

0 Kudos
Message 11 of 21
(2,042 Views)

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

Message Edited by MikeS81 on 07-29-2009 08:00 PM
Message 12 of 21
(2,030 Views)

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.


It's to late in the evening, to much typing errors.
Message Edited by waldemar.hersacher on 07-29-2009 09:48 PM
Waldemar

Using 7.1.1, 8.5.1, 8.6.1, 2009 on XP and RT
Don't forget to give Kudos to good answers and/or questions
Message 13 of 21
(2,021 Views)

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.

0 Kudos
Message 14 of 21
(2,007 Views)

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.

0 Kudos
Message 15 of 21
(2,006 Views)

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

Message 16 of 21
(1,997 Views)

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.

0 Kudos
Message 17 of 21
(1,980 Views)

Hi mmm2006,

it's not a problem of different version. See the attached pictures, made from LabVIEW 8.5.

 

Mike

Message Edited by MikeS81 on 07-31-2009 08:30 AM
Download All
0 Kudos
Message 18 of 21
(1,971 Views)

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

0 Kudos
Message 19 of 21
(1,969 Views)

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.

0 Kudos
Message 20 of 21
(1,952 Views)