Why use a set when string work ok? (and I think it's a set)
Question: I have seen this quite a bit and apparently it's good
practice however to me it seems like more work.
Example
Whats the point in doing this
MyStatus = (Active, Pending, Ended, Paused, Deleted, Suspended););
type
Something =
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
Hi
We have bought a new component pack and have installed it ok. However
the docs say to register the help files by using RegHelp2. I cant find
this on my system or any mention of it on the web. The exact wording in
the doc is
Delphi 2007 : Close the IDE, run regHelp2 /I TMSPACKdBds5w
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/
Hi
Found it !
If you are smart and unzip the help files you find the exe in with them !!!
Rob Martin
Software Engineer
phone +64 03 377 0495
fax +64 03 377 0496
web www.chreos.com
Wild Software Ltd
Robert martin wrote:
Hi
We have bought a new component pack and have installed it ok.
Hi
Does anyone use an Object Inspector Component, I'm looking to replace
the Dream one
TIA
Neven
___
NZ Borland Developers Group - Delphi mailing list
Post: delphi@delphi.org.nz
Admin: http://delphi.org.nz/mailman/listinfo/delphi
Unsubscribe: send
I have seen a free one somewhere, maybe on Torrys but TMS has an object
inspector control.and come ot think of it, didn’t TurboPower have one
too? Their controls are on sourceforge now, and I am sure I have seen on in
their controlsnot the Async ones, but one of the others starting with
O
A Quick search of SourceForge reveals Turbopower Orpheus
(http://sourceforge.net/projects/tporpheus/) which includes an Object
Inspector
TTFN, Struan.
Jeremy Coulter wrote:
I have seen a free one somewhere, maybe on Torrys but TMS has an
object inspector control.and come ot think of it,
22 matches
Mail list logo