473,748 Members | 2,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4715
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******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.co.uk>
Oct 27 '06 #3
In article <zC************ **@eminent.demo n.co.uk>,
pe******@eminen t.demon.co.uk.n ot.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******@eminen t.demon.co.uk.n ot.this.bit.no. html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.dem on.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($some char, 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**********@ch arter.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************ **********@f16g 2000cwb.googleg roups.com>,
nc@iname.com says...
>
You can do:

if (in_array($some char, 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
1628
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
4540
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 'Save as Incomplete' button is Clicked the form will be going to the "SaveAsincomplete.asp" without validation of the fields. And when the 'save as complete' is clicked certain fileds are to be validated and by the function return value, if false...
2
9801
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 in a link. that function can have parameters for URL and window name passed to it. This works peachy in Firefox (1.0). With IE 6 (6.0.29) on two separate computers, I get an "onject expected" error. Going to the MS-based debugger just tells me...
10
2617
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 of that software. That subject seems not to be addressed, at least not directly, in the C FAQ where FAQ 5.2 seems most relevant. References: * C FAQ 5.2 Null pointers (Including conditions where "casting" of null pointer...
2
1559
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 immediate window it return this. Anywhere where I attempt to use two apostrophes, it inserts a backslash. Even a function in one method that saves its string to a file shows that the
3
8427
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
11201
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 to dock a winform on a winform? Thanks Torben
0
256
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
4893
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 "C:\Windows\system32\md5lib.dll" Alias "MD5" (ByVal pwd As String) As String I put the md5lib.dll file in C:\Windows\system32\md5lib.dll. On a simple form to test it with I entered this under the click event of a button:
0
8826
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9534
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9241
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8239
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6793
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6073
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4597
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4867
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.