[DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Nick
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 =

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Sean Cross
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

[DUG] Installing new compoents (D2007)

2007-05-09 Thread Robert martin
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

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Paul Heinz
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

Re: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Nick
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

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Leigh Wanstead
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

Re: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Nick
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?

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Conor Boyd
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,

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Myles Penlington
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:

Re: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Nick
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

Re: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Neven MacEwan
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,

Re: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Nick
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

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Myles Penlington
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

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Tim Jarvis
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

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread John Bird
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

Re: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Jeremy North
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

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Conor Boyd
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

RE: [DUG] Why use a set when a string will work OK (and less code)?

2007-05-09 Thread Sean Cross
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/

Re: [DUG] Installing new compoents (D2007)

2007-05-09 Thread Robert martin
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.

[DUG] Object Inspector

2007-05-09 Thread Neven MacEwan
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

RE: [DUG] Object Inspector

2007-05-09 Thread Jeremy Coulter
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

RE: [DUG] Object Inspector

2007-05-09 Thread Judd, Struan \(eCargo\)
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,