baloonatic@hotmail.com Guest
|
Posted: Wed Dec 10, 2003 8:48 pm Post subject: Re: Help - reference to global variables ? |
|
|
On 9 Dec 2003 13:59:03 -0800, [email]dunric (AT) centrum (DOT) cz[/email] (Dunric) wrote:
I've a feeling test.myinst would work but I have n't tried as my
fingers would go on strike.
Either of the following changes (or better both) would solve your
problem and make the code much more readable. This sort of practice
makes code maintenance and team developing extremely difficult, and I
would be very unhappy with any member of mine who came up with
something similar.
Consider yourself well smacked on the wrist. !!
| Quote: | (Delphi object pascal - not VCL)
When names of variables or fields conflicts(are the same),
qualifiyng shall distinguish them.
But HOW TO QUALIFY them when they are not in a unit but IN MAIN
PROJECT FILE ?
sample code of Test.dpr:
-------------------------------------------------------
program test;
{$APPTYPE GUI}
uses Windows, Messages;
type
MyRecord = record
myInst: LongWord;
someOther: Boolean;
end;
var
// rename the variable so you can see it's the global one at a glance |
say
globmyinst: longword // no need to quality it now.
| Quote: | myInst: LongWord;
myRec: MyRecord;
...
begin
...
myInst := HInstance;
// damn with statements I hate 'em. so |
myrec.myinst := myinst
//or even less confusing combine the two
myrec.myinst := globmyinst
myrec.somethother := false
| Quote: | with myRec do
begin
myInst := {global_dpr_scope.}myInst; // !!!!!!!!!! how ?
someOther := False;
end;
...
end.
-------------------------------------------------------
Thanks in advance
Pavel
|
|
|