TfxLocate Component (c) 1997 by Chuck Gadd. All rights reserved. You are granted permission to use this component in any program royalty-free. You may not charge any fee for distributing this component. Use of this component is at your own risk. I do not make any warranty regarding this component, but it's based on code I've used for quite a while. (Ok, so I'm not good at lawyer-talk ) I make no promises regarding Updates/bug fixes, but if you find any bugs or have any feature suggestions, please let me know. My email address is cgadd@cyber-fx.com Feel free to drop me an email just to say 'I like it!'. If you hate it, don't bother telling me. Description: ----------------------------------------------------------------- LOCATEs data in a TTable or TQuery component (and their descendants like the Infopower TwwTable component ). Currently only searches on String and Blob/Memo fields. Will search up to 1048576 chars of a Blob/Memo field. (Does anyone know the stated limits of a dBase/Paradox blob/memo?) Starting with Version 0.90, it will automatically find and use an index if one is available for the field being searched for. What's New in v0.9x: ----------------------------------------------------------------- Index Optimization : Will examine all available indexes, and use one if it matches. This will greatly improve speed. See "Optimizing" below for more info. Progress tracking : You can now specify an event to trigger every N records. This will let you display progress to your users. Adjustable Memo/Blob Buffer size : Was hard-coded to 32767, now you can set it anywhere from 1 to 1048576. Installation: --------------------------------------------------------------- for Delphi 1, from the main menu choose: Options|Install Components|Add for Delphi 2 and Delphi 3 choose: Component |Install|Add then browse to find the Dir where you unzipped this components files. It will be installed onto the Samples page. ATTENTION!!!!!!!!!!!!!!! Before installing ANY components, you should make a safe copy of your Delphi Library files (or in the case of D3, the Package files). If it gets mangled, you're hosed!!!! I haven't had any problems with this component trashing my VCL, but why take chances??? Properties: --------------------------------------------------------------- UseIndexes : If True, the component will check the available index files, and attempt to optimzie the Locate or LocateNext Commands. See section 'Optimizing' below for more info. If False, no Optimization will be attempted. ProgressCount : The OnProgress event will be triggered after every N records. This allows you to show a status or progress information to your users. If this is set to 0, the OnProgress event will not be called. MaxMemoSize : Specifies the size of the buffer to be used for searching memo/blob fields. If the memo is greater than the size specified here, only the part that fits in this buffer will be searched. The default is 32767, with a max of 1048576. This memory is only allocated while a search on a memo/blob field is active. Datasource : The datasource component to search Datafield : The name of the String or Blob field to search FindText : The string value you want to find. MatchType : maAnywhere : finds text anywhere in the field maFull : field must match text exactly maBeginning : text must match beginning of field IgnoreCase : If true, the search will be case insensitive DisableControls : If True, disables all attached components during search. Greatly increases speed, but it looks cool to leave controls enabled during the search. ;^) FindCursor : The cursor that will be displayed during the search. FailPos : Where to leave the record pointer if no match is found: fpOriginal : Position record pointer to starting record fpEnding : Leave record pointer at the last record checked fpBottom : Leave pointer at bottom of table fpTop : Leave pointer at top of table DoBackground : Determines whether the component releases time for other windows processing to occur during the search. Recommended while searching very large tables. NumRecs : Number of records to examine. If zero, searchs until EOF. RUNTIME/READONLY PROPERTIES: ----------------------------- Found : True if Locate/LocateNext was successful. Error : Error condition (if any) that caused the Locate to fail erNone : No error, data just not found. erDataset : Dataset not set, or not Active. erField : Field not correct type, or not present. erUnknown : I have no idea! Optimized : True if an index was used to optimize the Locate/ LocateNext. If this returns false, OptError will indicate the reason it was not Optimized. OptError : Error condition that caused Optimized to be false. erOptNone : No error (Possibly UseIndex set to false) erNoInd : No index was found for the field erMatchType : "Anywhere" matches can not be optimized erCaseSens : The IgnoreCase setting did not match the case sensitive flag of the index. erNotTable : Only TTable datasets can be optimized. erNotReady : The DataSource is not set, or is not Active. Methods: ------------------------------------------------------------- Locate : Performs a locate from the Top of the Dataset. LocateNext : Performs a locate from the NEXT record. TestOptimized : Determines if the next Locate/LocateNext will be Optimized, based on current settings. Events: ------------------------------------------------------------- OnFind : Called when the data was successfully found. OnFail : Called when the data was NOT found. OnProgress : Called every N records, where N is determined by the ProgressCount property. Optimizing: ------------------------------------------------------------- If the Field you are Locating has an active index, TfxLocate can find the index, and use it to optimize the Locate/LocateNext commands. There are several limitations: 1) An index on the field must exist. If the index is based on multiple fields, the field you are Locating must be first. dBase "Expression" indexes will not be used. 2) If the IgnoreCase property is True, then the index must also be "Case Insensitive". 3) MatchType must be maFull or maBeginning 4) Searches on Memo/Blob fields can not be optimized. 4) The DataSet must be a TTable or Descendant. There is a new Method, TestOptimize that will test the parameters, and determine if the Locate/LocateNext will be optimized. After a Locate/LocateNext or TestOptimize, you can check the Optimized property to determine if it was optimized. If it was not, you can check the OptError to determine the reason it was not optimized. If it was not optimized, check the OptError property to determine why. For an example of using these new features, check out the included Demo app. TfxLocate Source Code: ---------------------------------------------------------- Currently, source code is NOT available. Sometime soon, source will be made available for a low "registration fee". Email me if you wish to be notified when the source is available. The component itself will continue to be free for unrestricted use (Except as stated in the first paragraph).