• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

help - simple c function if condition

Zaki Ahmed

Well Known Member
I have customized a c function that isn't working.

I have taken last 2 characters of a string, and if the value is not "20", i need to pass a EOL character, otherwise not.

It always goes to ELSE logic and doesn't hit the logic where it gets equal to value of "20". See attachment as well. Not sure what I am doing wrong.

Here's my function.

jdeStrncpy((JCHAR *)szLast2CharString, (JCHAR *)szWorkString+998,2);
szLast2CharString[2] = _J('\0');
if (szLast2CharString == (const JCHAR *) _J("20"))
{
lWrittenByte = jdeFprintfConvert(lpBhvrCom, fOutFile, _J("%ls"), szWorkString);
}
else
{
lWrittenByte = jdeFprintfConvert(lpBhvrCom, fOutFile, _J("%ls\n"), szWorkString);


JDE 9.0
Tools Release 8.98
 

Attachments

craig_welton

Legendary Poster
You need to compare strings using jdestrcmp.

if (jdestrcmp(szLast2CharString, _J("20")) == 0)
{
/* Matches */
}
else
{
/* doesn't match */
}

Craig
 
Top