Board index » delphi » How to get indexed fileds in a secondary index file at run time

How to get indexed fileds in a secondary index file at run time

I am developing a program that needs to create and modify tables at run
time.
So far I can create the tables and datasources. I also created a property
editor for the tables.
I created a form  similar to the File Link Designer to set the Master
Fields.
When I double Click the MasterFields in my Table Property editor It will
show the File Link Designer showing
the MasterSource Fields and the Available Indexes.

Now I want to know how to get the Indexed fields when I click in the Index
name ComboBox

I tried using   GetDetailLinkFields(MasterField,DetailField); but does not
show the fields.

Thanks.

Alberto

 

Re:How to get indexed fileds in a secondary index file at run time


Quote
>Now I want to know how to get the Indexed fields when I click in the Index
>name ComboBox

Assuming you are using Paradox or dbase tables you need to examine the Ttables
IndexDefs and look at the Fields property of each IndexDef
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:How to get indexed fileds in a secondary index file at run time


Yes so far using dbf or db. I did what you suggested but it reurn 0 to the
for loop
Ok here what I do.

I get the Table index name using GetIndexName as follows:

with Form1.FindComponent(tmpName) as TTable do
  begin
  dbIndexName.Clear;
   MyString:=TStringList.Create;
            GetIndexNames(MyString);
            dbIndexName.Items:=MyString;
            MyString.Free;
end;

Now clicking any index field in dbIndexName Combobox and using IndexDefs

with Form1.FindComponent(dbTName.Text) as TTable do
  begin
   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
   for I := 0 to IndexDefs.Count - 1 do
   ListBox3.Items.Add(IndexDefs.Items[I].Fields);
  end;

This will fill the ListBox3 with the IndexNames and not with the fields
assigned to the Indexed file.

When I click in any of the indexName, I want to be able to get the index
field for instance

If I have a Table Name Clients and have foru indexes for it like
Name,Number, PhoneNumber
the Field for Name =CustName
The field for Number=custNumber and
The Field for PhoneNumber=PNumber

I want that when I click Name index it tells me that the field use for index
= CustName.

Thanks for your support. If yoy ar not clear let me know.

Alberto,

"Brian Bushay TeamB" <BBus...@Nmpls.com> wrote in message
news:kj7tgu04hsgpvffp88q33o5iovbhvjrfgr@4ax.com...

Quote

> >Now I want to know how to get the Indexed fields when I click in the
Index
> >name ComboBox

> Assuming you are using Paradox or dbase tables you need to examine the
Ttables
> IndexDefs and look at the Fields property of each IndexDef
> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Re:How to get indexed fileds in a secondary index file at run time


It sounds like you are tring to list the fields that comprise the
index in the listbox. If so, you need something like this (not
tested).

with Form1.FindComponent(dbTName.Text) as TTable do
  begin
   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
   for I := 0 to IndexDefs.Count - 1 do
    if IndexDefs[I].Name = IndexName then
    begin
      FldNames := TStringList.Create;
      try
        FldNames.Delimiter := ';';
        FldNames.DelimitedText := IndexDefs[I].Fields;
        ListBox3.Items := FldNames;
      finally
        FldNames.Free;
      end; //try
  end;

On Tue, 18 Jun 2002 15:32:47 -0400, "Alberto" <chap...@bellsouth.net>
wrote:

Quote
>with Form1.FindComponent(dbTName.Text) as TTable do
>  begin
>   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
>   for I := 0 to IndexDefs.Count - 1 do
>   ListBox3.Items.Add(IndexDefs.Items[I].Fields);
>  end;

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:How to get indexed fileds in a secondary index file at run time


Quote
>Yes so far using dbf or db. I did what you suggested but it reurn 0 to the
>for loop

use IndexDefs.Update before you try to extract information out of the Indexdefs

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:How to get indexed fileds in a secondary index file at run time


Thansk Master!!!
I followed You but using

FldNames.Delimiter := ';';
FldNames.DelimitedText := IndexDefs[I].Fields;

generate the following error

undeclared identifier Delimiter
undeclared identifier DelimitedText

I checked the TStringList Properties and I don't see this properties.

If I remove the above lines and use

ListBox3.ItemsAdd( IndexDefs[I].Fields); it works except for index that have
more than one Field

But the best thing about  all of this is that I am getting why I'm trying to
do.

Alberto

Quote
"Bill Todd" <b...@notthis.dbginc.com> wrote in message

news:7i7vguscq65vgfu3luje8qsoidjb0bfbnk@4ax.com...
Quote
> It sounds like you are tring to list the fields that comprise the
> index in the listbox. If so, you need something like this (not
> tested).

