Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

ID: 15813, Using case structure with strings

by William Egge Email: Anonymous

Allows you to use a case structure with strings, kind of.
Download Details
FTP  download also available
CDN Login Required to Download. (You will be redirected to the login page if you click on the Download Link)
To download this, you must have registered:
A free membership

For Delphi, Version 2.0  to 5.0 546 downloads
Copyright: No significant restrictions

Size: 357 bytes
Updated on Thu, 05 Apr 2001 14:27:18 GMT
Originally uploaded on Thu, 05 Apr 2001 14:25:45 GMT
SHA1 Hash: B01BFE6B8E33AF079C660FDC500FE4412E9EBFF4
MD5 Hash: A3E62274E3038A70855DF608E9C7B0AB

    Explore the files in this upload

This is really simple, but nobody does it and I have seen people ask how to use a case structure for strings. My solution to the problem was making a StringIndex function that returned to index of a string in an array then use that index in the case structure.

Usage looks this:

case StringIndex('Edit', ['Post', 'Edit', 'Cancel']) of
0: ; // Do somthing for Post "command"
1: ; // Do somthing for Edit "command"
2: ; // Do somthing for Cancel "command"

if StringIndex('Edit', ['a', 'ab', 'rth']) = -1 then
// something
// something

StringIndex returns -1 if the string does not exist. This function is not case sensitive.

The first parameter would be some variable.

   Latest Comments  View All Add New

Move mouse over comment to see the full text

Could not retrieve comments. Please try again later.

Server Response from: ETNACDC03