Two options spring to mind;
1. Simple.

  if pos('/'+Extension+'/','/wav/mp3/ogg/')>0 then

2. Complex

uses typinfo;
const
  ENUM_NOTFOUND :integer = 1;
type
  eTAudioTypes : (wav,mp3,ogg);

  if getEnumValue(typeinfo(etAudioType),extension) = ENUM_NOTFOUND then   //
getenumvalue returns -1 on not Found

I tend to use the first for simple cases. But if I have a lot of conditional
code and want to use case statements then I use the later.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
Behalf Of Ross Levis
Sent: Wednesday, August 01, 2001 11:42 PM
To: Multiple recipients of list delphi
Subject: [DUG]: Sets of Strings?


A beginners Pascal question here:

Is there a better way of doing this?
If (Extension='.wav' or Extension='.mp3' or Extension='.ogg') then ...

Is there something similar to a Set I can use that would let me write
something like this?
If Extension in AudioFiles then ...

I tried Pos(Extension,AudioFiles)>0 but an extension of '.w' would also
be true.

Another question.  Is it quicker to add many items to a TStringList
unsorted and then Sort it; or set Sorted True & sort each item as it is
added?  Or is there no difference?

Cheers,
Ross.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to