i have a tree object and i am trying to save the nodes in it to an ini file and load it on start...
Thanks in Advance
Professional Software Development Tools
i have a tree object and i am trying to save the nodes in it to an ini file and load it on start...
Thanks in Advance
Last edited by jackdaniels; 04-22-2008 at 08:46 AM.
any help or idea![]()
ok, there was many mistakes in that code, but i sorted it for you
Replace the below functions in your project
move the call to "ReadAndInsertFavorites()" from page preload to page on show and set the tree root node data to 0Code:function AddFavorite() Url = Web.GetURL("Web1"); UrlDialog = Dialog.Input("Add Favorite - Specify the adress", "Please enter the url of the website", Url, MB_ICONQUESTION); NameDialog = Dialog.Input("Add Favorite - Enter a name", "Please enter the name of the favorite", "", MB_ICONQUESTION); FavCount = Tree.GetChildCount("Favorites_Panel", "1"); FavNodeData = {}; FavNodeData.Text = NameDialog; FavNodeData.Data = UrlDialog; FavNodeData.Expanded = true; FavNodeData.NodeIndex = 3.1; FavNodeData.ImageIndex = 1; FavNodeData.SelectedImageIndex = 1; Tree.InsertNode("Favorites_Panel", (FavCount), FavNodeData); end function SaveFavorites() FavCount = Tree.GetChildCount("Favorites_Panel", "0"); for node=1, FavCount do FavDataTable = Tree.GetNode("Favorites_Panel", node); Url = FavDataTable.Data Name = FavDataTable.Text if Url ~= "0" then -- dont save the root node or it will keep adding it INIFile.SetValue("AutoPlay\\Docs\\favorites.ini", Name, "Url", Url); end end end function ReadAndInsertFavorites() Favorites = INIFile.GetSectionNames("AutoPlay\\Docs\\favorites.ini"); if Favorites then for index, sections in Favorites do Url = INIFile.GetValue("AutoPlay\\Docs\\favorites.ini", sections, "Url"); FavCount = Tree.GetChildCount("Favorites_Panel", "1"); FavNodeData = {}; FavNodeData.Text = sections; FavNodeData.Data = Url; FavNodeData.Expanded = true; FavNodeData.NodeIndex = FavCount+1; FavNodeData.ImageIndex = 1; FavNodeData.SelectedImageIndex = 1; Tree.InsertNode("Favorites_Panel", (FavCount), FavNodeData); end end end -- test function function OpenFavorite(sNodeIndex) -- make sure nothing happens when the root node is clicked if Tree.GetNode("Favorites_Panel", sNodeIndex).Data ~= "0" then result = Dialog.Message("Notice", Tree.GetNode("Favorites_Panel", sNodeIndex).Data, MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1); end end
heres the apz showing it working
Last edited by RizlaUK; 02-01-2009 at 11:34 AM.
Open your eyes to Narcissism, Don't let her destroy your life!!
thanks alot RizlaUK... i have another problem with tree
i want to edit node in the tree... what am i doing wrong ???
Code:function Edit() SelFav = Tree.GetSelectedNode("Favorites_Panel"); FavDataTable = Tree.GetNode("Favorites_Panel", SelFav); Url = FavDataTable.Data Name = FavDataTable.Text UrlDialog = Dialog.Input("Add Favorite - Specify the adress", "Please enter a new url for : " .. Url, Url, MB_ICONQUESTION); NameDialog = Dialog.Input("Add Favorite - Enter a name", "Please enter the name for the favorite : " .. Name, "", MB_ICONQUESTION); FavNodeData = {}; FavNodeData.Text = NameDialog; FavNodeData.Data = UrlDialog; FavNodeData.Expanded = true; FavNodeData.NodeIndex = SelFav; FavNodeData.ImageIndex = 8; FavNodeData.SelectedImageIndex = 8; Tree.SetNode("Favorites_Panel", SelFav, FavNodeData); end