Announcement

Collapse
No announcement yet.

Table count limit?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Table count limit?

    The code below was borrowed off the forum, by T.J Tigger originally. And it works as it should except I cannot import more than around 615 files into the listbox. Much more than that and it returns empty handed.

    A non-random code has no such limitation. I'm hoping someone here can figure out whats causing the restriction.

    Code:
    -- Get your list of files.
    PlayList = Dialog.FileBrowse(true, "Load Videos", "", "", "", "", true, true); 
    
    
    if PlayList then --If there are songs in the table then proceed
    	-- Count the soungs found
    	songCount = Table.Count(PlayList); 
    	
    	-- display the number of songs found
    	Dialog.Message("Count","There are " ..songCount .." files added"); 
    
    	-- for each song found we will do the following
    	for x=1,songCount do
    		--Generate a random number between 1 and the table count
    		rndnum = Math.Random(songCount);
    		
    		--Split the song path using the random number
    		tblSong = String.SplitPath(PlayList[rndnum]);
    
    		-- Add the song to a listbox
    		ListBox.AddItem("ListBox1", tblSong.Filename , PlayList[rndnum]);
    
    		-- Remove the added item from the table
    		Table.Remove(PlayList, rndnum);
    
    		-- get a new table count on the PlayList Table.
    		songCount = Table.Count(PlayList); 
    	end
    end
    Any help would be appreciated.

  • #2
    Code:
    Folder.Create(_DesktopFolder.."\\Temp Files");
    
    for i =1, 700 do
     TextFile.WriteFromString(_DesktopFolder.."\\Temp Files\\"..i..".txt","",false);
    end
    
    PlayList = Dialog.FileBrowse(true, "Locate File", _DesktopFolder.."\\Temp Files", "All Files (*.*)|*.*|", "", "txt", true, false);
    if PlayList then 
    	Dialog.Message("Count","There are " ..#PlayList .." files added"); 
    	for x=1,#PlayList do
    		rndnum = Math.Random(#PlayList);
    		tblSong = String.SplitPath(PlayList[rndnum]);
    		ListBox.AddItem("ListBox1", tblSong.Filename , PlayList[rndnum]);
    		--Table.Remove(PlayList, rndnum);
    		--songCount = Table.Count(PlayList); 
    	end 
    end
    whats commented out is your problem, its a bit pointless deleting table entries to get a count when you are adding them all anyway.

    Comment


    • #3
      Thanks very much Shrek, loaded 2000 text files no problem!
      Much appreciated.

      Comment


      • #4
        After some experimentation I've found that file names which use special characters may cause a failure when trying to load hundreds of items into the listbox. After renaming all my music vids they loaded without problem. This wasn't an issue with non-random code, but looking at it I can't figure out what's causing the problem.

        Comment


        • #5
          ooops, my typing was faster then my thinking ... wrong post sorry
          Last edited by johnraus; 05-22-2014, 04:58 PM. Reason: oops, while writing, discovered i was wrong

          Comment

          Working...
          X