home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP25.EXE / CHP2513.PRG < prev    next >
Encoding:
Text File  |  1991-06-12  |  1.7 KB  |  59 lines

  1. /*
  2.    Listing 25.13. Browsing an array of directory information.
  3.    Author: Craig Yellick
  4.    Excerpted from "Clipper 5: A Developer's Guide"
  5.    Copyright (c) 1991 M&T Books
  6.                       501 Galveston Drive
  7.                       Redwood City, CA 94063-4728
  8.                       (415) 366-3600
  9. */
  10.  
  11. //───── NOTE: must compile with the /N option!
  12.  
  13. function BrowArray2()
  14. local dir_, element, list, key
  15.  
  16.   //  Load the dir_ array with a complete set of
  17.   //  directory information for the current subdirectory.
  18.   dir_ := directory()
  19.  
  20.   //  This will be our "element pointer".
  21.   element := 1
  22.  
  23.   //  General browse setup.
  24.   @ 9, 19 to 20, 61 double
  25.   list := TBrowseNew(10, 20, 20, 60)
  26.   list:headSep := "---"
  27.   list:colSep  := " | "
  28.   list:footSep := "---"
  29.  
  30.   //  Assign the positioning blocks.
  31.   list:goTopBlock    := { || element := 1 }
  32.   list:goBottomBlock := { || element := len(dir_) }
  33.   list:skipBlock := { |n| ArraySkip(len(dir_), @element, n) }
  34.  
  35.   //  File name is first element in array.
  36.   list:addColumn(TBColumnNew("File Name", ;
  37.        { || padr(dir_[element, 1], 12) } ))
  38.  
  39.   //  Size is second element.
  40.   list:addColumn(TBColumnNew("Size", ;
  41.        { || transform(dir_[element, 2], "999,999,999") } ))
  42.  
  43.   //  Date and time are third and forth elements.
  44.   //  We'll skip the file attributes in the fifth element.
  45.   list:addColumn(TBColumnNew("Date", { || dir_[element, 3] } ))
  46.   list:addColumn(TBColumnNew("Time", { || dir_[element, 4] } ))
  47.  
  48.   //  Display the window and process navigation keystrokes.
  49.   do while .t.
  50.     do while .not. list:stabilize()
  51.     enddo
  52.     if .not. Navigate(list, inkey(0))
  53.       exit
  54.     endif
  55.   enddo
  56. return nil
  57.  
  58. // end of file CHP2513.PRG
  59.