How to run a global function from ListBox Item Data?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Nocturnal
    Forum Member
    • Jun 2006
    • 29

    How to run a global function from ListBox Item Data?

    Is this even possible?

    I've created a ListBox similar to a file browser. This ListBox includes all these different setup files to install random programs.

    One of the many things I want this file browser to do is to connect to an ftp and download this file.

    I have the FTP code down and works perfect. But I want to attach it to this ListBox/file browser so that when I click on say the first thing in the ListBox, it will automatically get the data from the global function and then download it to the desktop.

    The thing is I need to a) pass parameters to the programs such as silent install and b) have a few File.Run after each item.

    I'm having a hard time explaining myself so if any of you have the time please feel free to contact me on AIM at RyanKMA or GTalk at [email protected].
  • Nocturnal
    Forum Member
    • Jun 2006
    • 29

    #2
    I can't edit my post so I'm going to add to it.

    I think I have figured out it just a little bit.

    I now know that I can put all of this additional code into a global function.

    I need to know how or if it's even possible to call a global function from a listbox but also keep it so that if and when I sort the listbox, all of the functions work the same, regardless of what order the listbox is in after the sort.

    The only way I have figured out how to do that is to use the Item Data but I cannot for the life of me figure out how to call a global function from the Item Data. I know I can put in a pointer to a file but not anything remotely close to telling it to call and execute a global function.

    OKAY

    I'm even closer than before.

    Here is the code I have for the listbox:

    Code:
    -- Get the selected index
    index = ListBox.GetSelected("ListBox2");
    -- Get the data associated with the selected item
    data = ListBox.GetItemData("ListBox2", index[1]);
    -- Open the document
    function data()
    	install_avast()
    end
    data()
    -- Get the selected index
    index = ListBox.GetSelected("ListBox2");
    -- Get the data associated with the selected item
    data = ListBox.GetItemData("ListBox2", index[2]);
    -- Open the document
    function data()
    	install_ccleaner()
    end
    data()
    NOW my problem is that when I click on the second index item [2], it automatically runs the first function as well as the second. I thought that if you specify that you are getting the data from the second indexed item [2], that it will only work or affect that.

    How do I break it up so that no matter what I do, the second item only does one thing as opposed to doing the entire set of instructions listed in the script for double click?
    Last edited by Nocturnal; 02-27-2009, 02:06 AM.

    Comment

    • Desrat
      Forum Member
      • Nov 2006
      • 240

      #3
      Something like this ?
      Attached Files

      Comment

      • Nocturnal
        Forum Member
        • Jun 2006
        • 29

        #4
        Wow. I am so grateful for your reply. I appreciate it very much. It works how I want it to. I wish I had known that. I was trying to hard with what I posted.

        Thank you again.

        Comment

        Working...
        X