View Full Version : need help with code
jackdaniels
04-23-2008, 05:34 AM
i want to delete the selected node from ini file... it only deletes from tree object but not from ini file... what am doing wrong :huh
SelectedTab = Tree.GetSelectedNode("Favorites_Panel");
TabDataTable = Tree.GetNode("Favorites_Panel", SelectedTab);
TabText = TabDataTable.Text
if SelectedTab then
Tree.RemoveNode("Favorites_Panel", SelectedTab);
FavCount = Tree.GetChildCount("Favorites_Panel", "0");
for node=1, FavCount do
FavDataTable = Tree.GetNode("Favorites_Panel", node);
Url = FavDataTable.Data
Name = FavDataTable.Text
INIFile.DeleteValue("AutoPlay\\Docs\\favorites.ini", Name, "Url", Url);
end
else
end
TimeSurfer
04-23-2008, 07:06 AM
i want to delete the selected node from ini file... it only deletes from tree object but not from ini file... what am doing wrong :huh
SelectedTab = Tree.GetSelectedNode("Favorites_Panel");
TabDataTable = Tree.GetNode("Favorites_Panel", SelectedTab);
TabText = TabDataTable.Text
if SelectedTab then
Tree.RemoveNode("Favorites_Panel", SelectedTab);
FavCount = Tree.GetChildCount("Favorites_Panel", "0");
for node=1, FavCount do
FavDataTable = Tree.GetNode("Favorites_Panel", node);
Url = FavDataTable.Data
Name = FavDataTable.Text
INIFile.DeleteValue("AutoPlay\\Docs\\favorites.ini", Name, "Url", Url);
end
else
end
I highlighted your problem in red and below is the fix ;)
INIFile.DeleteValue("AutoPlay\\Docs\\favorites.ini", Name, Url)
jackdaniels
04-23-2008, 07:14 AM
thanks alot but it doesnt delete from ini file !!!
TimeSurfer
04-23-2008, 07:34 AM
very odd it worked for me, ill look into it jack and get back wit you
TimeSurfer
04-23-2008, 08:32 AM
your right jack it doesnt work everytime i just tried it again and no go [must be a bug cause its intermittent at best] but here's my workaround [shorter code too hope you dont mind ;)]
Selected = Tree.GetSelectedNode("Favorites_Panel");
SelProps = Tree.GetNode("Favorites_Panel", Selected);
if SelProps then
Name = SelProps.Text
Url = SelProps.Data
INIFile.DeleteSection("AutoPlay\\Docs\\favorites.ini", Name);
Tree.RemoveNode("Favorites_Panel", Selected);
end
will remove from tree and ini [granted if your making favs for a browser you should make it create the section in the ini file as its added.]
jackdaniels
04-23-2008, 08:45 AM
thanks alot TimeSurfer :yes
TimeSurfer
04-23-2008, 10:12 AM
the code i posted above is for your remove button.
here is the new code for your edit button. i also added in error checking and such so that way you dont get null data [sent in a pm also]
Selected = Tree.GetSelectedNode("Favorites_Panel");
SelProps = Tree.GetNode("Favorites_Panel", Selected);
if SelProps then
Name = SelProps.Text
Url = SelProps.Data
INIFile.DeleteSection("AutoPlay\\Docs\\favorites.ini", Name);
NewName = Dialog.Input("Edit Favorite - Enter a name", "Please enter the name for the favorite: "..Name, "", MB_ICONQUESTION);
if NewName ~= "CANCEL" then
NewSite = {}
NewSite.Text = NewName
if NewName == "" then
Dialog.Message("Error", "You must designate a name for your favorite, it cannot be blank.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
NewName = Dialog.Input("Edit Favorite - Enter a name", "Please enter the name for the favorite: "..Name, "", MB_ICONQUESTION);
end
NewUrl = Dialog.Input("Edit Favorite - Specify the address", "Please enter a url address for: "..NewName, Url, MB_ICONQUESTION);
if NewUrl ~= "CANCEL" then
NewSite = {}
NewSite.Text = NewName
NewSite.Data = NewUrl
if NewUrl ~= "" then
Tree.SetNode("Favorites_Panel", Selected, NewSite);
else
Dialog.Message("Error", "URL must be defined and cannot be blank to add favorite.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
NewUrl = Dialog.Input("Edit Favorite - Specify the address", "Please enter a url address for: "..NewName, Url, MB_ICONQUESTION);
end
end
end
if NewSite.Text ~= "" and NewSite.Data ~= "" then
INIFile.SetValue("AutoPlay\\Docs\\favorites.ini", NewSite.Text, "Url", NewSite.Data);
end
end
enjoy ;)
jackdaniels
04-23-2008, 11:01 AM
thanks alot TimeSurfer u r a star :yes
TimeSurfer
04-23-2008, 11:10 AM
lol thanks, btw i just upgraded to rockstar rofl...
heres your new apz m8, :yes [i did remove a couple of your global functions as they werent needed anymore, and i did some customizing to one of em to make the favs display in a hierarchy when you 1st load it and when you add 1]
enjoy :eek: lol love them smilies
jackdaniels
04-23-2008, 11:28 AM
when i click edit and type nothing then click cancel , i get that error
TimeSurfer
04-23-2008, 11:45 AM
oops thats my fault, reposted and fixed. [i was trying to make it so u cant enter blank text lol, **** i wish ams had goto loops lol] problem was i put the conditional statement in wrong place lol
jackdaniels
04-23-2008, 01:05 PM
thanks alot TimeSurfer that works perfect
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.