Language Reference Guide : B. Dedicated User Classes for .INI File Support : How You Can Use the INI File Facility
 
Share this page          
How You Can Use the INI File Facility
To use the INI file facility, first declare a ProfileObject object. Then read in its current content using the ReadProfile method and handle any lookups or changes. Finally, rewrite the file using WriteProfile. The only four methods you need are ReadProfile, WriteProfile, GetProfileVarchar, and SetProfileVarchar. See the following example:
DECLARE
    Info      = ProfileObject;
    mySection = Varchar(256);
    myKey     = Varchar(256);
    myResult  = Varchar(256);
    status    = Integer not null;
ENDDECLARE
BEGIN
    /* Read the initialization file from disk */
    Info.ReadProfile (IniFile = 'test.ini');

    /* Look up a Section and Entry */
    mySection = 'Screen';
    myKey = 'XPos';

    status = Info.GetProfileVarchar (Section =
        mySection,
                  Keyword = myKey,
                  Entry = ByRef (myResult));
    If status = FALSE Then
        myResult = '0';  /* Not found, default to 0 */
    EndIf;
    /* Update the entry (or create it if it wasn't found) */
    myResult = '500';
    status = Info.SetProfileVarchar (Section = mySection,
        Keyword = myKey,
        Entry = myResult);

    /* Write the file to disk */
    Info.WriteProfile (IniFile = 'test.ini');
END