> with Form1.FindComponent(dbTName.Text) as TTable do
>   begin
>    IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
>    for I := 0 to IndexDefs.Count - 1 do
>     if IndexDefs[I].Name = IndexName then
>     begin
>       FldNames := TStringList.Create;
>       try
>         FldNames.Delimiter := ';';
>         FldNames.DelimitedText := IndexDefs[I].Fields;
>         ListBox3.Items := FldNames;
>       finally
>         FldNames.Free;
>       end; file://try
>   end;

> On Tue, 18 Jun 2002 15:32:47 -0400, "Alberto" <chap...@bellsouth.net>
> wrote:

> >with Form1.FindComponent(dbTName.Text) as TTable do
> >  begin
> >   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
> >   for I := 0 to IndexDefs.Count - 1 do
> >   ListBox3.Items.Add(IndexDefs.Items[I].Fields);
> >  end;

> --
> Bill (TeamB)
> (TeamB cannot respond to questions received via email)

Re:How to get indexed fileds in a secondary index file at run time


See the properties for TStringList in the Delphi 6 on-line help. Both
Delimiter and DelimitedText are listed and they work for me. Make sure
the Classes unit is in your uses clause.

On Tue, 18 Jun 2002 22:41:32 -0400, "Alberto" <chap...@bellsouth.net>
wrote:

Quote
>Thansk Master!!!
>I followed You but using

>FldNames.Delimiter := ';';
>FldNames.DelimitedText := IndexDefs[I].Fields;

>generate the following error

>undeclared identifier Delimiter
>undeclared identifier DelimitedText

>I checked the TStringList Properties and I don't see this properties.

>If I remove the above lines and use

>ListBox3.ItemsAdd( IndexDefs[I].Fields); it works except for index that have
>more than one Field

>But the best thing about  all of this is that I am getting why I'm trying to
>do.

>Alberto

>"Bill Todd" <b...@notthis.dbginc.com> wrote in message
>news:7i7vguscq65vgfu3luje8qsoidjb0bfbnk@4ax.com...
>> It sounds like you are tring to list the fields that comprise the
>> index in the listbox. If so, you need something like this (not
>> tested).

>> with Form1.FindComponent(dbTName.Text) as TTable do
>>   begin
>>    IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
>>    for I := 0 to IndexDefs.Count - 1 do
>>     if IndexDefs[I].Name = IndexName then
>>     begin
>>       FldNames := TStringList.Create;
>>       try
>>         FldNames.Delimiter := ';';
>>         FldNames.DelimitedText := IndexDefs[I].Fields;
>>         ListBox3.Items := FldNames;
>>       finally
>>         FldNames.Free;
>>       end; file://try
>>   end;

>> On Tue, 18 Jun 2002 15:32:47 -0400, "Alberto" <chap...@bellsouth.net>
>> wrote:

>> >with Form1.FindComponent(dbTName.Text) as TTable do
>> >  begin
>> >   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
>> >   for I := 0 to IndexDefs.Count - 1 do
>> >   ListBox3.Items.Add(IndexDefs.Items[I].Fields);
>> >  end;

>> --
>> Bill (TeamB)
>> (TeamB cannot respond to questions received via email)

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:How to get indexed fileds in a secondary index file at run time


Maybe they are not in Delphi 5 which is the one I am using.

Is there any way to upgrade The TStringList classes in D5?

Thanks again.

Alberto

Quote
"Bill Todd" <b...@notthis.dbginc.com> wrote in message

news:7731hu047emc523ae4tck3f31gnsmk3dci@4ax.com...
Quote
> See the properties for TStringList in the Delphi 6 on-line help. Both
> Delimiter and DelimitedText are listed and they work for me. Make sure
> the Classes unit is in your uses clause.

> On Tue, 18 Jun 2002 22:41:32 -0400, "Alberto" <chap...@bellsouth.net>
> wrote:

> >Thansk Master!!!
> >I followed You but using

> >FldNames.Delimiter := ';';
> >FldNames.DelimitedText := IndexDefs[I].Fields;

> >generate the following error

> >undeclared identifier Delimiter
> >undeclared identifier DelimitedText

> >I checked the TStringList Properties and I don't see this properties.

> >If I remove the above lines and use

> >ListBox3.ItemsAdd( IndexDefs[I].Fields); it works except for index that
have
> >more than one Field

> >But the best thing about  all of this is that I am getting why I'm trying
to
> >do.

> >Alberto

