Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 14 of 14
  1. #1
    Join Date
    Jun 2008
    Posts
    165

    Star I need help with an easy way to display files to download

    Hi all, a new project in the making, but has been halted after trying a few ways, to no avail.

    Basically I need to display around 70 files to download, each download will be displayed with a title, and then the hidden data will be the download URL.

    An example I have tried is a listbox with the program title as the item text, and the URL in the Item Data part, but I have no way of loading this on show (either from registry, text file or ini file)

    An example:

    Item Text Item Data

    Program 1 http://www.myprog1.exe
    Program 2 http://www.myprog2.exe
    etc...

    What I have managed to do is use this code:
    Code:
    ListBox.DeleteItem("ListBox1", -1);
    tbl_folders = TextFile.ReadToTable(_DesktopFolder.."\\progs list.txt");
    for count = 1, Table.Count(tbl_folders) do
    	result = ListBox.AddItem("ListBox1", tbl_folders[count], "");
    end
    but in the listbox it just shows the url text, but I would like a way to store both the Item Text AND the Item Data so when it loads the page, it is all filled in, I am pulling my hair out here as I have a few apps & have made that are downloaders and listbox apps, but I cannot incorporate them into 1.

    I have tried writing to the registry, an ini file AND a text file, but none do what I want, is there any way to do what I need?

    I have also tried using a tree, but I have never been able to figure them out so have avoided them at all cost!

  2. #2
    Join Date
    Jun 2007
    Location
    Delphi II
    Posts
    1,534
    Please don't double post.
    Action Plugins
    AllOn | Box | Class | Code | Cursor | DXML | Error | Frames | GlobalPaths | Group | INIPlus |KeyBind | KeyLock | MathEx | Menu | Name | Project | Resize | StatusBar
    Download

  3. #3
    Join Date
    Jun 2008
    Posts
    165
    I am sorry, I compiled the thread, and after clicking on submit, it timed out, took over 180 seconds to try and complete, then I clicked submit again and it said I could only do 1 opst per 5 mins, so I went back to the topics but couldnt see it so I created another 1, sorry again :(

  4. #4
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Posts
    279
    Ive been getting time out errors as well, usually followed by the server 400 error. I though it was my machine but maybe it's not. Anyway, give this a shot:

    Code:
    ListBox.DeleteItem("ListBox1", -1);
    tbl_folders = TextFile.ReadToTable(_DesktopFolder.."\\progs list.txt");
    for count = 1, Table.Count(tbl_folders) do
        result = String.SplitPath(tbl_folders[count]);
    	ListBox.AddItem("ListBox1",result.Filename , tbl_folders[count]);
    end
    There are 10 types of people in the world: those who understand binary, and those who don't.

  5. #5
    Join Date
    Jun 2008
    Posts
    165
    Quote Originally Posted by Scriptonite View Post
    Ive been getting time out errors as well, usually followed by the server 400 error. I though it was my machine but maybe it's not. Anyway, give this a shot:

    Code:
    ListBox.DeleteItem("ListBox1", -1);
    tbl_folders = TextFile.ReadToTable(_DesktopFolder.."\\progs list.txt");
    for count = 1, Table.Count(tbl_folders) do
        result = String.SplitPath(tbl_folders[count]);
    	ListBox.AddItem("ListBox1",result.Filename , tbl_folders[count]);
    end
    Thanks Scriptonite, this method is quite good, but the problem still exists that I need a way to show in the text (of listbox, combo box or whatever else) is say for example:

    WinZip, but with the data(download url) hidden.

    I did think of a way of manually typing the data in and then at runtime it would populate the listbox, but the problem with that is I would have to update the whole program each time I wanted to add something new...


    On second thoughts, this will do for now thank you so much Scriptonite, I will go with this :-)

  6. #6
    Join Date
    Jun 2008
    Posts
    165

    Another Question

    Right, after going with Scriptonite's suggestion, I now need 1 more bit of help...

    I want to have 2 buttons, 1 to download all the listed programs, the other button to just download the selected proram.

    Now if it was a comboBox, I can do the get selected, and it will work, but with Listbox it will not, so I guess what I am asking is, how when I select an item in a listBox, can I use it to get the selected text?

  7. #7
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Posts
    279
    This function should work. This is not tested.

    Code:
    AllApps = ListBox.GetCount("ListBox1");
    
    for count =1, AllApps do
    
    URL = ListBox.GetItemData("ListBox1", count);
    appName = String.SplitPath(URL)
    HTTP.Download(URL, "AutoPlay\\Docs\\"..appName.Filename..appName.Extension, MODE_BINARY, 20, 80, nil, nil, nil);
    
    
    end
    There are 10 types of people in the world: those who understand binary, and those who don't.

  8. #8
    Join Date
    Jun 2008
    Posts
    165
    Quote Originally Posted by Scriptonite View Post
    This function should work. This is not tested.

    Code:
    AllApps = ListBox.GetCount("ListBox1");
    
    for count =1, AllApps do
    
    URL = ListBox.GetItemData("ListBox1", count);
    appName = String.SplitPath(URL)
    HTTP.Download(URL, "AutoPlay\\Docs\\"..appName.Filename..appName.Extension, MODE_BINARY, 20, 80, nil, nil, nil);
    
    
    end
    Thanks for your efforts mate, but that code dont work :(

    I do have a app I made a while ago called Portable Downloader, I have tried to mix and match the code, but I just cant figure it out!

    I will attatch the portable downloader app incase its usefull for anybody, there is a single downloader bit, the download url then gets stored into a listbox, there is a page for a multi-downloader, and also a batch downloader, might be of use to somebody!

  9. #9
    Join Date
    May 2006
    Posts
    5,380
    so I guess what I am asking is, how when I select an item in a listBox, can I use it to get the selected text?
    try this:
    Code:
    -- single selection
    local tSel = ListBox.GetSelected("ListBox1");
    if tSel then
    	local sName = ListBox.GetItemText("ListBox1",tSel{1]);
    	local sURL = ListBox.GetItemData("ListBox1",tSel{1]);
    
    	-- dowmnload  your file
    	
    	
    else
    	-- no selection
    	
    end

    or this:
    Code:
    -- multi selection
    local tSel = ListBox.GetSelected("ListBox1");
    if tSel then
    	
    	-- loop all selected
    	for nIndex, nItem, tSel do
    		local sName = ListBox.GetItemText("ListBox1",nItem);
    		local sURL = ListBox.GetItemData("ListBox1",nItem);
    
    		-- dowmnload  your file
    	
    	end
    else
    	-- no selection
    	
    end
    Open your eyes to Narcissism, Don't let her destroy your life!!

  10. #10
    Join Date
    Jun 2008
    Posts
    165
    Sorry guys, none of your suggestions are working for me so I'm gonna attatch the new project I'm working on so you have a better idea, and this is for Windows Updates.

  11. #11
    Join Date
    May 2006
    Posts
    5,380
    yeah, i wish i could just copy n paste code into a project and have it magical work too!

    edit your code!, change the variable names etc
    Open your eyes to Narcissism, Don't let her destroy your life!!

  12. #12
    Join Date
    Oct 2009
    Location
    127.0.0.1
    Posts
    279
    Well, I sifted through your code. You have to read through the code and change things like variable names. You can't copy an paste different peoples code and expect it to work. I've been picking at this a couple minutes at a through the morning and did not have the extra time to go back through and comment the code. I made the necessary changes to make it work, please take the time to go through it and see what changes were made. I think you could have easily found the issues if you had read through the code, there were variables that were not defined anywhere before they were called. Best of luck.
    Attached Files
    There are 10 types of people in the world: those who understand binary, and those who don't.

  13. #13
    Join Date
    Jun 2008
    Posts
    165
    RizlaUK: I DID mess around and change the code till i got soo fed up with trying to figure things out, I tried to copy the code from my previous downloader into the new 1 and change things, but nothing!


    @Scriptonite: I have just got in and will check that out and comment in due course thanks loads

  14. #14
    Join Date
    Jun 2008
    Posts
    165
    Quote Originally Posted by Scriptonite View Post
    Well, I sifted through your code. You have to read through the code and change things like variable names. You can't copy an paste different peoples code and expect it to work. I've been picking at this a couple minutes at a through the morning and did not have the extra time to go back through and comment the code. I made the necessary changes to make it work, please take the time to go through it and see what changes were made. I think you could have easily found the issues if you had read through the code, there were variables that were not defined anywhere before they were called. Best of luck.
    Thanks so much, this is exactly what I needed, have a pint on me

Posting Permissions

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