Автор: KerberX
Дата сообщения: 06.06.2013 23:02
Use this script. Replace them Global Functions. Then, if the element at "Root/"AnyElementName"/PlaceName" will not text (empty string), then it will not be added to the list.
[more=Script]
Код: sXML = "AutoPlay\\Docs\\Test.xml";
sObjectName = "PlacesList";
--
SelectedPlace = "";
SelectedStaff = "";
--
function ReadXML(sXML, sObjectName)
ListBoxEx.SetUpdate(sObjectName, false);
ListBoxEx.DeleteAllItems(sObjectName);
if sXML ~= "" and File.DoesExist(sXML) == true then
XML.Load(sXML);
local nErrorCode = Application.GetLastError();
if (nErrorCode ~= 0) then
Dialog.Message("Error", _tblErrorMessages[nErrorCode], MB_OK, MB_ICONEXCLAMATION);
else
local tElements = XML.GetElementNames("Root", true, true);
if tElements ~= nil then
for a, b in pairs (tElements) do
local sPlaceName = XML.GetValue(b.."/PlaceName");
if sPlaceName ~= "" then
local nIndex = ListBoxEx.AddItem(sObjectName, sPlaceName, "Place", "", "Close", 1, LBXITEM_HTML, 0, {16316664,16764057,16316664}, {16316664,16764057,16316664}, {16316664,16764057,16316664}); --
ListBoxEx.SetItemGStyle(sObjectName, nIndex, VERTICAL, LBXISTATE_NORMAL);
ListBoxEx.SetItemCheckBoxVisible(sObjectName, nIndex, false);
ListBoxEx.SetItemIconSize(sObjectName, nIndex, 16);
--
local tPlace = XML.GetElementNames(b, true, true);
if tPlace ~= nil then
for x, y in pairs (tPlace) do
if XML.GetElementNames(y, true, true) ~= nil then
local sName = XML.GetValue(y.."/Name");
local sDate = XML.GetValue(y.."/Date");
--
local nIndex = ListBoxEx.AddItem(sObjectName, sName, "Staff", sDate, "", 3, LBXITEM_HTML, 0, {46819,10092543}, {46819,10092543}); --
ListBoxEx.SetItemGStyle(sObjectName, nIndex, BACKWARD_DIAGONAL, LBXISTATE_NORMAL);
ListBoxEx.SetItemVisible(sObjectName, nIndex, false);
ListBoxEx.SetItemIconSize(sObjectName, nIndex, 16);
end
end
end
end
end
end
end
end
ListBoxEx.SetUpdate(sObjectName, true);
ListBoxEx.SelectItem(sObjectName, 1, true);
ListBoxEx.SelectItem(sObjectName, 1, true);
end
--
function ReadXML_PlacesList(sXML, sObjectName)
ListBoxEx.SetUpdate(sObjectName, false);
ListBoxEx.DeleteAllItems(sObjectName);
if sXML ~= "" and File.DoesExist(sXML) == true then
XML.Load(sXML);
local nErrorCode = Application.GetLastError();
if (nErrorCode ~= 0) then
Dialog.Message("Error", _tblErrorMessages[nErrorCode], MB_OK, MB_ICONEXCLAMATION);
else
local tElements = XML.GetElementNames("Root", true, true);
if tElements ~= nil then
for a, b in pairs (tElements) do
local sPlaceName = XML.GetValue(b.."/PlaceName");
if sPlaceName ~= "" then
local nIndex = ListBoxEx.AddItem(sObjectName, sPlaceName, "Place", "", "Close", 1, LBXITEM_HTML, 0, {16316664,16764057,16316664}, {16316664,16764057,16316664}, {16316664,16764057,16316664}); --
ListBoxEx.SetItemGStyle(sObjectName, nIndex, VERTICAL, LBXISTATE_NORMAL);
ListBoxEx.SetItemCheckBoxVisible(sObjectName, nIndex, false);
ListBoxEx.SetItemIconSize(sObjectName, nIndex, 16);
end
end
end
end
end
ListBoxEx.SetUpdate(sObjectName, true);
ListBoxEx.SelectItem(sObjectName, 1, true);
end
--
function GetPlaceXMLID(sPlaceName)
local tElements = XML.GetElementNames("Root", true, true);
if tElements ~= nil then
for x, y in pairs (tElements) do
local sValue = XML.GetValue(y.."/PlaceName");
if sValue == sPlaceName then
return x
end
end
else
return nil
end
end
--
function GetStaffXMLID(sStaffName, nPlaceXMLID)
local tElements = XML.GetElementNames("Root/Place:"..nPlaceXMLID, true, true);
if tElements ~= nil then
for x, y in pairs (tElements) do
local sValue = XML.GetValue(y.."/Name");
if sValue == sStaffName then
return x
end
end
else
return nil
end
end