Indigo Rose Software

Professional Software Development Tools

 
+ Reply to Thread
Results 1 to 8 of 8
  1. #1
    Join Date
    Jul 2005
    Posts
    6

    Generate listbox from file folder

    Help!!! Is there a way to generate a listbox from a folder of pdfs that will generate the list and make them clickable to lauch each individual pdf from clicking the name of the file?

  2. #2
    Join Date
    Nov 2006
    Posts
    233
    Code:
    --code to find pdf files and populate listbox
    --place in a button or onshow of page
    
    --Purge listbox of all previous data
    ListBox.DeleteItem("Name Of Listbox", LB_ALLITEMS);
    
    --find all pdf files in the folder
    tblPDF = File.Find("C:\\Path To Folder", "*.pdf", false, false, nil, nil);
    
    --ensure there was a result and continue
    if (tblPDF) then 
    
    	--loop to step through table adding items to listbox
    	for i, v in tblPDF do
    	
    	--split file path so we can get the file name
    	tblSplit = String.SplitPath(tblPDF[i]);
    	
    	--add filename as text and filepath as data
    	ListBox.AddItem("Name Of Listbox", tblSplit.Filename, tblPDF[i]);
    	end
    	
    	
    --no pdf files found
    else Dialog.Message("Notice", "No PDF files found", MB_OK);
    
    end
    Code:
    --code for on click event of listbox
    --get selected item
    tblSelected = ListBox.GetSelected("Name Of Listbox");
    
    --ensure there is a valid selection
    if (tblSelected) then 
    
    --get data for selected item i.e the file path
    strFilePath = ListBox.GetItemData("Name Of Listbox", tblSelected[1]);
    
    	--ensure no errors
    	if strFilePath == "" then
    	Dialog.Message("Notice", "No filepath found", MB_OK);
    	
    	--no error so open file
    	else File.Open(strFilePath, "", SW_SHOWNORMAL);
    	
    	end
    	
    --no listbox item selected
    else Dialog.Message("Notice", "No Item selected", MB_OK);
    
    end

  3. #3
    Join Date
    Jan 2008
    Posts
    47

    Is this any good

    Will this work for you ?
    Regards
    sebalius

  4. #4
    Join Date
    Aug 2007
    Location
    Leon, Mexico.
    Posts
    406

    Why i cant populate a hard drive folder...

    I use this code and the Apz runs just fine... but i need to use this path "c:\\somedir\\otherdir" and when i use my hard drive i cant populate the files to the list box why is that any one can helpme a Byte.

    myCategory = "PDFfiles"; --set the name to your own folder

    bFound = Folder.DoesExist("AutoPlay\\Docs\\"..myCategory);

    if bFound == true then

    tFiles = File.Find("AutoPlay\\Docs\\"..myCategory, "*", false, false, nil, nil);

    if tFiles then

    ListBox.DeleteItem("ListBox1", -1); -- clears the previous choice

    for i,sFilePath in pairs(tFiles) do
    tFileParts = String.SplitPath(sFilePath); -- this breaks everypart of the filepath
    sFileName = tFileParts.Filename; -- this one is the Filename only
    sFileExtension = tFileParts.Extension; -- this one is File Extension only
    sFullFileName = sFileName..sFileExtension; -- concatenate
    ListBox.AddItem("ListBox1", sFileName, sFilePath); -- add to the ListBox
    end

    end

    end

  5. #5
    Join Date
    Aug 2007
    Location
    Leon, Mexico.
    Posts
    406

    Greets Forum People... here is a Problemo any one can help...

    I Just Bumb it...

    About populate a listbox from hard drive using C:\\pathhere\\somefolder

    http://www.indigorose.com/forums/thr...ht=#post179470

  6. #6
    Join Date
    Feb 2007
    Location
    Como, Italy
    Posts
    1,415
    Why you use a sub-path of the application ("AutoPlay\\Docs\\"..) if you instead need the path "c:\\somedir\\otherdir" ?

    The code you posted works fine, but you are making confusion with file paths.
    We are slowly invading your planet to teach lazy humans to read the user manual.
    But don't be scared: we are here to help.

  7. #7
    Join Date
    Aug 2007
    Location
    Leon, Mexico.
    Posts
    406
    I want to populate from "c:\\somedir\\otherdir but does not work... any example will help...


    THANKS AND ENJOY LIFE... ANY HOW...

  8. #8
    Join Date
    Aug 2006
    Posts
    28
    my_docs_path = _DesktopFolder.."\\screens\\";
    --or in your example my_docs_path = "c:\\somedir\\otherdir\\"
    -- Search the user's My Documents folder for the text files.
    search_resultsb = File.Find(my_docs_path, "*.txt", true, false, nil, nil);
    for index, pathb in search_resultsb do
    ListBox.AddItem("ListBox1", pathb, "")
    end
    else

    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. Single EXE file and external folder
    By nals in forum AutoPlay Media Studio 7.5
    Replies: 3
    Last Post: 10-27-2008, 06:04 AM
  3. open file from listbox help please
    By melissa in forum AutoPlay Media Studio 7.5
    Replies: 3
    Last Post: 08-25-2008, 07:09 PM
  4. ListBox to Text File
    By AudioSam in forum AutoPlay Media Studio 6.0
    Replies: 13
    Last Post: 01-15-2007, 06:52 AM
  5. INFO: The Explore Button on the Distribution Folder Dialog
    By Support in forum AutoPlay Media Studio 4.0 Examples
    Replies: 0
    Last Post: 10-11-2002, 12:06 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