home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1993 #2 / Image.iso / database / kbrows.zip / DEMO.PRG < prev    next >
Text File  |  1993-05-30  |  2KB  |  59 lines

  1. ******************************************************************************
  2. * PROGRAM ----: DEMO.PRG 
  3. * AUTHOR -----: Kevin E. Saffer
  4. * CREATED ----: 5/27/1993 at 10:21
  5. ******************************************************************************
  6. * demonstrates the KBROWSE function with incremental search and record marking
  7. ******************************************************************************
  8.  
  9. * open a data file and build indexes           
  10. USE address EXCLUSIVE
  11. IF .NOT. FILE("addrname" + INDEXEXT())
  12.   INDEX ON UPPER(lastname)+UPPER(firstname)+initial+"   " TO addrname
  13.   INDEX ON ssn + " " TO addrssn
  14. ENDIF
  15. SET INDEX TO addrname,addrssn  && note that the index order is used later!
  16.  
  17. * set up browsing arrays
  18. m_marked = {}                 
  19. m_retexp = {|| A->lastname}
  20. m_array = {;
  21.   { "Last Name"     , {|| A->lastname}, 1, "@!" },; && use index 1 with a search clause
  22.   { "First Name"    , {|| A->firstname} },;
  23.   { "I"             , {|| A->initial}   },;
  24.   { "SSN"           , {|| A->ssn}, 2, "" },;   && index 2, no search clause
  25.   { "Marked"        , {|| IIF(ASCAN(m_marked,RECNO()) = 0," ","√")} },;  && a marking function
  26.   { "Address Line 1", {|| A->addr1}     },;
  27.   { "Address Line 2", {|| A->addr2}     },;
  28.   { "Address Line 3", {|| A->addr3}     },;
  29.   { "City"          , {|| A->city}      },;
  30.   { "St"            , {|| A->state}     },;
  31.   { "Zip Code"      , {|| A->zipcode}   };
  32. }
  33.  
  34. * set up the screen
  35. CLEAR
  36. @ 00,00 TO 15,79 DOUBLE
  37. @ 16,00 SAY ""
  38. TEXT
  39.  Up Arrow:    Up 1 Record           PgUp:      Up 1 screen     SpaceBar: Marks
  40.  Down Arrow:  Down 1 Record         PgDn:      Down 1 screen   Alpha: Search
  41.  Right Arrow: Column Right          Ctrl-PgUp: Top of File     Enter: Select
  42.  Left Arrow:  Column Left           Ctrl-PgDn: Bottom of File  Esc:   Exit
  43.  Ctrl-Right:  Arrow: Screen Right   Home:      Left Column
  44.  Ctrl-Left:   Arrow: Screen Right   End:       Right Column
  45.  
  46.    Note that moving into an indexed column re-sorts the display accordingly.
  47. ENDTEXT
  48.  
  49. * perform the browse with array parameters, locking the lastname column
  50. m_retval = KBROWSE(01,01,14,78,m_array,m_retexp,"═╤═"," │ ",@m_marked,0)
  51.  
  52. * just for fun, perform a full screen browse
  53. KBROWSE()
  54.  
  55. CLOSE DATABASES
  56. CLEAR
  57. RETURN
  58.  
  59.