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

  1. /*
  2.    Listing 25.12. Browsing an array of file names.
  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 BrowArray()
  14. /*
  15.    Load an array of file names and browse it.
  16. */
  17. local files_, element, list, key
  18.  
  19.   //  Load the files_ array with filenames
  20.   //  found in current subdirectory.
  21.   files_ := {}
  22.   aeval(directory(), { |f_| aadd(files_, f_[1]) } )
  23.  
  24.   //  This will be our "element pointer".
  25.   element := 1
  26.  
  27.   //  General browse setup.
  28.   list := TBrowseNew(10, 30, 18, 50)
  29.   list:headSep := "-"
  30.   list:footSep := "-"
  31.  
  32.   //  Assign the positioning blocks.
  33.   list:goTopBlock    := { || element := 1 }
  34.   list:goBottomBlock := { || element := len(files_) }
  35.   list:skipBlock := { |n| ArraySkip(len(files_), @element, n) }
  36.  
  37.   //  Add a file name column object to the browse object.
  38.   list:addColumn(TBColumnNew("File Name", ;
  39.                  { || padr(files_[element], 12) } ))
  40.  
  41.   //  Display the window and process navigation keystrokes.
  42.   do while .t.
  43.     do while .not. list:stabilize()
  44.     enddo
  45.     if .not. Navigate(list, inkey(0))
  46.       exit
  47.     endif
  48.   enddo
  49. return nil
  50.  
  51. // end of file CHP2512.PRG
  52.