01-25-2016 02:56 AM
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 ..
Solved! Go to Solution.
01-25-2016 02:57 AM
Can you post the relevant code?
01-25-2016 03:01 AM - edited 01-25-2016 03:04 AM
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
01-25-2016 03:17 AM - edited 01-25-2016 03:18 AM
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.
01-27-2016 02:53 AM - edited 01-27-2016 02:54 AM
Thanks RobertoBozzolo for giving me useful help all the time.
i followed your instructions , i have run the code in debug mode as well pressing F10 and looking at one statement at a time.
what i am doing in the main function is this
iniText = Ini_New (1); // in the main
//then reading two tag values
Ini_ReadFromFile (iniText, pathName);
Ini_GetString (iniText, "section 1", "tag 1", &str1); // reading ip address
Ini_GetInt (iniText, "section 1", "tag 2", &intVal); // reading port number
// now my user interface opens
// on the user interface i have a popup in which user can enter port number and ip address
// i use GetCtrlVal to get both values (i.e one interger port and other string ip )
// then i replace previous tag value by doing this
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
01-27-2016 03:39 AM
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 ()
01-27-2016 10:09 PM
what u mean by updating tag values and how to update tag values ?? can u guide please
01-28-2016 01:56 AM
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:
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
01-28-2016 02:06 AM
Saying it graphically:
01-29-2016 02:01 AM
thanks alot so nice of you , i respect u :manvery-happy: