 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Kim Hovorka Guest
|
Posted: Tue Dec 16, 2003 5:28 pm Post subject: Passing a component as a var parameter to a function |
|
|
Hello,
Here is something that I was wondering how to do.
I would like to pass a QuickReport Label component to a function
or procedure and have the labels caption property populated inside the function as follows(EXAMPLE below):
returnMONTHDAYYEAR(qrlblODOBMO.Caption, qrlblODOBDAY.Caption,
qrlblODOBYR.Caption, qryHCFAOTHERINSUREDDOB.AsFloat);
procedure TFormHCFAReport.returnMONTHDAYYEAR(var Val1, Val2, Val3 : String; theDATE : TDateTime);
var
Year, Month, Day: Word;
begin
DecodeDate(theDATE, Year, Month, Day);
Val1 := IntToStr(Month);
Val2 := IntToStr(Day);
Val3 := IntToStr(Year);
end;
How could I do this? I have to break up a ton of dates into month,day and year and this is how I would like to do it if possible?
Thanks,
Kim Hovorka
[email]kimhovorka (AT) yahoo (DOT) com[/email]
|
|
| Back to top |
|
 |
Franz-Leo Chomse Guest
|
Posted: Tue Dec 16, 2003 7:22 pm Post subject: Re: Passing a component as a var parameter to a function |
|
|
| Quote: | How could I do this? I have to break up a ton of dates into month,day and year and this is how I would like to do it if possible?
|
You can't: A property has a getter and a setter which have normally
not the same address as in the case of a variable. Additionally the
might
be methods and not plain memory addresses.
Regards from Germany
Franz-Leo
|
|
| Back to top |
|
 |
Harley Pebley Guest
|
Posted: Tue Dec 16, 2003 7:59 pm Post subject: Re: Passing a component as a var parameter to a function |
|
|
| Quote: | Here is something that I was wondering how to do.
I would like to pass a QuickReport Label component to a function
or procedure and have the labels caption property populated inside the function as follows(EXAMPLE below):
returnMONTHDAYYEAR(qrlblODOBMO.Caption, qrlblODOBDAY.Caption,
qrlblODOBYR.Caption, qryHCFAOTHERINSUREDDOB.AsFloat);
procedure TFormHCFAReport.returnMONTHDAYYEAR(var Val1, Val2, Val3 : String; theDATE : TDateTime);
var
Year, Month, Day: Word;
begin
DecodeDate(theDATE, Year, Month, Day);
Val1 := IntToStr(Month);
Val2 := IntToStr(Day);
Val3 := IntToStr(Year);
end;
How could I do this? I have to break up a ton of dates into month,day and year and
this is how I would like to do it if possible?
|
Pass the objects rather than the properties. Like so:
| Quote: | populateMONTHDAYYEAR(qrlblODOBMO, qrlblODOBDAY,
qrlblODOBYR, qryHCFAOTHERINSUREDDOB);
procedure TFormHCFAReport.populateMONTHDAYYEAR(const Val1, Val2, Val3 : TQRLabel; theDATE : TWhateverQueryType);
var
Year, Month, Day: Word;
begin
DecodeDate(theDate.AsFloat, Year, Month, Day);
Val1.Caption := IntToStr(Month);
Val2.Caption := IntToStr(Day);
Val3.Caption := IntToStr(Year);
end;
|
Change the types as appropriate.
HTH,
Harley Pebley
|
|
| Back to top |
|
 |
Tony J Hopkinson Guest
|
Posted: Tue Dec 16, 2003 8:30 pm Post subject: Re: Passing a component as a var parameter to a function |
|
|
On 16 Dec 2003 10:28:56 -0700, "Kim Hovorka" <kimhovorka (AT) yahoo (DOT) com>
wrote:
| Quote: | Hello,
Here is something that I was wondering how to do.
I would like to pass a QuickReport Label component to a function
or procedure and have the labels caption property populated inside the function as follows(EXAMPLE below):
returnMONTHDAYYEAR(qrlblODOBMO.Caption, qrlblODOBDAY.Caption,
qrlblODOBYR.Caption, qryHCFAOTHERINSUREDDOB.AsFloat);
procedure TFormHCFAReport.returnMONTHDAYYEAR(var Val1, Val2, Val3 : String; theDATE : TDateTime);
var
Year, Month, Day: Word;
begin
DecodeDate(theDATE, Year, Month, Day);
Val1 := IntToStr(Month);
Val2 := IntToStr(Day);
Val3 := IntToStr(Year);
end;
How could I do this? I have to break up a ton of dates into month,day and year and this is how I would like to do it if possible?
Thanks,
Kim Hovorka
[email]kimhovorka (AT) yahoo (DOT) com[/email]
|
Nothing to do with var.
Var will pass the address (reference) of a variable, as an object is a
reference already ....
Procedure PopulateWithdate(SomeObject : TsomeObjectwithaCaption; aDate
TDateTime)
someobject.caption := FormatDateTime('dd/mmm/yyyy',aDate)
end ;
Sort of begs the question why don't you set the caption and dump the
function doesn't it.
|
|
| 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
|
|