Hi all!
I often have problems with IF ELSE statements.
It is not that i can't fix them.I just want to understand once and for all why i often get synthax error (caused by the use of else ) for this kind of statements :
if (m_baBoundsAction == BA_WRAP)
{
if ((ptNewPosition.x + ptSpriteSize.x) < m_rcBounds.left)
ptNewPosition.x = m_rcBounds.right;
else if (ptNewPosition.x > m_rcBounds.right)
ptNewPosition.x = m_rcBounds.left - ptSpriteSize.x;
if ((ptNewPosition.y + ptSpriteSize.y) < m_rcBounds.top)
ptNewPosition.y = m_rcBounds.bottom;
else if (ptNewPosition.y > m_rcBounds.bottom)
ptNewPosition.y = m_rcBounds.top - ptSpriteSize.y;
}
I don't think the best idea is to use the square brackets with each If condition. ???
Any suggestions please so that i no longer have to ask myself such ... questions ;D
Thanks!
Regards!
Peter
If you don't use brackets, remove the semicolon before 'else'
if (1 == 1) blah() else if (1 == 2) blah() else
Yes!
I remember that i noticed something similar in the user guide.
Thank you Sap ! Your help is much appreciated!
Cheers!
Peter