New topic: folderitem contents, specific files
<http://forums.realsoftware.com/viewtopic.php?t=2968> Page 1 of 1 [ 7 posts ] Previous topic | Next topic Author Message Scott Post subject: folderitem contents, specific filesPosted: Tue Feb 21, 2006 5:40 pm Joined: Tue Feb 21, 2006 5:21 pm Posts: 8 Hi everyone, I am rather new to programing and am finding it a bit tricky. I have programed a little in college with RB but that was quite a while ago. Here is my problem. I am writing a program that when opened it will look into a certain directory and take its contents and add them to a listbox. No problem I just wrote a loop using .count The problem is that I only want it to open MP3 files open them as a movie and add them to the list. I am pretty sure I need an array but am not sure how to code it right. If anyone has any ideas I would be greatfull, I really need some sleep. Here is the code for my loop, I actually figured it out through this forum. Dim f as FolderItem Dim n as integer Dim i as Integer f= desktopfolder.child ("mp3s") n = f.count if n >0 then for i = 1 to n[/code] next end if _________________ Logically impaired Top Aaron Ballman Post subject: Posted: Tue Feb 21, 2006 7:55 pm Joined: Wed Sep 28, 2005 8:39 am Posts: 9282 Location: St Augusta, MN Yup -- you should be using FolderItem.Item within that for loop. _________________ * Check out my blog at http://ramblings.aaronballman.com. * RBLibrary.com REALbasic learning at the speed of now! * Get the WFS, everybody's using it. Top Scott Post subject: Posted: Wed Feb 22, 2006 10:29 pm Joined: Tue Feb 21, 2006 5:21 pm Posts: 8 Thanks for the reply Aaron So for I have figured out how to grab every file in a folder and display it in a listbox. Dim f as FolderItem Dim n as integer Dim i as Integer f= desktopfolder.child ("mp3s") n = f.count if n >0 then for i = 1 to n songlist.addrow f.item(i).name next end if My problem is I need to open these files as a MOVIE so the movieplayer can read them. The way it is setup now the files are just strings. It would be even nicer to only pull the mp3 files out of the folder and nothing else. if anyone has any suggestion I would be greatful. Scott _________________ Logically impaired Top Aaron Ballman Post subject: Posted: Wed Feb 22, 2006 10:33 pm Joined: Wed Sep 28, 2005 8:39 am Posts: 9282 Location: St Augusta, MN Each cell in the listbox has a CellTag property which can hold a Variant. Variants are essentially "buckets" which can hold anything. So what I'd do is assign the FolderItem to each cell, like this: Code: for i = 1 to n dim theItem as FolderItem = f.Item( i ) songlist.addrow theItem.name songlist.CellTag( songlist.LastIndex, 0 ) = theItem next So now each cell knows about a FolderItem as well as the item's name. When you want to get the FolderItem back from the cell, you'd do: Code: Dim f as FolderItem = songlist.CellTag( whichRow, 0 ) _________________ * Check out my blog at http://ramblings.aaronballman.com. * RBLibrary.com REALbasic learning at the speed of now! * Get the WFS, everybody's using it. Top Mike Bailey Post subject: Posted: Wed Feb 22, 2006 10:37 pm Joined: Wed Sep 28, 2005 8:30 am Posts: 5424 Location: Austin, TX You could filter out any files that do not have the .mp3 extension. Code: dim f as folderItem f = desktopFolder.child("mp3s") dim i as integer for i = 1 to f.count if right(f.name,4) = ".mp3" then listBox1.addRow f.name end next Now to get the selected folderitem from the name you could do something like this: Code: dim f as folderItem f = desktopFolder.child("mp3s") // load get the selected item from the listbox and find that folderitem in the mp3s folder f = f.child( listBox1.cell( listbox1.listIndex, 0 ) ) // now we can open the file as a move dim mv as movie mv = f.openAsMovie Top Scott Post subject: Posted: Sun Feb 26, 2006 12:30 pm Joined: Tue Feb 21, 2006 5:21 pm Posts: 8 Thanks guys for all your help finally got it working Scott _________________ Logically impaired Top Dx-Dyablo Post subject: Re: folderitem contents, specific filesPosted: Wed Aug 05, 2009 11:19 pm Joined: Fri Feb 08, 2008 10:47 am Posts: 120 Location: Portland, Oregon, USA :lol _________________ Its not the same tell: I'll Kill you, than. It's time To kill... http://www.bestfreeforums.com/forums/dxteam.html Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 7 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