> >"Bill Todd" <b...@notthis.dbginc.com> wrote in message
> >news:7i7vguscq65vgfu3luje8qsoidjb0bfbnk@4ax.com...
> >> It sounds like you are tring to list the fields that comprise the
> >> index in the listbox. If so, you need something like this (not
> >> tested).

> >> with Form1.FindComponent(dbTName.Text) as TTable do
> >>   begin
> >>    IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
> >>    for I := 0 to IndexDefs.Count - 1 do
> >>     if IndexDefs[I].Name = IndexName then
> >>     begin
> >>       FldNames := TStringList.Create;
> >>       try
> >>         FldNames.Delimiter := ';';
> >>         FldNames.DelimitedText := IndexDefs[I].Fields;
> >>         ListBox3.Items := FldNames;
> >>       finally
> >>         FldNames.Free;
> >>       end; file://try
> >>   end;

> >> On Tue, 18 Jun 2002 15:32:47 -0400, "Alberto" <chap...@bellsouth.net>
> >> wrote:

> >> >with Form1.FindComponent(dbTName.Text) as TTable do
> >> >  begin
> >> >   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
> >> >   for I := 0 to IndexDefs.Count - 1 do
> >> >   ListBox3.Items.Add(IndexDefs.Items[I].Fields);
> >> >  end;

> >> --
> >> Bill (TeamB)
> >> (TeamB cannot respond to questions received via email)

> --
> Bill (TeamB)
> (TeamB cannot respond to questions received via email)

Re:How to get indexed fileds in a secondary index file at run time


For future reference, if you are not using the current version of
Delphi it helps if you let us know which version you are using. There
is no way to update the TStringList  functionality in D5 unless you
want to try to make the changes yourself.

To solve your problem scan the string and replace all semicolons with
commas then use the CommaText property of TStringList to parse the
string.

On Wed, 19 Jun 2002 20:36:00 -0400, "Alberto" <chap...@bellsouth.net>
wrote:

Quote
>Maybe they are not in Delphi 5 which is the one I am using.

>Is there any way to upgrade The TStringList classes in D5?

>Thanks again.

>Alberto

>"Bill Todd" <b...@notthis.dbginc.com> wrote in message
>news:7731hu047emc523ae4tck3f31gnsmk3dci@4ax.com...
>> See the properties for TStringList in the Delphi 6 on-line help. Both
>> Delimiter and DelimitedText are listed and they work for me. Make sure
>> the Classes unit is in your uses clause.

>> On Tue, 18 Jun 2002 22:41:32 -0400, "Alberto" <chap...@bellsouth.net>
>> wrote:

>> >Thansk Master!!!
>> >I followed You but using

>> >FldNames.Delimiter := ';';
>> >FldNames.DelimitedText := IndexDefs[I].Fields;

>> >generate the following error

>> >undeclared identifier Delimiter
>> >undeclared identifier DelimitedText

>> >I checked the TStringList Properties and I don't see this properties.

>> >If I remove the above lines and use

>> >ListBox3.ItemsAdd( IndexDefs[I].Fields); it works except for index that
>have
>> >more than one Field

>> >But the best thing about  all of this is that I am getting why I'm trying
>to
>> >do.

>> >Alberto

>> >"Bill Todd" <b...@notthis.dbginc.com> wrote in message
>> >news:7i7vguscq65vgfu3luje8qsoidjb0bfbnk@4ax.com...
>> >> It sounds like you are tring to list the fields that comprise the
>> >> index in the listbox. If so, you need something like this (not
>> >> tested).

>> >> with Form1.FindComponent(dbTName.Text) as TTable do
>> >>   begin
>> >>    IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
>> >>    for I := 0 to IndexDefs.Count - 1 do
>> >>     if IndexDefs[I].Name = IndexName then
>> >>     begin
>> >>       FldNames := TStringList.Create;
>> >>       try
>> >>         FldNames.Delimiter := ';';
>> >>         FldNames.DelimitedText := IndexDefs[I].Fields;
>> >>         ListBox3.Items := FldNames;
>> >>       finally
>> >>         FldNames.Free;
>> >>       end; file://try
>> >>   end;

>> >> On Tue, 18 Jun 2002 15:32:47 -0400, "Alberto" <chap...@bellsouth.net>
>> >> wrote:

>> >> >with Form1.FindComponent(dbTName.Text) as TTable do
>> >> >  begin
>> >> >   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
>> >> >   for I := 0 to IndexDefs.Count - 1 do
>> >> >   ListBox3.Items.Add(IndexDefs.Items[I].Fields);
>> >> >  end;

>> >> --
>> >> Bill (TeamB)
>> >> (TeamB cannot respond to questions received via email)

>> --
>> Bill (TeamB)
>> (TeamB cannot respond to questions received via email)

