Page 1 of 1

Else if?

Posted: Thu Sep 15, 2005 5:58 am
by zchris
I am using Else If in my old setups - the command still works with the new InstallAware.

It is however missing in the commands list ... why?

Posted: Thu Sep 15, 2005 8:35 am
by sinan
There were some very subtle bugs with this command. We didn't have time to fully fix them, so we removed it from the production builds, but as you notice, it is still available for backwards compatibility reasons. We do recommend that you replace all else-if commands in your script with an else and then a new if block.

Re: Else if?

Posted: Wed Mar 06, 2013 6:56 am
by deploy
Seven years later, "else if" is still listed in the help file, but not available as a command in the editor? I am using the latest version.
Is "else if" supposed to work or not?

Using if with multiple else will not work from what I can see. It will indent fine in editor, it will compile fine but not execute more than one else. In the example below the last else will never execute.

Don't know if I am totally blind at the moment, but I had to resolve this with some really ugly code using goto:s everywhere.

Code: Select all

  if Variable ENHET Equals 1
    if Variable isIE10 Equals TRUE
      do stuf
    else
      do stuff
    end
  else
    if Variable ENHET Equals 2
      if Variable isIE10 Equals TRUE
        do stuff
      else
        do stuff
      end
    end
  else
    if Variable isIE10 Equals TRUE
      this will never execute
    else
      nor will this
    end
  end
In my opinion "else if" is a useful command.

Regards,

Re: Else if?

Posted: Wed Mar 06, 2013 10:44 am
by FrancescoT
Dear User,

Unfortunately, "else if" is still not available ... and not because not useful.

Anyway, have you tried doing as?;

Code: Select all

  if Variable ENHET Equals 1
if Variable isIE10 Equals TRUE
   do stuf
else
   do stuff
end
  
if Variable ENHET Equals 2
  if Variable isIE10 Equals TRUE
    do stuff
  else
    do stuff
  end
end
Regards

Re: Else if?

Posted: Thu Mar 07, 2013 5:16 am
by deploy
OK, then I know. Would be nice if "else if" would be reimplemented at some point in the future :)

Your example does not handle the case when ENHET does not equal 1 or 2 (the last else in my example) and since IA does not support logical operators in "If" I saw no other solution than using labels and Goto:s (or using yet another variable).

Anyways, the example really isn't important I mostly wanted to find out the status of "else if" since it was listed in the help file.

Regards,

Re: Else if?

Posted: Thu Mar 07, 2013 8:17 am
by FrancescoT
Dear User,

In reality the "Else If" statement used to exist.
It can still be loaded from scripts that use it (generated with past IA versions). However, it cannot be added to new scripts.

You can also use "Evaluate Expression" command where you can evaluate expressions as;
$A$ = "value1" or ($B$ = "value2" and $C$ = "value3")

Hope his helps you.

Regards