-- функция сохранения/чтения насторек ini файла -- первый параметр strPathIni - (строка) путь к файлу ini; -- второй параметр (сторока) strAction действие значения "load" или "save" IniFiles = function (strPathIni, strAction) local tblObjectType={}; -- типы объектов значения которых нужно сохранять/считывать из ini tblObjectType[7]={Name="OBJECT_INPUT", Save = function (object) return Input.GetText(object); end}; tblObjectType[10]={Name="OBJECT_COMBOBOX", Save = function (object) return ComboBox.GetSelected(object); end}; tblObjectType[13]={Name="OBJECT_RADIOBUTTON", Save = function (object) return RadioButton.GetChecked(object); end}; tblObjectType[15]={Name="OBJECT_CHECKBOX", Save = function (object) return CheckBox.GetChecked(object); end}; if strAction=="load" then if File.DoesExist(strPathIni) then local tblSection_names = INIFile.GetSectionNames(strPathIni); if (tblSection_names) then for index_section, section in pairs(tblSection_names) do local tblAllValue_names = INIFile.GetValueNames(strPathIni, section); if (tblAllValue_names) then for index_value, value in pairs(tblAllValue_names) do if section == "OBJECT_INPUT" then Input.SetText(value, INIFile.GetValue(strPathIni, section, value)); elseif section == "OBJECT_COMBOBOX" then ComboBox.SetSelected(value, INIFile.GetValue(strPathIni, section, value)); elseif section == "OBJECT_RADIOBUTTON" then if INIFile.GetValue(strPathIni, section, value) == "true" then RadioButton.SetChecked(value, true); else RadioButton.SetChecked(value, false); end elseif section == "OBJECT_CHECKBOX" then if INIFile.GetValue(strPathIni, section, value) == "true" then CheckBox.SetChecked(value, true); else CheckBox.SetChecked(value, false); end end end end end end end elseif strAction=="save" then local object_names = Page.EnumerateObjects(); error = Application.GetLastError(); if (error ~= 0) then Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION); else if (object_names == nil) then Dialog.Message("Notice", "Нет объектов на текущей странице!", MB_OK, MB_ICONEXCLAMATION); else for index, object in pairs(object_names) do local typeObj = Page.GetObjectType(object); if (tblObjectType[typeObj]) then local strSection = tblObjectType[typeObj].Name; local strValue=object; local strData = tblObjectType[typeObj].Save(object); INIFile.SetValue(strPathIni, strSection, strValue, tostring(strData)); end end end end end end |