home *** CD-ROM | disk | FTP | other *** search
- // Tbex16.prg
- //
- // Standard generic browse routine, MyBrowse2. Allows key specific
- // actions to be passed as key / block pairs in the TBrowse:cargo
- // TBrowse:cargo[1] is the before keys, TBrowse:cargo[2] is the
- // after keys
- //
- // Compile with /a /m /n /w
-
- #include "Inkey.ch"
-
- FUNCTION MyBrowse2(oTbr)
-
- LOCAL nKey
- LOCAL lExitRequested := .F.
- LOCAL nElem
- LOCAL aBeforePairs
- LOCAL aAfterpairs
-
- // set defaults for before and after keys
- IF ValType(oTbr:cargo) != "A"
- aBeforePairs := {}
- aAfterPairs := {}
- ELSE
- aBeforePairs := iif(oTbr:cargo[1] == NIL, {}, oTbr:cargo[1])
- aAfterpairs := iif(oTbr:cargo[2] == NIL, {}, oTbr:cargo[2])
- ENDIF
-
- DO WHILE !lExitRequested
- FullStabilize(oTbr)
- nKey := InKey(0)
- nElem := Ascan(aBeforePairs, ;
- {|e| e[1] == nKey })
- IF nElem > 0
- lExitRequested := Eval(aBeforePairs[nElem, 2], oTbr)
- ELSEIF !StdMeth(nKey, oTbr) .AND. oTbr:stable
- nElem := Ascan(aAfterPairs, ;
- {|e| e[1] == nKey })
- lExitRequested := iif(nElem > 0, ;
- Eval(aAfterPairs[nElem, 2], oTbr), ;
- nKey == K_ESC)
- ENDIF
- ENDDO
-
- RETURN NIL