473,395 Members | 1,677 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,395 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 4682
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.