473,387 Members | 1,637 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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 4680
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tom | last post by:
delphi 7 python 2.3 win98 Python for Delphi V3.25 In Delphi: 1 Create a new Form ; 2 Drop a TMemo(Memo1) to contain python code; 3 Drop a TPythonInputOutput (PythonInputOutput1) ;
3
by: Varun | last post by:
Hi There, I have a form("myRequest.asp") and the values from it are retrieved into the page ("output_Print.asp") on which I have two buttons('Save As Complete' and 'Save As Incomplete'). When the...
2
by: Chuck Martin | last post by:
I am having a most frustrating problem that references, web searches, and other resources are no help so far in solving. Basically, I'm trying to design a pop-up window to be called with a funciton...
10
by: LaEisem | last post by:
On-the-job, I have "inherited" a lot of old C language software. A question or two about when "casting" of null pointer constants is needed has occurred during behind-the-scenes cleanup of some...
2
by: Johann Blake | last post by:
I posted a related problem today. The problem is this: string str1 = @""""; When I execute this code (even in a bare bones application), in the IDE it returns "\""" Why? Even in the...
3
by: mrzt | last post by:
the following codes won't work. ============================== using System; using System.Runtime; using System.Runtime.InteropServices; namespace Shutdown { /// <summary> /// Class1...
3
by: Torben Laursen | last post by:
Hi Is there a component in c# like the Frame in Delphi. I'm looking for a way to handle a large number of component in one winform and a frame style component could do the trick. Or is possible...
0
by: Sonnich | last post by:
Hi Is the such a function like IN in delphi: if( $somechar in ) dsafsakjldg; where true is for the characters mentioned above. BR
3
by: TD | last post by:
I found a freeware dll, md5lib.dll, on the web and am trying to use it in Acess 2003. I entered this in a module in the database: Public Declare Function StringMD5 Lib...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.