home *** CD-ROM | disk | FTP | other *** search
- /*
- Listing 26.14 GETNEW() and TBrowse
- Author: Greg Lief
- Excerpted from "Clipper 5: A Developer's Guide"
- Copyright (c) 1991 M&T Books
- 501 Galveston Drive
- Redwood City, CA 94063-4728
- (415) 366-3600
- */
-
- //───── NOTE: must compile with the /N option!
-
- #include "inkey.ch"
-
- function main(dbf_file)
- local x, browse := TBrowseDB(3, 0, 15, 79), column, key, ele
- local browseaction := { { K_ENTER, { || grabvar(browse) } } , ;
- { K_LEFT, { | | browse:left() } } , ;
- { K_RIGHT, { | | browse:right() } } , ;
- { K_UP, { | | browse:up() } } , ;
- { K_DOWN, { | | browse:down() } } , ;
- { K_HOME, { | | browse:home() } } , ;
- { K_END, { | | browse:end() } } , ;
- { K_PGUP, { | | browse:pageUp() } } , ;
- { K_PGDN, { | | browse:pageDown() } } , ;
- { K_CTRL_LEFT, { | | browse:panLeft() } } , ;
- { K_CTRL_RIGHT, { | | browse:panRight() } }, ;
- { K_CTRL_HOME, { | | browse:panHome() } } , ;
- { K_CTRL_END, { | | browse:panEnd() } } , ;
- { K_CTRL_PGUP, { | | browse:goTop() } } , ;
- { K_CTRL_PGDN, { | | browse:goBottom() } } }
- setcursor(0)
- if dbf_file != NIL
- use (dbf_file) new
- for x := 1 to fcount()
- column := TBColumnNew(field(x), fieldwblock(field(x),
- select()))
- browse:AddColumn( column )
- next
- do while key != 27
- do while ! browse:stabilize() .and. ( key := inkey() ) = 0
- enddo
- if browse:stable
- key := inkey(0)
- endif
- if ( ele := ascan(browseaction, { | a | key == a[1] }) ) > 0
- eval(browseaction[ele, 2])
- endif
- enddo
- use
- endif
- return nil
-
-
- function grabvar(b)
- // determine current column object out of the browse object
- local column := b:getColumn(b:colPos), mget, oldcurs :=
- setcursor(2)
- // create a corresponding GET
- mget := GetNew(Row(), Col(), column:block, column:heading, ;
- b:colorSpec)
- ReadModal( {mget} ) // must pass as an array!
- setcursor(oldcurs) // restore previous cursor
- b:refreshCurrent()
- return nil
-
- // end of file CHP2614.PRG
-