home *** CD-ROM | disk | FTP | other *** search
- // UDFTBROW.PRG
- // Employee Information TBrowse library functions
- // November, 1993
-
- #include "sys.ch"
-
- FUNCTION Init_Tb(TheArray, TheTop, TheLeft, TheBottom, TheRight, TheCondition)
- LOCAL TheBrowse, OldColor, TheCount, TheTotal, TheColumn
-
- TheBrowse := TBrowseDB(TheTop, TheLeft, TheBottom, TheRight)
-
- TheBrowse:HeadSep := '═╤═'
- TheBrowse:ColSep := ' │ '
- TheBrowse:ColorSpec := Browse_Color()
-
- TheTotal := Len(TheArray)
- FOR TheCount := 1 TO TheTotal
- TheColumn := TBColumnNew(TheArray[TheCount, 1], ;
- TheArray[TheCount, 2])
- TheColumn:DefColor := {3, 4}
- TheBrowse:AddColumn(TheColumn)
- NEXT
-
- IF ISBLOCK(TheCondition)
- TheBrowse:GoTopBlock := { | | GoTop_Tb( TheCondition) }
- TheBrowse:GoBottomBlock := { | | GoBot_Tb( TheCondition) }
- TheBrowse:SkipBlock := { | TheCount | Skip_Tb (TheCount, TheCondition) }
- ENDIF
-
- RETURN TheBrowse
-
-
- FUNCTION Browse_Tb(TheArray, TheTop, TheLeft, TheBottom, TheRight, ;
- TheTitle, TheCondition)
- LOCAL OldCursor, OldWindow, TheBrowse, TheKey, TheReturn
-
- OldCursor := SetCursor(SC_NONE)
-
- IF RecCount() = 0
- ErrorMsg('NO RECORDS TO BROWSE')
- RETURN ""
-
- ELSEIF !EOF()
-
- ELSEIF Bottom_It()
-
- ELSEIF EOF()
- ErrorMsg('NO RECORDS TO BROWSE')
- RETURN ""
-
- ENDIF
-
- OldWindow := Win_Open(TheTop, TheLeft, TheBottom, TheRight, TheTitle)
- TheBrowse := Init_Tb(TheArray, TheTop + 1, TheLeft + 1, ;
- TheBottom - 2, TheRight - 1, TheCondition)
-
- DO WHILE TRUE
-
- DO WHILE (!TheBrowse:Stabilize()) .AND. (NextKey() = 0)
- ENDDO
-
- Win_Msg(TheBottom - 1, TheLeft, TheRight, ;
- 'Record: ' + LTrim(Str(RecNo())) + ;
- ' ' + ;
- 'of: ' + LTrim(Str(RecCount())))
-
- TheKey := InKey(0)
-
- IF Movement(TheKey, TheBrowse)
- ELSEIF TheKey = K_ESC
- EXIT
-
- ELSEIF TheKey = K_ENTER
- EXIT
- ENDIF
- ENDDO
-
- Win_Close(OldWindow)
- SetCursor(OldCursor)
-
- TheReturn := Macro(IndexKey())
-
- IF LastKey() = K_ESC
- RETURN Space(Len(TheReturn))
- ENDIF
-
- RETURN TheReturn
-
-
- FUNCTION GoTop_Tb(TheCondition)
-
- DO WHILE (Eval(TheCondition)) .AND. (!BOF())
- Skip_It(-1)
-
- IF !Eval(TheCondition)
- Skip_It(1)
- EXIT
- ENDIF
-
- ENDDO
-
- RETURN NIL
-
-
- FUNCTION GoBot_Tb(TheCondition)
-
- DO WHILE (Eval(TheCondition) .AND. (!EOF()))
- Skip_It(1)
- ENDDO
-
- Skip_It(-1)
-
- RETURN NIL
-
-
- FUNCTION Skip_Tb(TheTotal, TheCondition)
- LOCAL TheCount, OldAlias, OldOrder
-
- OldAlias := Select()
- OldOrder := IndexOrd()
- TheCount := 0
-
- IF TheTotal = 0
- Skip_It(0)
-
- ELSEIF (TheTotal > 0) .AND. (!EOF())
- DO WHILE TheCount < TheTotal
- Skip_It(1)
- IF (!Eval(TheCondition)) .OR. (EOF())
- Skip_It(-1)
- EXIT
- ENDIF
-
- ++TheCount
- ENDDO
-
- ELSEIF TheTotal < 0
- DO WHILE TheCount > TheTotal
- Skip_It(-1)
- IF BOF()
- EXIT
- ENDIF
- IF !Eval(TheCondition)
- Skip_It(1)
- EXIT
- ENDIF
-
- --TheCount
- ENDDO
-
- ENDIF
-
- Order_It(OldOrder, OldAlias)
-
- RETURN TheCount
-
-
- FUNCTION Movement(TheKey, TheBrowse)
- LOCAL ThePointer
- STATIC TheKeyList
-
- TheKeyList := { ;
- K_DOWN , { | TheBrowse | TheBrowse:Down() } , ;
- K_UP , { | TheBrowse | TheBrowse:Up() } , ;
- K_PGDN , { | TheBrowse | TheBrowse:PageDown() } , ;
- K_PGUP , { | TheBrowse | TheBrowse:PageUp() } , ;
- K_CTRL_PGUP , { | TheBrowse | TheBrowse:GoTop() } , ;
- K_CTRL_PGDN , { | TheBrowse | TheBrowse:GoBottom() } , ;
- K_RIGHT , { | TheBrowse | TheBrowse:Right() } , ;
- K_LEFT , { | TheBrowse | TheBrowse:Left() } , ;
- K_HOME , { | TheBrowse | TheBrowse:Home() } , ;
- K_END , { | TheBrowse | TheBrowse:End() } , ;
- K_CTRL_LEFT , { | TheBrowse | TheBrowse:PanLeft() } , ;
- K_CTRL_RIGHT , { | TheBrowse | TheBrowse:PanRight() } , ;
- K_CTRL_HOME , { | TheBrowse | TheBrowse:PanHome() } , ;
- K_CTRL_END , { | TheBrowse | TheBrowse:PanEnd() } ;
- }
-
- ThePointer := AScan(TheKeyList, TheKey)
- IF ThePointer != 0
- Eval(TheKeyList[++ThePointer], TheBrowse)
- ENDIF
-
- RETURN ThePointer != 0
-