LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

problem updating ini file ini file

Solved!
Go to solution

i get input ip address from the user and replace the previous ip address in the .ini file with latest ip address but the issue is this that when a user enter the ip address and i write it to my ini file it is not done at once but if i do it twise by calling same function from my command button twise then my ini file is updated , this is strage although iniwrite function returnes success on first attempt as well ; which i have checked with breakpoint but when i do it twise then it is done , please guide me in detail , i am really amayzed by this strange behaviour ..

0 Kudos
Message 1 of 15
(6,280 Views)

Can you post the relevant code?



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 15
(6,281 Views)

can u start with ininew(1) for the handel returne or ininew(0) is must if i am using one ini file  ?? can this be the case , i dont have code right now on this pc. but i know that i have use ini file for initial loding of parameters and then finally in a callback for mordification by the use and i have not used ini file in different threads which is recommended by cvi to not use ini in multiple threads 

Spoiler
Smiley Happy
0 Kudos
Message 3 of 15
(6,277 Views)

The parameter for Ini_New has no effect on the behaviour you are seeing.

It's difficult to try guessing what's happening without looknig at the code: may there be some condition that prevents writing down to disk the updated IniText object on the first run? Try step-running the code to see what happens.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 15
(6,273 Views)

Thanks 

Ini_WriteToFile(iniText, pathName);  //

Ini_PutString (iniText, "section 1", "tag 1", "string 2");
Ini_PutInt (iniText, "section 1", "tag 2", 8080); // or any other value i get from popup dialog box

//then close popupdialog

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

the issue i am facing is that when i press command button and this writing to file code executes then after pressing the button once my desired job is not done although wrietofile code is hit which i have checked using breakpoint but when i press the button second time the job of writing to file is successful although this is the time when my code is executed second time

// now more testing i did

i chage the ip address when ever i press the button and what i found was that the one precious statment was written rather than the latest

e.g

i enter 8080 value changed on inifile none

i enter 8081 value changed on inifile 8080

i enter 8082 value changed on inifile 8081

i enter 8083 value changed on inifile 8082

i enter 8084 value changed on inifile 8083

i enter 8085 value changed on inifile 8084

how is this happening ?? why is this happening ?? i tried changing tag postion and even there order nothing happend ... please help me it feels as if some gost is delaying my input by one Smiley Frustrated

 

 

 

0 Kudos
Message 5 of 15
(6,224 Views)

The problem is that you need to update the tag/value pairs before, and write them to disk as the last thing:

Ini_PutInt ()

Ini_PutString ()

Ini_WriteToFile ()

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 6 of 15
(6,218 Views)

what u mean by updating tag values and how to update tag values ?? can u guide please Smiley Surprised

0 Kudos
Message 7 of 15
(6,201 Views)
Solution
Accepted by topic author smartprogrammer

Smiley Frustrated

I already gave you the exact order of functions in my preceding message!

 

Ini file instrument builds an object in memory which permits you to store and locate values. This object can be populated reading from a file on disk; similarly, it can be saved on a file on disk. These are the very first and last operation to perform if you want an up-to-date image of your values on disk. There are three layers to consider:

  1. The file on disk
  2. The IniText object in memory
  3. The variables specific to your program

With this in mind, the correct sequence to update the file on disk so that it reflects the value your variables have in memory is:

 

Ini_New           Create the object in memory

Ini_ReadFromFile  Populate it with disk content

Ini_Get           Read from the memory objecy into variables in your program

 

Here tou can update program values

 

Ini_Put           Update the memory object with the content of your variables

Ini_WriteToFile   Save all to disk

Ini_Dispose       Clear memory

 

Since you are saving to disk before calling Ini_Put functions, the disk image is not up to date



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 8 of 15
(6,188 Views)
Solution
Accepted by topic author smartprogrammer

Saying it graphically:

 

IniFile paradigm.png



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
Message 9 of 15
(6,186 Views)

thanks alot so nice of you , i respect u :manvery-happy:

0 Kudos
Message 10 of 15
(6,161 Views)