IniFile Class

The iniFile class is used to access and manipulate Windows "ini" files. These are typically ASCII text files that contain name=value pairs enclosed in [section] headings.

This object is part of the SYSCLASS library. Standalone apps need to include the LIBRARY SYSCLASS entry at the top of the source file, while Active Pages automatically include the SYSCLASS library.


Properties:
    string filenameName of the ini file.

Methods:
    object = new( string filename )
    string = Get( string section, string name, string defvalue )
    string = GetItems( string section )
    string = GetString( string section, string name, string defvalue )
    string = Set( string section, string name, string value )
    string = SetString( string section, string name, string value )


Description:

The iniFile class is instantiated with a call to the new( ) operator. The name of the ini file is passed as the filename parameter in a fully qualified path format.

The Get and GetString methods are called with the section and name of the item within the section to get. A default value is also passed in the event that either the specified section or named item does not exist. The method returns the correpsonding value associated with the specified name.

The GetItems method returns a semi-colon (";") delimited string containing a list of all of the names within a specified section.

The Set and SetString methods update or add the specified value to the named item within the specified section.


Platforms:
    Windows, DOS, Internet Active Pages


Example:
  LIBRARY sysclass.flb
  
  FUNCTION LoadWebSelectWithIniData( vname )
    local s

    ini = new( "iniFile", 'c:\windows\mydata.ini' )
    if ( type( ini ) != "O" )
    	return( "Error creating iniFile Object" )
    end

    items = ini.GetItems( "Config" )
    if ( strempty( items ) )
    	return( "No Items Listed" )
    end
    
    s = "<select name=" + vname + ">\r\n"
    i = 1
    while ( 1 )
    	curitem = strextract( items, ";", i++ )
    	if ( strempty( curitem ) )
    		break
    	end
    	s += "<option>" + curitem + " "
    	s += ini.get( "Config", curitem, "" ) + "\r\n"
    end
    s += "</select>\r\n"

    return( s )
  END

  

Sample Ini File Structure:
  [Config]
  FullName=George W. Bushington
  Processor=Pentium III
  Memory=64MB
  
  [Location]
  street=123 East Sycamore Lane
  city=Missoin Viejo
  state=CA
  zip=92692
 
  
(c) 2000-2001 by West Coast Web Adventures, Inc., All Rights Reserved