468,272 Members | 2,025 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,272 developers. It's quick & easy.

Function like "in" in Delphi?

Hi

Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.

BR
S

Oct 27 '06 #1
8 4338
Rik
Sonnich wrote:
Hi

Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.
Well, I have never used Delphi, but when you maken an array, you can
offcourse search with in_array($char,array('a','b','d'));
--
Rik Wasmus
Oct 27 '06 #2
Following on from Sonnich's message. . .
>Hi

Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.

BR
S
Delphi's in is an operation on a set of enumerated values. So strictly
speaking the answer is no.

If you're looking at finding substrings then RTM.
If you're looking at finding an element or a key in an array then RTM
My preferred version of the manual is the Windows compiled help one.


--
PETER FOX Not the same since the deckchair business folded
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Oct 27 '06 #3
In article <zC**************@eminent.demon.co.uk>,
pe******@eminent.demon.co.uk.not.this.bit.no.html says...
Following on from Sonnich's message. . .
Hi

Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.

BR
S

Delphi's in is an operation on a set of enumerated values. So strictly
speaking the answer is no.

If you're looking at finding substrings then RTM.
If you're looking at finding an element or a key in an array then RTM
My preferred version of the manual is the Windows compiled help one.


--
PETER FOX Not the same since the deckchair business folded
pe******@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>
Delphi includes a group of operators that implement an area of
mathematics known as "set theory"

This is a very simple to understand area that I personally wish
was used wider - its probably easy enough for you to implement
some set constructs in whatever language you use yourself.

The other functions do the same job but operating on sets can often make
code very much clearer and hence easier to write/debug/maintain.

Do a google for "set theory" or similar - I expect there's a lot more
there.

Oct 27 '06 #4
Sonnich wrote:
Hi

Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.

BR
S
What is wrong with if(strpos("abd", $somechar) !== FALSE)
Oct 28 '06 #5
NC
Sonnich wrote:
>
Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.
You can do:

if (in_array($somechar, array("a", "b", "d")))

or

if (strpos(' abd', $somechar) 0)

Cheers,
NC

Oct 28 '06 #6

Bob Stearns wrote:
Sonnich wrote:
Hi

Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.

BR
S
What is wrong with if(strpos("abd", $somechar) !== FALSE)'
final comment from me - one of the answers before was what I needed.
I need to test a single char, whether it is a, b or d - this could be
done in an if, but that might get pretty big and complex

S

Oct 30 '06 #7
In article <qz*************@newsfe06.lga>, rs**********@charter.net
says...
Sonnich wrote:
Hi

Is the such a function like IN in delphi:

if( $somechar in ["a", "b", "d"])
dsafsakjldg;

where true is for the characters mentioned above.

BR
S
What is wrong with if(strpos("abd", $somechar) !== FALSE)
I'd say I'd prefer the Delphi set construct myself too - its so much
cleaner in a number of ways - but that does the job of course.
Oct 30 '06 #8
In article <11**********************@f16g2000cwb.googlegroups .com>,
nc@iname.com says...
>
You can do:

if (in_array($somechar, array("a", "b", "d")))

or

if (strpos(' abd', $somechar) 0)

Cheers,
NC

Still overly complex by comparison I think.

In Delphi:

if "x" in ['a'..'z']

quicker to type - prettier on the eye - no question about case
sensitivity needed, easier to understand on first glance ?
Oct 30 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by LaEisem | last post: by
2 posts views Thread by Johann Blake | last post: by
3 posts views Thread by Torben Laursen | last post: by
reply views Thread by Sonnich | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.