home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a065 / 1.img / TBEXS.EXE / TBEX16.PRG < prev    next >
Encoding:
Text File  |  1992-03-18  |  1.4 KB  |  46 lines

  1.     // Tbex16.prg
  2.     //
  3.     // Standard generic browse routine, MyBrowse2. Allows key specific
  4.     // actions to be passed as key / block pairs in the TBrowse:cargo
  5.     // TBrowse:cargo[1] is the before keys, TBrowse:cargo[2] is the
  6.     // after keys
  7.     //
  8.     // Compile with /a /m /n /w
  9.  
  10.     #include "Inkey.ch"
  11.  
  12.     FUNCTION MyBrowse2(oTbr)
  13.  
  14.     LOCAL nKey
  15.     LOCAL lExitRequested := .F.
  16.     LOCAL nElem
  17.     LOCAL aBeforePairs
  18.     LOCAL aAfterpairs
  19.  
  20.       // set defaults for before and after keys
  21.       IF ValType(oTbr:cargo) != "A"
  22.         aBeforePairs := {}
  23.         aAfterPairs  := {}
  24.       ELSE
  25.         aBeforePairs := iif(oTbr:cargo[1] == NIL, {}, oTbr:cargo[1])
  26.         aAfterpairs  := iif(oTbr:cargo[2] == NIL, {}, oTbr:cargo[2])
  27.       ENDIF
  28.  
  29.       DO WHILE !lExitRequested
  30.         FullStabilize(oTbr)
  31.         nKey := InKey(0)
  32.         nElem := Ascan(aBeforePairs, ;
  33.                        {|e| e[1] == nKey })
  34.         IF nElem > 0
  35.           lExitRequested := Eval(aBeforePairs[nElem, 2], oTbr)
  36.         ELSEIF !StdMeth(nKey, oTbr) .AND. oTbr:stable
  37.           nElem := Ascan(aAfterPairs, ;
  38.                          {|e| e[1] == nKey })
  39.           lExitRequested := iif(nElem > 0, ;
  40.                                 Eval(aAfterPairs[nElem, 2], oTbr), ;
  41.                                 nKey == K_ESC)
  42.         ENDIF
  43.       ENDDO
  44.  
  45.     RETURN NIL
  46.