Navigation:  Macros > Macro Language > Built-in Functions > All Functions (Alphabetical) >


Previous pageReturn to chapter overviewNext page

bool = StrContains(sOne, sTwo, bCaseSensitive)


This macro function compares two strings and returns true if sOne "contains" sTwo, and false otherwise. The inverse function is StrIsContained.


StrContains('A', 'Z', false);       // returns -1

StrContains('AAA', 'aaaa', false); // returns -1

StrContains('AAAB', 'aaaa', false); // returns +1

StrContains('A', 'a', false);       // returns  0

StrContains('Aaaa', 'aaaa', false); // returns  0


The boolean parameter, bCaseSensitive, determines if the comparison is to take note of uppercase and lowercase letters.


StrContains('A', 'Z', true);       // returns -1

StrContains('AAA', 'aaaa', true); // returns +1  <---

StrContains('AAAB', 'aaaa', true); // returns +1

StrContains('A', 'a', true);       // returns +1  <---

StrContains('Aaaa', 'aaaa', true); // returns +1  <---


Note that the functionality of this function can also be reproduced using the Pos and LowerCase functions.


if bCaseSensitive

 bContains = Pos(sTwo,sOne) > 0


 bContains = Pos(LowerCase(sTwo),LowerCase(sOne)) > 0



However, the use of this function has the merit of being shorter to write, and being more explicit as to what is being tested.

Topic 137000 updated on 05-Mar-2002.
Topic URL: