Re: TZF - "Default Directory" & reindexing
Marie Vihonsky <[email protected]>
| Newsgroups | gmane.comp.lang.delphi.topaz |
|---|---|
| Message-ID | <[email protected]> |
Hi Brian,
First, I'm assuming you are using MDX's and not NDX's.
From the TOPAZ Help:
For MDXs: function MakeIndex(tags: PTagInfo; fname: String): Boolean;
Parameters: MDX:tags is a pointer to a list of tags. fname is the index
filename. It is best to leave the second parameter empty. TOPAZ will use
the name of the current database with MDX extension as the default name.
Although you may create and use an index with a different filename than
the name of the current DBF, it is best to stick to production indexes.
With that said, this works: (All I did was place a TtzDbf component,
a Datasource component, a TzGrid & a TzNavigator on a form - using all
defaults in the Object Inspector except for assigning the Datasource to
the grid and navigator. The rest is handled by code.)
unit Main;
interface
uses
SysUtils, Windows, Messages, Classes, Graphics, Controls,
Forms, Dialogs, StdCtrls, Buttons, ExtCtrls, Menus, Grids, aTzGrids,
DBCtrls, aTzNav, Db, tzprimds, ucommon, utzcds, utzfds,
ComCtrls,
tzndx, tzparser, UTzMDS; // added these manually
type
TMainForm = class(TForm)
TzDbf1: TTzDbf;
DataSource1: TDataSource;
TzNavigator1: TTzNavigator;
TzGrid1: TTzGrid;
procedure FormCreate(Sender: TObject);
end;
var
MainForm: TMainForm;
Const
JunkTags: array[0..1] of TTagInfo = (
(name: 'NAME'; keyexpr: 'upper(jlast - jfirst)'; forexpr: '';
descending: FALSE; unique: FALSE),
(name: ''; keyexpr: ''; forexpr: '';
descending: FALSE; unique: FALSE));
implementation
{$R *.DFM}
procedure TMainForm.FormCreate(Sender: TObject);
var pgmpath, tempath : string;
begin {open the major databases}
pgmpath:=ExtractFilePath(Application.ExeName);
tempath := pgmpath + 'tempmdxs\';
{make sure the directory exists}
if not TzDbf1.Active then begin
TzDbf1.DbfFileName := dbfpath + 'junk.dbf';
TzDbf1.Exclusive := true;
TzDbf1.Active := True;
TzDbf1.MakeIndex(@junktags,tempath+'junk.mdx');
TzDbf1.SetIndexTo(tempath+'junk.mdx');
TzDbf1.setordertotag('NAME');
TzDbf1.gotop;
end;
end;
Hope this helps,
Marie
==^================================================================
This email was sent to: [email protected]
EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]
TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
==^================================================================