string contains method

nkuebelbeck

nkuebelbeck

VIP Member
i would like the ability to see if a given string contains another string.

string a = abcdefg
string b = cde

if(a.contains(b))
{
//woot string b is in string a
}

obviously you can't write code like that in jde (my example resembles java/C#)

does this exist in JDE?
 
c-code is your friend: jdeStrstr

To return a pointer to the position in the string where a match occurs:

Code:
JCHAR * szFound = NULL;

szFound = [B]jdeStrstr[/B]( szStringToSearch, szStringToFind );

if( szFound )
{
     // szStringToFind in is szStringToSearch
}
 
For string functions like that just look up the ANSI C (C90) equivalent and then put "jde" in front of it. 99% of the time it will work identical to its C90 counterpart. There are a few calls missing and a few more JDE only ones and some work slightly differently (jdeStrcmp for example) than the C90 counterpart, but the difference is usually preferable when coding in JDE. For example jdeStrcmp will ignore trailing blanks which is generally what you want to do and since a lot of the time the strings you work with in JDE have trailing blanks, it saves you a lot of code.
 
For string functions like that just look up the ANSI C (C90) equivalent and then put "jde" in front of it. 99% of the time it will work identical to its C90 counterpart. There are a few calls missing and a few more JDE only ones and some work slightly differently (jdeStrcmp for example) than the C90 counterpart, but the difference is usually preferable when coding in JDE. For example jdeStrcmp will ignore trailing blanks which is generally what you want to do and since a lot of the time the strings you work with in JDE have trailing blanks, it saves you a lot of code.

Good to know, thanks!
 
If you look in E1 table F9862 you get the list of all lovely BSFNs we can use

B0500690 Is String in String is the one your after.
Returns a 1 if szStringToFind (30 long) is found within szFromString (2000 long)

It uses the API listed above
 
If you look in E1 table F9862 you get the list of all lovely BSFNs we can use

B0500690 Is String in String is the one your after.
Returns a 1 if szStringToFind (30 long) is found within szFromString (2000 long)

It uses the API listed above

Already rolled my own, but thanks anywho!
 
Back
Top