Board index » delphi » Only the Smartest of the Smart need to reply

Only the Smartest of the Smart need to reply

I want to build an assign statement in real time where the field name is
never known until at run time and written to a TmpFile.  I'm assuming I need
to build and concat the DataModule, TableName and FieldName into a assign
string statement to be executed.  It even possible within Delphi to do
something like this.

Thanks
Pasquale

 

Re:Only the Smartest of the Smart need to reply


Err. Dunno mate

Re:Only the Smartest of the Smart need to reply


So, if I knew the answer, but do not qualify the "Smartest of the
smart", you're not interested? <g>

Jan Derk

Re:Only the Smartest of the Smart need to reply


Your message is not clear. Is the following what you mean?

var
  S:  String;
begin
  S := 'SomeField';
  Table1.FieldByName(S).Assign(Table2.FieldByName(S));

--
Bill
(TeamB cannot answer questions received via email)

Re:Only the Smartest of the Smart need to reply


Quote
"Pasquale DeRenzo" <pdere...@supplussftwr.com> wrote in message

news:3bbe9815_2@dnews...

Quote
> I want to build an assign statement in real time where the field name is
> never known until at run time and written to a TmpFile.  I'm assuming I
need
> to build and concat the DataModule, TableName and FieldName into a assign
> string statement to be executed.  It even possible within Delphi to do
> something like this.

You can create any of these components at run time, and you can assign any
of their properties at run time. You can also create classes knowing only
their type name in string form, e.g. you can create a TTable only knowing
the string 'TTable'. If you have existing components, you can also search
for by them either name or class type.

Now given all that, what exactly are you trying to do? I'm not sure from
your question.

--
Wayne Niddery (Logic Fundamentals, Inc.)
RADBooks: http://www.logicfundamentals.com/RADBooks/delphibooks.html
"Some see private enterprise as a predatory target to be shot, others as a
cow to be milked, but few are those who see it as a sturdy horse pulling the
wagon." - Winston Churchill

Re:Only the Smartest of the Smart need to reply


LOL, all input is really accepted, I'm needing real thought on this process,
I'm at a loss on how to approach it.  Jan, I'm sure you qualify. :-)

--

Quote
"Jan Derk" <jand...@hotmail.com> wrote in message

news:3BBEEB5A.4030000@hotmail.com...
Quote
> So, if I knew the answer, but do not qualify the "Smartest of the
> smart", you're not interested? <g>

> Jan Derk

Re:Only the Smartest of the Smart need to reply


Wow!  It seems I might have been trying to do something the hard way.  My
eyes have been opened to try a few things now.  Thanks again for all who
have responded.

--

"Wayne Niddery [TeamB]" <wnidd...@aci.on.ca> wrote in message
news:3bbf1368$1_2@dnews...

Quote
> "Pasquale DeRenzo" <pdere...@supplussftwr.com> wrote in message
> news:3bbe9815_2@dnews...
> > I want to build an assign statement in real time where the field name is
> > never known until at run time and written to a TmpFile.  I'm assuming I
> need
> > to build and concat the DataModule, TableName and FieldName into a
assign
> > string statement to be executed.  It even possible within Delphi to do
> > something like this.

> You can create any of these components at run time, and you can assign any
> of their properties at run time. You can also create classes knowing only
> their type name in string form, e.g. you can create a TTable only knowing
> the string 'TTable'. If you have existing components, you can also search
> for by them either name or class type.

> Now given all that, what exactly are you trying to do? I'm not sure from
> your question.

> --
> Wayne Niddery (Logic Fundamentals, Inc.)
> RADBooks: http://www.logicfundamentals.com/RADBooks/delphibooks.html
> "Some see private enterprise as a predatory target to be shot, others as a
> cow to be milked, but few are those who see it as a sturdy horse pulling
the
> wagon." - Winston Churchill

Re:Only the Smartest of the Smart need to reply


Bill this seems to work for the field name, but how would you do it if your
assigning a table name to a DataModule# ?
example:
var
  S: String;
  T: String;
  NewData: String;
begin
  NewData := 'This is the Data';
  T:='SomeTable'
  DataModule2.????(T).......FieldByName(S).Assign(Table2.FieldByName(S)) :=
NewData;

--

"Bill Todd (TeamB)" <bill.nos...@dbginc.com> wrote in message
news:3bbf0912$1_2@dnews...

Quote
> Your message is not clear. Is the following what you mean?

> var
>   S:  String;
> begin
>   S := 'SomeField';
>   Table1.FieldByName(S).Assign(Table2.FieldByName(S));

> --
> Bill
> (TeamB cannot answer questions received via email)

Re:Only the Smartest of the Smart need to reply


If you are asking how to change the TableName of a TTable on a data module
then:

DataModule1.Table1.TableName := 'foo.db';

I still do not understand what you are trying to do. If you would explain in
more detail there may be a simple solution.

--
Bill
(TeamB cannot answer questions received via email)

Re:Only the Smartest of the Smart need to reply


Thanks Bill, I think I got it done.  Hopfully this will clearup what I have
been tring to do.
Let me see if I can try to explain it this way.  I'm redesigning an import
process of data maintained in a string(text format), lets call that string
field "sDataElement".  Now I'm updating a Paradox file of users selection
from a ListBox.  This file could change depending on what the user selects.
Lets call that table "tblDestination".   (I dropped a Table and Source on a
DataModule and named it "tblDestination")

I than associated what the user selected to the tblDestination by assigning
the LstBx.FileName to the table.

        DataModule2.tblDestination.TableName := ImpExpSelLstBx.FileName;
        DataModule2.tblDestination.Open;
        DataModule2.tblDestination.Edit;

       {After Data Verification is done}

DataModule2.tblDestination.FieldByName(F).Assign(DataModule2.tblDestination.
FieldByName(F)) := sDataElement;

        DataModule2.tblDestination.Post;

Bill, Thanks again for your help
Pasquale
--

"Bill Todd (TeamB)" <bill.nos...@dbginc.com> wrote in message
news:3bbf6b8e_2@dnews...

Quote
> If you are asking how to change the TableName of a TTable on a data module
> then:

> DataModule1.Table1.TableName := 'foo.db';

> I still do not understand what you are trying to do. If you would explain
in
> more detail there may be a simple solution.

> --
> Bill
> (TeamB cannot answer questions received via email)

Re:Only the Smartest of the Smart need to reply


The following will not work.

DataModule2.tblDestination.FieldByName(F).Assign(DataModule2.tblDestination.
FieldByName(F)) := sDataElement;

What you want is:

DataModule2.tblDestination.FieldByName(F).AsString := sDataElement;

--
Bill
(TeamB cannot answer questions received via email)

Other Threads