New topic: 

Showing folders only in a listbox

<http://forums.realsoftware.com/viewtopic.php?t=30519>

       Page 1 of 1
   [ 1 post ]                 Previous topic | Next topic         Author  
Message       ojan           Post subject: Showing folders only in a 
listboxPosted: Fri Oct 16, 2009 12:18 pm                        
Joined: Fri Oct 16, 2009 12:05 pm
Posts: 1              Hi!

I'm trying to modify the "File List Example.rbp" in the examples directory to 
show folders only - with no success  .

This is the code from the Expandrow event handler.
Code:dim i,itemsAdded, size,decimal as integer
dim f as folderitem
dim sizeStr, Kind as string
dim Today as date
Today=new date
f=getfolderItem(cell(Row,PathColumn))
for i=1 to f.Count
  If f.item(i).visible then
  If f.item(i).directory = true then  //Checks if the file is a folder
  me.AddFolder f.item(i).name //This adds a new folder to the list
  me.RowPicture(me.lastindex) = app.ResourceFork.getcicn(222)
  Kind = "Folder"
  ElseIf f.item(i).mactype = "APPL" then //Checks if the file is an application
  me.Addrow f.item(i).name //Lines like this add a row to the listbox, which 
stand for a file in the folder being viewed
  me.RowPicture(me.lastindex) = app.ResourceFork.getcicn(333) //Lines like this 
add a picture to the row being created. The row is grabbed from a cicn resource 
in the app.
  Kind = "Application"
  ElseIf f.item(i).mactype = "SITD" then //Checks if the file is a Stuffit 
archive
  me.Addrow f.item(i).name
  me.RowPicture(me.lastindex) = app.ResourceFork.getcicn(444)
  Kind = "Document"
  ElseIf f.item(i).mactype = "TEXT" then //Checks if the file is a text file
  me.Addrow f.item(i).name
  me.RowPicture(me.lastindex) = app.ResourceFork.getcicn(555)
  Kind = "Document"
  ElseIf f.item(i).mactype = "clpt" then  //Checks if the file is a text 
clipping
  me.Addrow f.item(i).name
  me.RowPicture(me.lastindex) = app.ResourceFork.getcicn(666)
  Kind = "Text Clipping"
  Else //If the file non of the above it is given a generic document icon
  me.Addrow f.item(i).name
  me.RowPicture(me.lastindex) = app.ResourceFork.getcicn(111)
  Kind = "Document"
  End If
  itemsAdded=itemsAdded+1
  //put the path in a non-visible column
  cell(row+itemsAdded,PathColumn)=f.item(i).absolutepath
  //put in the mod date
  if f.item(i).modificationDate.DayofYear=(Today.DayofYear-1) then
  cell(row+itemsAdded,1)="Yesterday"
  else
  if f.item(i).modificationDate.shortDate=Today.shortDate then
    cell(row+itemsAdded,1)="Today"
  else
    cell(row+itemsAdded,1)=f.item(i).modificationDate.AbbreviatedDate
  end if
  end if
  //handle the size column
  if f.item(i).directory then
  sizeStr="-"
  else
  size=f.item(i).length
  if size<1000 then
    sizeStr=Str(size)+" bytes"
  else
    if size<1000000 then
    sizeStr=Trunc(size/1000,0)+"K"
    else
    sizeStr=Trunc(size/1000000,2)+"MB"
    end if
  end if
  end if
  cell(row+itemsAdded,2)=sizeStr
  //now handle the kind column
  cell(row+itemsAdded,3)=Kind
  end if //it's visible
Next
exception outofboundsexception
msgBox "Error: "+str(i)


Can anybody please point me in the right direction to get it to show only 
folders without any documents or applications? 

thanx
ojan   
                            Top            Display posts from previous: All 
posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost 
timeSubject AscendingDescending          Page 1 of 1
   [ 1 post ]     
-- 
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]

Reply via email to