StrIsContained

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

StrIsContained

Previous pageReturn to chapter overviewNext page

bool = StrIsContained(sOne, sTwo, bCaseSensitive)

 

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

 

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

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

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

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

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

 

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

 

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

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

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

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

StrIsContained('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(sOne,sTwo) > 0

else

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

endif

 

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 137100 updated on 05-Mar-2002.
Topic URL: http://www.qppstudio.net/webhelp/index.html?striscontained.htm