Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2007
    Location
    HeaveN
    Posts
    534

    Star need help with ini file "write and read error"

    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
    Attached Files
    Last edited by jackdaniels; 04-22-2008 at 08:46 AM.

  2. #2
    Join Date
    Mar 2007
    Location
    HeaveN
    Posts
    534
    any help or idea

  3. #3
    Join Date
    May 2006
    Posts
    5,380
    ok, there was many mistakes in that code, but i sorted it for you

    Replace the below functions in your project

    Code:
    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
    move the call to "ReadAndInsertFavorites()" from page preload to page on show and set the tree root node data to 0

    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!!

  4. #4
    Join Date
    Mar 2007
    Location
    HeaveN
    Posts
    534
    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

Similar Threads

  1. Best way to share custom buttons with the group?
    By mwreyf1 in forum AutoPlay Media Studio 6.0
    Replies: 10
    Last Post: 04-28-2010, 01:29 PM
  2. Read ini file from the web to listbox
    By Ham in forum AutoPlay Media Studio 6.0
    Replies: 1
    Last Post: 05-22-2006, 10:54 AM
  3. Tables And Ini File
    By lanfz in forum AutoPlay Media Studio 5.0
    Replies: 0
    Last Post: 05-19-2004, 01:44 PM
  4. Unicode INI file, read on NT 4 crashes app
    By jlm13 in forum AutoPlay Media Studio 4.0
    Replies: 2
    Last Post: 08-07-2003, 09:08 AM
  5. Replies: 0
    Last Post: 08-17-2000, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts