IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: pistol350 on July 22, 2007, 04:36:40 AM

Title: IF Else Statement
Post by: pistol350 on July 22, 2007, 04:36:40 AM
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
Title: Re: IF Else Statement
Post by: sapero on July 22, 2007, 05:09:47 AM
If you don't use brackets, remove the semicolon before 'else'
if (1 == 1) blah() else if (1 == 2) blah() else
Title: Re: IF Else Statement
Post by: pistol350 on July 22, 2007, 11:56:18 AM
Yes!
I remember that i noticed something similar in the user guide.
Thank you Sap ! Your help is much appreciated!
Cheers!
Peter