LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

labwindow ini files

Solved!
Go to solution

int CVICALLBACK Ini_DIO (int panel, int control, int event,
        void *callbackData, int eventData1, int eventData2)
{
    switch (event)
    {
        case EVENT_COMMIT:
    IniText iniText;
    char pathName[MAX_PATHNAME_LEN];
    char dirName[MAX_PATHNAME_LEN];
    
    /* set up the pathName for the .ini file */
    GetProjectDir (dirName);
    MakePathname (dirName, "myconfig.ini", pathName);

    /* create object for holding the value/tag pairs */
    iniText = Ini_New (TRUE); /* TRUE for automatic sorting */

    /* create the in–memory tag/value pairs */

     Ini_PutInt (iniText, "Acquisition", "Channels", 3);

    /* write out the tag/value pairs */
    Ini_WriteToFile (iniText, pathName);
    
    /* dispose of the in–memory tag/value pairs */
     Ini_Dispose (iniText);
    
     int intVal[5];
      char section[24];
      char tag;

    /* set up the pathName for the .ini file */
      GetProjectDir (dirName);
      MakePathname (dirName, "myconfig.ini", pathName);

    /* create object for holding the value/tag pairs */
     iniText = Ini_New (TRUE); /* TRUE for automatic sorting */

    /* read in the tag/value pairs */
      Ini_ReadFromFile (iniText, pathName);

    /* create the in–memory tag/value pairs */
      
     Ini_GetStringIntoBuffer (iniText, "section 2", "tag 1", &tag,512);
     Ini_GetInt (iniText, "section 2", "tag 1", intVal);

            break;
    }
    return 0;
}

this my code I am able to write myconfig.ini but not able to read that in ring panel which I have defined in .uir file

 

0 Kudos
Message 11 of 12
(1,124 Views)

Well, which value you want to read from the file? You have created a file with one section and one item, next you want to read back from a different section so it's no mistery that you can't obtain what you want. In this case, what you store in the file is what you can read back from it.

 

FYI, the .ini file is nothing but a text file, that you can read with a simple text editor like Notepad: open the file you have created and look at what it's stored in it. That sum of informations is what you can read from the file!

 

Moreover, you are getting different values (a string and an integer) from the same item: if you had error checking enabled you should have get some error in some of the Ini_Get lines. Adding a proper error checking would have informed you of another thing: every Ini_Get that does not terminate on error will return a value of 0 (zero) if the item cannot be found in the file.



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 12 of 12
(1,120 Views)