home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a012 / 1.ddi / CHAP26.EXE / CHP2614.PRG < prev    next >
Encoding:
Text File  |  1991-04-30  |  2.3 KB  |  68 lines

  1. /*
  2.    Listing 26.14 GETNEW() and TBrowse
  3.    Author: Greg Lief
  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. #include "inkey.ch"
  14.  
  15. function main(dbf_file)
  16. local x, browse := TBrowseDB(3, 0, 15, 79), column, key, ele
  17. local browseaction := { { K_ENTER, { || grabvar(browse) } } , ;
  18.                  { K_LEFT, { | | browse:left() } } , ;
  19.                  { K_RIGHT, { | | browse:right() } } , ;
  20.                  { K_UP, { | | browse:up() } } , ;
  21.                  { K_DOWN, { | | browse:down() } } , ;
  22.                  { K_HOME, { | | browse:home() } } , ;
  23.                  { K_END, { | | browse:end() } } , ;
  24.                  { K_PGUP, { | | browse:pageUp() } } , ;
  25.                  { K_PGDN, { | | browse:pageDown() } } , ;
  26.                  { K_CTRL_LEFT, { | | browse:panLeft() } } , ;   
  27.                  { K_CTRL_RIGHT, { | | browse:panRight() } }, ;
  28.                  { K_CTRL_HOME, { | | browse:panHome() } } , ;
  29.                  { K_CTRL_END, { | | browse:panEnd() } } , ;
  30.                  { K_CTRL_PGUP, { | | browse:goTop() } } , ;
  31.                  { K_CTRL_PGDN, { | | browse:goBottom() } } }
  32. setcursor(0)
  33. if dbf_file != NIL
  34.    use (dbf_file) new
  35.    for x := 1 to fcount()
  36.       column := TBColumnNew(field(x), fieldwblock(field(x),
  37.    select()))
  38.       browse:AddColumn( column )
  39.    next
  40.    do while key != 27
  41.       do while ! browse:stabilize() .and. ( key := inkey() ) = 0
  42.       enddo
  43.       if browse:stable
  44.          key := inkey(0)
  45.       endif
  46.       if ( ele := ascan(browseaction, { | a | key == a[1] }) ) > 0
  47.          eval(browseaction[ele, 2])
  48.       endif
  49.    enddo
  50.    use
  51. endif
  52. return nil
  53.  
  54.  
  55. function grabvar(b)
  56. // determine current column object out of the browse object
  57. local column := b:getColumn(b:colPos), mget, oldcurs :=
  58. setcursor(2)
  59. // create a corresponding GET
  60. mget := GetNew(Row(), Col(), column:block, column:heading, ;
  61.                b:colorSpec)
  62. ReadModal( {mget} )  // must pass as an array!
  63. setcursor(oldcurs)   // restore previous cursor
  64. b:refreshCurrent()
  65. return nil
  66.  
  67. // end of file CHP2614.PRG
  68.