 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Stark Guest
|
Posted: Tue Nov 11, 2003 5:17 pm Post subject: How to make a routine general |
|
|
I am trying to make more "common" a few routines that I use pervasively in
my application and in so doing, I am transferring them from their original
module to my DataModule.; I found it impossible when the routine is using a
visual component as a parameter, since that component is unknown to the
DataModule. For instance:
procedure GetChecked (aChkListBox: TCheckListBox; aListChecked:
TStringList);
begin
.....
end;
I can use the above proc in different forms, all of them using different a
CheckListBox, that I can pas as a parameter to the proc as following:
.... GetChecked(FormAdd, AddChkList, ListChecked);
or
.... GetChecked(FormMod, ModChkList, ListChecked);
Is there a workaround to do what I had in mind ? What if I wanted to move
the routine to a unit of its own (with no form) ?
|
|
| Back to top |
|
 |
Maarten Wiltink Guest
|
Posted: Tue Nov 11, 2003 5:45 pm Post subject: Re: How to make a routine general |
|
|
"Stark" <starkwedder (AT) virgilio (DOT) it> wrote
| Quote: | I am trying to make more "common" a few routines that I use
pervasively in my application and in so doing, I am transferring
them from their original module to my DataModule.; I found it
impossible when the routine is using a visual component as a
parameter, since that component is unknown to the DataModule.
For instance:
procedure GetChecked (aChkListBox: TCheckListBox; aListChecked:
TStringList);
begin
.....
end;
|
Funny, lots of people do this and have no problems.
You say that "that component" is unknown to the datamodule, but
that's not the problem. It's known to the procedure; after all,
it's being passed in as a parameter.
What the datamodule should know about is its _type_. Types are
declared in units. Units can be Uses'ed.
Groetjes,
Maarten Wiltink
|
|
| Back to top |
|
 |
A man Guest
|
Posted: Tue Nov 11, 2003 6:09 pm Post subject: Re: How to make a routine general |
|
|
In article <sQ8sb.8483$hV.358242 (AT) news2 (DOT) tin.it>,
[email]starkwedder (AT) virgilio (DOT) it[/email] says...
| Quote: | I am trying to make more "common" a few routines that I use pervasively in
my application and in so doing, I am transferring them from their original
module to my DataModule.; I found it impossible when the routine is using a
visual component as a parameter, since that component is unknown to the
DataModule. For instance:
procedure GetChecked (aChkListBox: TCheckListBox; aListChecked:
TStringList);
begin
.....
end;
I can use the above proc in different forms, all of them using different a
CheckListBox, that I can pas as a parameter to the proc as following:
... GetChecked(FormAdd, AddChkList, ListChecked);
or
... GetChecked(FormMod, ModChkList, ListChecked);
Is there a workaround to do what I had in mind ? What if I wanted to move
the routine to a unit of its own (with no form) ?
|
Put the correct unit names in the unit's USES statement. I always put
the Windows unit first, because some things break if it is not first.
unit DataModule;
Uses Windows, Controls, Strings, Sysutils, etc.
interface
implementation
blah blah blah
--
"Tis better to be thought a fool than to open your mouth and remove
all doubt."
"Someone once said that your anger and hatred toward another person
is like you drinking poison and hoping the other person will die."
|
|
| Back to top |
|
 |
Stark Guest
|
Posted: Wed Nov 12, 2003 1:43 pm Post subject: Re: How to make a routine general |
|
|
True, i did'nt try, but I rapidly checked: the TCheckListUnit needs a
different unti than that of a normal ListBox (stdctrls) which it's not
included in the uses list. That must be the problem. Sorry, I lost hope too
early ...
Thanks anyway.
"Stark" <starkwedder (AT) virgilio (DOT) it> ha scritto nel messaggio
news:sQ8sb.8483$hV.358242 (AT) news2 (DOT) tin.it...
| Quote: | I am trying to make more "common" a few routines that I use pervasively
in
my application and in so doing, I am transferring them from their original
module to my DataModule.; I found it impossible when the routine is using
a
visual component as a parameter, since that component is unknown to the
DataModule. For instance:
procedure GetChecked (aChkListBox: TCheckListBox; aListChecked:
TStringList);
begin
.....
end;
I can use the above proc in different forms, all of them using different a
CheckListBox, that I can pas as a parameter to the proc as following:
... GetChecked(FormAdd, AddChkList, ListChecked);
or
... GetChecked(FormMod, ModChkList, ListChecked);
Is there a workaround to do what I had in mind ? What if I wanted to move
the routine to a unit of its own (with no form) ?
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|