I believe the refactoring engine has problems with with statements.
Which is probably in itself enough of a reason for me to stop using them.
Alister Christie
Computers for People
Ph: 04 471 1849 Fax: 04 471 1266
http://www.salespartner.co.nz
PO Box 13085
Johnsonville
Wellington
Ross
I thought using with with a single argument, not nested, would be a clean
and elegant practice, like:
with stringgrid1 do
begin
cells[5,tcgmax]:=uline;
cells[6,tcgmax]:=uline;
nextstrgrdMaTC;
cells[3,tcgmax]:='Totals';
cells[5,tcgmax]:=inttostr(trntotu);
I tend to do this as well when it is obviously quite safe and saves a lot of
typing. The problem is debugging. The debugger (in D7 anyway) will not
resolve the variables unless they are fully qualified on the line. I have
always found this very annoying. Code Insight resolves everything fine
Interesting stuff...
Is it just me or is anyone else horrified by the with statement abuse in
example function getStructures?
Steve
-Original Message-
From: Sean Cross [mailto:[EMAIL PROTECTED]
Sent: Thursday, 10 May 2007 1:49 p.m.
To: NZ Borland Developers Group - Delphi List
Steve
Please explain? also why you are at it why is the diminutive of Stephen
Steve?
Neven
Interesting stuff...
Is it just me or is anyone else horrified by the with statement abuse in
example function getStructures?
Steve
-Original Message-
From: Sean Cross [mailto:[EMAIL
Is it just me or is anyone else horrified by the with statement abuse in
example function getStructures?
I'm horrified by any use of the with statement.
___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin:
Jeremy
I always though they should enhance the with statement with and as
clause ie
if ( Components[ siCom ] is TAdoDataSet ) then
with ( Components[ siCom ] as tAdoDataSet ) as Dataset do
begin
Dataset.Open;
...
otherwise I do
var DataSet: tAdoDataSet;
if (
Hi Neve :)
I'm not one of the many who don't use the with statement at all, but I only
use it sparingly and never nested 3 levels deep like the example. I usually
end up removing it during debug sessions anyway and kick myself for using it
in the first place.
I think your mate Malcolm Groves
Stephe (Nah doesn't work)
I certainly agree as far as to say this part of the language construct
is broken, but then I hate having to declare
a temp var for no purpose at all but to remove ambiguity in references
N
Hi Neve :)
I'm not one of the many who don't use the with statement at all,
I certainly agree as far as to say this part of the language construct
is broken, but then I hate having to declare
a temp var for no purpose at all but to remove ambiguity in references
I tend to think of it as writing more readable/maintainable code.
Because then you are forever checking status with code like
If Status = 'Active' then ..
Else if Status = 'Pending'...
So you end up using consts. And you still have the problem that your Status
may end up as '' or 'Ative' or 'as323'
And you can't use case statements.
If status is purely
Sean Cross wrote:
TMyStatus = (Active, Pending, Ended, Paused, Deleted,
Suspended); StatusMeanings = array[TMyStatus] of string =
('Active', 'Pending', 'Ended', 'Paused', 'Deleted', 'Suspended'); ...
ShowMessage(StatusMeanings[Status]);
Also, Delphi can do this for you using RTTI - this is
Hi Sean,
Thanks for the reply. Indeed I can see the benefit and use them in other
parts of my program - but for something like status which does get acted
on and displayed I was wondering what was best. You example code below
would solve my initial query - thanks for that!
:-)
Sean Cross
Take advantage compile time checking. Strong typecast check.
Regards
Leigh
http://www.smootharm.com
-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Nick
Sent: Thursday, May 10, 2007 10:49 AM
To: NZ Borland Developers Group - Delphi List
Subject: [DUG] Why
Nice thats even shorter :-)
So following on from this, what happens when you want to do something
like this
TMyStatus = (Active, Pending, Ended, Paused, Deleted, Suspended);
TLogLevel = (Normal,Error,Ended);
This will cause an error as Ended appears twice.
How you can you get around this?
Yes, or if you want more control over your descriptive values, then you
can do something like this:
TGalleryStatus = (gsUnknown, gsSuccess, gsMajVerInvalid,
gsMinorVerInvalid, gsVerFmtInvalid, gsVerMissing, gsPasswordWrong,
gsLoginMissing, gsUnknownCommand,
Nope - Look at the call - uses TypeInfo(TMyStatus), and for the other
case should be TypeInfo(TLogLevel).
M.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Nick
Sent: Thursday, 10 May 2007 11:29
To: NZ Borland Developers Group - Delphi List
Subject:
Indeed, but I mean just doing this
type
TMyStatus = (Active, Pending, Ended, Paused, Deleted, Suspended);
TLogLevel = (Normal,Error,Ended);
(as in, just writing that) wont compile as I get an error 'Identifier
redeclared: Ended'
Myles Penlington wrote:
Nope - Look at the call - uses
Nick
Thats why you use a lower case prefix ie tmsActive, tmsPending, ...
verssu tllNormal, tllError, tllEnded...
HTH
Neven
Nice thats even shorter :-)
So following on from this, what happens when you want to do something
like this
TMyStatus = (Active, Pending, Ended, Paused, Deleted,
aa ;-)
Time for another coffee!
Thanks heaps guys, I have learned a stack!
Neven MacEwan wrote:
Nick
Thats why you use a lower case prefix ie tmsActive, tmsPending, ...
verssu tllNormal, tllError, tllEnded...
HTH
Neven
Nice thats even shorter :-)
So following on from this, what
Or you can put it into another unit, and then when you use it prefix it
with the unit name, which in effect becomes a namespace.
Myles.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Neven MacEwan
Sent: Thursday, 10 May 2007 11:37
To: NZ Borland
Also, enumerated types are ordinal types, this means you can use them in
case statements instead of having to use nested if's (which is what you
would have to do with strings)
Cheers Tim.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Leigh Wanstead
I like this a lot !!!:
TGalleryStatusDescriptions: array
[Low(TGalleryStatus)..High(TGalleryStatus)] of String =
I have been trying to find out where I can use other variables in array
declarations. I hoped I could use previously declared constants, I did not
know I could use a function that
I like this a lot !!!:
TGalleryStatusDescriptions: array
[Low(TGalleryStatus)..High(TGalleryStatus)] of String =
You don't have to do that, you can just do this:
TGalleryStatusDescriptions: array[TGalleryStatus] of String =
Just like for booleans you can do:
BoolStr: array[Boolean] of
Yeah, I remembered that when I saw that Sean had posted almost the same
type of example. ;-)
Thanks,
C.
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On Behalf Of Jeremy North
I like this a lot !!!:
TGalleryStatusDescriptions: array
Q. What is the function to return the enum name?
A. See http://www.techtricks.com/delphi/enumname.php
Regards
Sean Cross
IT Systems Development Manager
Catalyst Risk Management
PO Box 230
50 Dalton St
Napier 4140
DDI: 06-8340362
mobile: 021 270 3466
Visit us at http://www.catalystrisk.co.nz/
26 matches
Mail list logo