--
Bill (TeamB)
(TeamB cannot respond to questions received via email)

Re:How to get indexed fileds in a secondary index file at run time


Ok Bill I will,

Now going back to de fields dilemma digging in in IndexDefs I encounter the
FiledExpression property
which return the filed name and work just fine.

I just change the FldNames:TStringList to FldNames:String

here is the code

with Form1.FindComponent(dbTName.Text) as TTable do
  begin
   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
   for I := 0 to IndexDefs.Count - 1 do
    if IndexDefs[I].Name = IndexName then
    begin
      try
        Fldnames:=IndexDefs[I].FieldExpression;
        DetailField.Items.Add(FldNames);
       finally
      end; file://file://try
  end;
end;

Thanks for your join actions.

Alberto

Quote
"Bill Todd" <b...@notthis.dbginc.com> wrote in message

news:h8b2huc1inftgmedui6thgi372dlp3mrgm@4ax.com...
Quote
> For future reference, if you are not using the current version of
> Delphi it helps if you let us know which version you are using. There
> is no way to update the TStringList  functionality in D5 unless you
> want to try to make the changes yourself.

> To solve your problem scan the string and replace all semicolons with
> commas then use the CommaText property of TStringList to parse the
> string.

> On Wed, 19 Jun 2002 20:36:00 -0400, "Alberto" <chap...@bellsouth.net>
> wrote:

> >Maybe they are not in Delphi 5 which is the one I am using.

> >Is there any way to upgrade The TStringList classes in D5?

> >Thanks again.

> >Alberto

> >"Bill Todd" <b...@notthis.dbginc.com> wrote in message
> >news:7731hu047emc523ae4tck3f31gnsmk3dci@4ax.com...
> >> See the properties for TStringList in the Delphi 6 on-line help. Both
> >> Delimiter and DelimitedText are listed and they work for me. Make sure
> >> the Classes unit is in your uses clause.

> >> On Tue, 18 Jun 2002 22:41:32 -0400, "Alberto" <chap...@bellsouth.net>
> >> wrote:

> >> >Thansk Master!!!
> >> >I followed You but using

> >> >FldNames.Delimiter := ';';
> >> >FldNames.DelimitedText := IndexDefs[I].Fields;

> >> >generate the following error

> >> >undeclared identifier Delimiter
> >> >undeclared identifier DelimitedText

> >> >I checked the TStringList Properties and I don't see this properties.

> >> >If I remove the above lines and use

> >> >ListBox3.ItemsAdd( IndexDefs[I].Fields); it works except for index
that
> >have
> >> >more than one Field

> >> >But the best thing about  all of this is that I am getting why I'm
trying
> >to
> >> >do.

> >> >Alberto

> >> >"Bill Todd" <b...@notthis.dbginc.com> wrote in message
> >> >news:7i7vguscq65vgfu3luje8qsoidjb0bfbnk@4ax.com...
> >> >> It sounds like you are tring to list the fields that comprise the
> >> >> index in the listbox. If so, you need something like this (not
> >> >> tested).

> >> >> with Form1.FindComponent(dbTName.Text) as TTable do
> >> >>   begin
> >> >>    IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
> >> >>    for I := 0 to IndexDefs.Count - 1 do
> >> >>     if IndexDefs[I].Name = IndexName then
> >> >>     begin
> >> >>       FldNames := TStringList.Create;
> >> >>       try
> >> >>         FldNames.Delimiter := ';';
> >> >>         FldNames.DelimitedText := IndexDefs[I].Fields;
> >> >>         ListBox3.Items := FldNames;
> >> >>       finally
> >> >>         FldNames.Free;
> >> >>       end; file://try
> >> >>   end;

> >> >> On Tue, 18 Jun 2002 15:32:47 -0400, "Alberto"

<chap...@bellsouth.net>

- Show quoted text -

Quote
> >> >> wrote:

> >> >> >with Form1.FindComponent(dbTName.Text) as TTable do
> >> >> >  begin
> >> >> >   IndexName:=dbMasterIndex.Items[dbMasterIndex.ItemIndex];
> >> >> >   for I := 0 to IndexDefs.Count - 1 do
> >> >> >   ListBox3.Items.Add(IndexDefs.Items[I].Fields);
> >> >> >  end;

> >> >> --
> >> >> Bill (TeamB)
> >> >> (TeamB cannot respond to questions received via email)

> >> --
> >> Bill (TeamB)
> >> (TeamB cannot respond to questions received via email)

> --
> Bill (TeamB)
> (TeamB cannot respond to questions received via email)

Other Threads