home *** CD-ROM | disk | FTP | other *** search
- DBrowse UNIT for TurboPower Software OPRO/BTREE users
-
-
- Version 1.02 released on 11 December 1992
-
- Written by a guy named Rob Rosenberger (who?)
- Barn Owl Software
- P.O. Box 1115
- O'Fallon, IL 62269-1115
- CompuServe 74017,1344
-
-
-
- REQUIREMENTS:
-
- Borland BP7 or TP7
- TurboPower BTREE 5.4x
- TurboPower OPRO 1.xx
-
- TurboPower Software
- P.O. Box 49009
- Colorado Springs, CO 80949-9009
- 719-260-6641
- Compuserve 76004,2611
-
-
-
- INTRODUCTION:
-
- TurboPower Software's FBROWSE unit combines the functionality of their BTREE
- Filer toolkit with their OPRO object-oriented toolkit. FBrowser, the primary
- object descendent of the FBROWSE unit, provides immense power for command-
- window based ISAM databases. FBrowser provides a virtual CharHook() routine
- so you can "roll your own" incremental-key function, but FBrowser doesn't
- itself implement one for you.
-
- DBROWSE offers a descendent object called DataDefBrowser for overriding the
- FBrowser CharHook() method. In effect, this object provides a transparent
- incremental key capability for your users.
-
- Most people can implement an incremental key function in five easy steps:
-
- 1. By default, DataDefBrowser descends from the VBrowser object. If you
- use FBrowser objects instead, you must disable the {$DEFINE VBROWSER}
- directive near the top of the DBROWSE.PAS file.
- 2. Include DBROWSE in your USES statement right after FBROWSE.
- 3. Change your objects so they descend from DataDefBrowser rather than
- FBrowser. (BP7 users would do well to learn how the new "inherited"
- reserved word can make life easier when they change ancestors!)
- 4. Include one more variable when you call the InitCustom() constructor.
- 5. Recompile your program.
-
- Ta da! You now have an incremtal key function.
-
- When you call your object's Process() method, each character you type (known
- specifically as a ccChar keystroke in OPRO terminology) winds up in a string
- for incremental key searching. The DataDefBrowser object immediately searches
- for the closest matching key compared to this string and sets the highlight
- bar on it if found. If it finds no potential match, it throws out the user's
- keystroke and calls the RingBell() method to alert the user.
-
- If the user makes a typing mistake, he/she can press the backspace key to
- erase the last keystroke.
-
- By default, DataDefBrowser uses header index #0, the first wFrame.AddHeader()
- command you issue, to display the incremental key string. You can make it use
- a different header index by issuing the following commands:
-
- MyDBrowser.wFrame.AddHeader(...);
- MyDBrowser.dbrHdrIndex := MyDBrowser.wFrame.GetLastHeaderIndex;
-
- You can disable header updates by setting dbrHdrIndex to a value of 255 or by
- simply not adding any headers to the frame.
-
-
-
- TYPES:
-
- KeySeriesSet = SET OF 1..MaxNrOfKeys;
-
- A set of all possible keys available in an FBrowser-derived object.
- The MaxNrOfKeys constant appears in the BTREE FILER unit. NOTE: the
- TurboPower folks set MaxNrOfKeys to 100 by default but allow values
- as high as 254. (Caution: earlier BTREE versions let you go as high
- as 750. DBROWSE cannot cope with more than 255 keys, but this won't
- affect many of you out there.)
-
-
- DataDefBrowserPtr = ^DataDefBrowser;
-
- A pointer to a DataDefBrowser object.
-
-
- DataDefBrowser
- {$IFDEF VBROWSER}
- = OBJECT(VBrowser)
- {$ELSE}
- = OBJECT(FBrowser)
- {$ENDIF}
-
- A DataDefBrowser object. It descends from the VBrowser or FBrowser
- object depending on the state of the {$DEFINE VBROWSER} directive near
- the top of the DBROWSE.PAS file.
-
-
-
- METHODS:
-
- CONSTRUCTOR InitCustom(X1 : BYTE;
- Y1 : BYTE;
- X2 : BYTE;
- Y2 : BYTE;
- VAR Colors : ColorSet;
- Options : LONGINT;
- IFBPtr : IsamFileBlockPtr;
- KeyNum : INTEGER;
- VAR DatS;
- MaxRows : BYTE;
- RowsPerItem : BYTE;
- MaxCols : WORD;
- MaxIncLen : BYTE;
- IncrKeys : KeySeriesSet);
-
- Initializes a DataDefBrowser object. The first 12 items correspond
- exactly to the FBrowser/VBrowser.InitCustom() constructor.
-
- MaxIncLen dictates the maximum length of an incremental key in the
- DataDefBrowser object. Many people use the Filer constant MaxKeyLen
- for the length of all text-based keys, but in some cases (like mine)
- you'll need shorter keys. This controls the length of an incremental
- key string so it doesn't exceed the actual size of the key.
-
- IncrKeys comprises a set of keys where incremental key searching can
- take place. For example, I use six keys in my database but three of
- them sort on numbers, not text. I pass along [1,2,5] as my IncrKeys
- since key fields #1, #2, and #5 sort on actual text.
-
- Sample calling syntax:
-
- IF MyDBrowser.InitCustom(....
- .... {same as FBrowser.InitCustom}
- ....
- MaxKeyLen,
- [1,2,5])
- THEN {everything went okay}
- ELSE {failed to init the object}
-
-
- PROCEDURE Process; VIRTUAL;
-
- Works exactly like the FBrowser/VBrowser.Process() method, but it does
- some essential things for the DataDefBrowser object.
-
-
- PROCEDURE SetCurrentRecordAndPos(Key : IsamKeyStr;
- Ref : LONGINT;
- ItemPos : BYTE);
-
- Similar to the FBrowser/VBrowser.SetCurrentRecord() function, but it
- positions the current record (and the highlight bar) at ItemPos. The
- DataDefBrowser.CharHook() method calls on it to constantly position
- the highlight bar in the center of the window. NOTE: ItemPos has no
- effect if the selected Key/Ref record already appears on the screen.
-
-
-
- TECHNICAL NOTES:
-
- DBrowse's unit initialization code modifies the FBrowserCommands object so it
- recognizes the backspace key as a ccChar command. This lets DBrowse intercept
- it via the CharHook() method so the user can correct any typing mistakes. If
- you Load() FBrowserCommands from disk (like I do) or use an alternate command
- processor, you must issue an appropriate call to AddCommand() to change the
- backspace to a ccChar. Look near the bottom of the DBROWSE.PAS file for hints
- on how I do it.
-
- FBrowse's MaxNrOfKeys constant controls the absolute maximum number of keys
- you can assign to any one data file. TurboPower arbitrarily sets it to 100 to
- accomodate most BTREE users. (You can set it as high as 254 keys if needed.)
- I personally recompiled it with MaxNrOfKeys set to 10 in order to reclaim a
- few hundred bytes of memory in my programs.
-
- The DataDefBrowser object contains a BYTE variable called MaxIncKeyLen so it
- knows when to stop accepting keystrokes for an incremental key string. The
- InitCustom() method sets it appropriately. In my case all text-based keys
- work out to the same length, so I never have to worry about MaxIncKeyLen. If
- you use different-length keys, you'll have to implement a method to change the
- value in MaxIncKeyLen. I recommend you go into FBROWSE.PAS and make a single
- change to the FBrowser object. Namely, make SetKeyNumber() a VIRTUAL method
- so you can override it with the following descendent method:
-
- PROCEDURE YourDescendentDBrowse.SetKeyNumber(KeyNum : INTEGER);
- BEGIN
- DataDefBrowser.SetKeyNumber(KeyNum);
- CASE KeyNum OF
- 1 : MaxIncKeyLen := 20;
- 2 : MaxIncKeyLen := MaxKeyLen;
- 5 : MaxIncKeyLen := 15
- END {CASE}
- END;
-
- Who knows, perhaps TurboPower will take my advice and make it a virtual method
- in a future version. <grin>
-