home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / CLASSES / INI.PRG < prev    next >
Text File  |  1994-04-22  |  2KB  |  77 lines

  1. #include "FiveWin.ch"
  2.  
  3. //----------------------------------------------------------------------------//
  4.  
  5. CLASS TIni
  6.  
  7.    DATA   cIniFile
  8.  
  9.    METHOD New( cIniFile ) CONSTRUCTOR
  10.  
  11.    METHOD Get( cSection, cEntry, uDefault, uVar )
  12.  
  13.    METHOD Set( cSection, cEntry, uValue )
  14.  
  15. ENDCLASS
  16.  
  17. //----------------------------------------------------------------------------//
  18.  
  19. METHOD New( cIniFile ) CLASS TIni
  20.  
  21.    DEFAULT cIniFile := ""
  22.  
  23.    if ! Empty( cIniFile ) .and. At( ".", cIniFile ) == 0
  24.       cIniFile += ".ini"
  25.    endif
  26.  
  27.    ::cIniFile = cIniFile
  28.  
  29. return
  30.  
  31. //----------------------------------------------------------------------------//
  32.  
  33. METHOD Get( cSection, cEntry, uDefault, uVar ) CLASS TIni
  34.  
  35.    local cType := ValType( If( uDefault != nil, uDefault, uVar ) )
  36.  
  37.    if Empty( ::cIniFile )
  38.       if cType == "N"
  39.          uVar = GetProfInt( cSection, cEntry, uDefault )
  40.       else
  41.          uVar = GetProfString( cSection, cEntry, cValToChar( uDefault ) )
  42.       endif
  43.    else
  44.       if cType == "N"
  45.          uVar = GetPvProfInt( cSection, cEntry, uDefault, ::cIniFile )
  46.       else
  47.          uVar = GetPvProfString( cSection, cEntry, cValToChar( uDefault ),;
  48.                                  ::cIniFile )
  49.       endif
  50.    endif
  51.  
  52.    ::Set( cSection, cEntry, uVar )
  53.  
  54.    do case
  55.       case cType == "D"
  56.            uVar = CToD( uVar )
  57.  
  58.       case cType == "L"
  59.            uVar = ( Upper( uVar ) == ".T." )
  60.    endcase
  61.  
  62. return uVar
  63.  
  64. //----------------------------------------------------------------------------//
  65.  
  66. METHOD Set( cSection, cEntry, uValue ) CLASS TIni
  67.  
  68.    if Empty( ::cIniFile )
  69.       WriteProfString( cSection, cEntry, cValToChar( uValue ) )
  70.    else
  71.       WritePProString( cSection, cEntry, cValToChar( uValue ), ::cIniFile )
  72.    endif
  73.  
  74. return nil
  75.  
  76. //----------------------------------------------------------------------------//
  77.