//**************************************************************************** // $Module type: Package // $Module name: cRDCProjectIniFile.pkg // // $Author : Nils Svedmyr, RDC Tools International. // Copyright (c) 2012 RDC Tools International // E-mail : support@rdctools.com // Web-site : http://www.rdctools.com // // Created : 2012-09-20 @ 18:04 (Military date format - Year-Month-Day) // // Note : The file must be USEd after declaration of the ghoApplication object, as it uses // properties of that object. // // The code is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. // This is free software; you can redistribute it and/or modify it under the terms of the // GNU Lesser General Public License - see the "GNU Lesser General Public License.txt" // in the help folder for more details. // Use cApplication.pkg Use cIniFile.pkg Use vWin32fh.pkg #IFNDEF CS_Notepad Define CS_Notepad for "Notepad.exe" #ENDIF #IFNDEF CS_Editor Define CS_Editor for "Editor" #ENDIF #IFNDEF CS_EditorParams Define CS_EditorParams for "Editor Parameters" #ENDIF #IFNDEF CS_SectionName Define CS_SectionName for "Settings" #ENDIF #IFNDEF CS_UseHighlightstateText Define CS_UseHighlightstateText for "Use Highlight Row State" #ENDIF #IFNDEF CS_HighlightColorText Define CS_HighlightColorText for "Highlight Row Color" #ENDIF #IFNDEF CS_pbAlternateRowColor Define CS_pbAlternateRowColor for "pbUseAlternateRowBackgroundColor" #ENDIF #IFNDEF CS_BooleanYes Define CS_BooleanYes for "Yes" #ENDIF #IFNDEF CS_BooleanNo Define CS_BooleanNo for "No" #ENDIF Class cRDCProjectIniFile is a cIniFile Procedure Construct_Object String sApplicationFileName sExtension Forward Send Construct_Object // If this package is used _before_ the cApplication object, these two lines // will generate runtime errors. So the package must be USEd _after_ the cApplication object Property String private_psIniFilePath Property String private_psIniFileName Property String psSectionName "Settings" Set psIniFilePath to (psProgramPath(phoWorkspace(ghoApplication))) Get GetApplicationFileName of ghoApplication to sApplicationFileName Get ParseFileName sApplicationFileName to sApplicationFileName Get ParseFileExtension sApplicationFileName to sExtension Set psIniFileName to (Replace(sExtension, sApplicationFileName, "ini")) End_Procedure Procedure Set psIniFilePath String sPath Get vFolderFormat sPath to sPath Set private_psIniFilePath to sPath End_Procedure Procedure Set psIniFileName String sFileName Set psFileName to sFileName Set private_psIniFileName to sFileName End_Procedure Function psIniFilePath Returns String Function_Return (private_psIniFilePath(Self)) End_Function Function psIniFileName Returns String Function_Return (private_psIniFileName(Self)) End_Function // *** Generalized messages to Get & Set values of the ini file. // Sets a value in the program's ini file (write) // Pass a section name, the value name parameter and the value itself to be written. Procedure Set IniFileValue String sSection String sValueName String sValue String sIniFile sPath Get psIniFilePath to sPath Get psIniFileName to sIniFile Move (sPath + sIniFile) to sIniFile Set psFileName to sIniFile Send WriteString sSection sValueName sValue End_Procedure // Get a value from program's ini-file (read) // Pass a section name and the name of the value parameter & a default value. // Returns the value Function IniFileValue String sSection String sValueName String sDefaultValue Returns String String sValue sIniFile sPath Get psIniFilePath to sPath Get psIniFileName to sIniFile Move (sPath + sIniFile) to sIniFile Set psFileName to sIniFile Get ReadString sSection sValueName sDefaultValue to sValue Function_Return sValue End_Function End_Class #IFNDEF ghoProjectIniFile Global_Variable Integer ghoProjectIniFile #ENDIF Object oRDCProjectIniFile is a cRDCProjectIniFile Move Self to ghoProjectIniFile End_Object