Help in Listbox

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • carlossequeira
    Forum Member
    • Jun 2005
    • 9

    Help in Listbox

    I intend to load the name of same games into a list box, the games are in one directory and sub directory.

    I write the code above and only one game are load to the listbox.

    I need too to only show the name of the game without the extension

    ListBox.SetVisible("caixa1", true);

    min = 1; -- The number to start at
    max = 3; -- The number to stop at

    for count = min, max do

    data = File.Find("AutoPlay\\accao2", "*.exe", false, false, nil, nil);

    ListBox.SetItemText("caixa1", count, data[count]);

    ListBox.SetUpdate("caixa1", false);
    end

    Thanks for your help

    Carlos
  • Desmond
    Indigo Rose Staff Member
    • Jul 2003
    • 709

    #2
    Hello,

    You need to trim the extension off the string before you do this:
    Code:
    ListBox.SetItemText("caixa1", count, data[count]);
    One way to do that is with the String.TrimRight action. Or, you could search for the position of the '.' in the string, and do a String.Mid action to get everything up to that point.

    Comment

    • carlossequeira
      Forum Member
      • Jun 2005
      • 9

      #3
      Listbox

      Thanks for the idea

      But how can i retrive the other files with the loop for, because im populate only the first row.

      Thanks

      Carlos

      Comment

      • Desmond
        Indigo Rose Staff Member
        • Jul 2003
        • 709

        #4
        Hello,

        I'd first do a File.Find to generate a table of all of the files. For example:
        Code:
        sFolder = _SourceDrive .. "\\Path\\To\\Your\\Folder";
        tFiles = File.Find(sFolder, "*.*", true, false, nil, nil);
        Then, you can add each item in that table:
        Code:
        for nItemNumber, sCompleteFilePath in tFiles do
            sFilenameNoExtension = String.SplitPath(sCompleteFilePath).Filename;
            ListBox.SetItemText("caixa1", sFilenameNoExtension, sCompleteFilePath);
        end
        The for loop above moves through the file list returned by the File.Find action one item at a time. It strips the filename from the path, stores that as the item text in the listbox, and uses the complete path for the item data.

        I haven't tested this script, so it may need some tweaking, but give 'er a go.

        Let me know if that's what you were looking for, or if i missed the mark.

        Comment

        Working...
        X