Does AFL support 'else if' statement?

User's Guide and web say that AFL supports 'if-else'
https://www.amibroker.com/guide/keyword/if.html

but there seems no AFL document mentions about 'if-else if'
So could I use statement like 'else if' as below inside the for loop?

for (i=0; i< BarCount; i++)
{
   if (cond1) { xxx; }
   else if (cond2) { xxx; }
   else if (cond3) { xxx; }
   else { xxx; }
}

Short answer: yes

Long answer: there is no really separate "else if" statement. It is just two nested if-else statements. Any statement can be nested ad-infinitum, so if - else can be nested infinitely too.

So if you write

for (i=0; i< BarCount; i++)
{
   if (cond1) { xxx; }
   else if (cond2) { xxx; }
   else if (cond3) { xxx; }
   else { xxx; }
}
}

It is actually the same as if you wrote:

for (i=0; i< BarCount; i++)
{
   if (cond1) { xxx; }
   else
   { 
      if (cond2) { xxx; }
      else 
      {
          if (cond3) { xxx; }
            else { xxx; } 
      }
   }
}
3 Likes