Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
A Star Lingo Pathfinding Algorithm
Custom Scroll Bars
Find angles of a right triangle
Impactica
Arca Database Xtra
All_In_One Button Hue Shift
Blend Sprite
Effector Set II for Alphamania
DirectEmail
A cool button
 

 

 

Behavior file browser

Added on 10/2/2000

 

Compatibilities:
behavior D7 D8 PC

Required Xtras:
Buddy API
FileXtra

This item has not yet been rated

Author: MediaMacros (website)

This is a little utility that will turn any scrollable field member into a file browser. It is not terribly useful on its own, but can be modified easily to suit your needs. Requires the FileXtra

property spriteNum, driveList, curDirectory

on beginSprite me
  if getOne([#field,#text], sprite(spriteNum).member.type) <> 0 then
    theDrives = drivesToList()
    driveList = ""
    repeat with x = 1 to theDrives.count
      driveList = driveList & theDrives[x] & return
    end repeat
    sprite(spriteNum).member.text = driveList
    curDirectory = ""
  end if
end

on mouseUp me
  if getOne([#field,#text], sprite(spriteNum).member.type) <> 0 then
    if the doubleClick then      
      theLine = the mouseLine
      theLineText = sprite(spriteNum).member.text.line[theLine]
      put theLineText
      if getOne([""," ", "..", "*****Directories*****", "*****Files*****"], theLineText) = 0 then
        --is a valid click      
        if curDirectory = "" then
          curDirectory = theLineText
          buildTree()
        else
          isFile =  baFileDate( curDirectory & "\" & theLineText , "dd-mm-yy" , "hh:nn:ss" )
          if isFile = "" then
            --is a folder
            curDirectory = curDirectory & "\" & theLineText
            buildTree()
          else
            --is a file
            numChars = theLineText.chars.count
            if numChars >= 4 then
              extension = theLineText.char[(numChars - 3)..(numChars)]
              if getOne([".exe", ".com", ".bat"], extension) <> 0 then
                --is an executable
                baRunProgram( baShortFileName(curDirectory & "\" & theLineText) , "normal", true )
              else
                ok = baOpenFile(baShortFileName(curDirectory & "\" & theLineText), "normal")              
                if ok < 32 then getError(ok)
              end if
            end if            
          end if
        end if
      else
        --is invalid or is ..
        if theLineText = ".." then
          the itemDelimiter = "\"
          theItems = curDirectory.item.count
          newDir = ""
          if theItems = 1 then
            curDirectory = ""
            sprite(spriteNum).member.text = driveList
          else            
            repeat with y = 1 to (theItems - 1)
              newDir = newDir & curDirectory.item[y]
              if y < (theItems - 1) then
                newDir = newDir & "\"
              end if
            end repeat
            curDirectory = newDir
            buildTree()
          end if
        end if        
      end if
    end if
  end if
end

on getError whatError
  case whatError of
    0  :  alert "System was out of memory."
    2  : alert "File was not found."
    3   :alert "Path was not found."
    5  : alert "Sharing or network-protection error."
    6  : alert "Library required separate data segments for each task."
    8  :  alert"There was insufficient memory to start the application."
    10  : alert"Windows version was incorrect."
    11  : alert "Executable file was invalid. Either it was not a Windows application or there was an error in the .EXE image."
    12  : alert "Application was designed for a different operating system."
    13  : alert "Application was designed for MS-DOS 4.0."
    14  : alert "Type of executable file was unknown."
    15  : alert "Attempt was made to load a real-mode application (developed for an earlier version of Windows)."
    16  : alert "Attempt was made to load a second instance of an executable file containing multiple data segments that were not marked read-only."
    19  : alert "Attempt was made to load a compressed executable file. The file must be decompressed before it can be loaded."
    20  :  alert"Dynamic-link library (DLL) file was invalid. One of the DLLs required to run this application was corrupt."
    21  : alert "Application requires 32-bit extensions."
    26  : alert "A sharing violation occurred."
    27  : alert "The filename association is incomplete or invalid."
    29  : alert "The DDE transaction failed."
    30  : alert "The DDE transaction could not be completed because other DDE transactions were being processed."
    31  : alert "There is no application associated with the given filename"
  end case
end


on buildTree me
  theText = "*****Directories*****" & return
  folders = baFolderList(curDirectory)
  files = baFileList(curDirectory, "*.*")
  if folders.count >= 1 then
    repeat with x = 1 to folders.count
      theText = theText & folders[x] & return
    end repeat
  end if
  theText = theText & "*****Files*****" & return
  if files.count >= 1 then
    repeat with x = 1 to files.count
      theText = theText & files[x] & return
    end repeat
  end if
  theText = theText & ".." & return
  sprite(spriteNum).member.text = theText
  sprite(spriteNum).member.scrollTop = 0
end

on getBehaviorDescription me
  describe = "This is a little utility that will turn any scrollable field member into a file browser.  It is not terribly useful on its own, but can be modified easily to suit your needs.  Requires the FileXtra"
  return describe
end

on getBehaviorTooltip me
  describe = "This is a little utility that will turn any scrollable field member into a file browser.  It is not terribly useful on its own, but can be modified easily to suit your needs.  Requires the FileXtra"
  return describe
end

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail