BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to make a routine general

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc
View previous topic :: View next topic  
Author Message
Stark
Guest





PostPosted: Tue Nov 11, 2003 5:17 pm    Post subject: How to make a routine general Reply with 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
Maarten Wiltink
Guest





PostPosted: Tue Nov 11, 2003 5:45 pm    Post subject: Re: How to make a routine general Reply with quote



"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





PostPosted: Tue Nov 11, 2003 6:09 pm    Post subject: Re: How to make a routine general Reply with quote



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





PostPosted: Wed Nov 12, 2003 1:43 pm    Post subject: Re: How to make a routine general Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.misc All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.