Author Topic: IIF statement giving me "expression error";  (Read 2540 times)

GreyArea

  • Guest
IIF statement giving me "expression error";
« on: March 18, 2017, 04:32:22 PM »
It's quite asimple statement, not sure why it's not working;

Set Text [movedir] to '{EXP:IIF({TXT:movedir}='right','left','right')}'

The movedir field can only be left or right...I was hoping this simple statement would invert it; so if it's 'right', it becomes left and if it's anything else (given it can only otherwise be 'left') it becomes 'right'.

What am I doing wrong?

Pfeil

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4780
  • RTFM
Re: IIF statement giving me "expression error";
« Reply #1 on: March 18, 2017, 04:46:37 PM »
The token is replaced by text, and text needs to be enclosed in single quotes:

Code: [Select]
Set Text [movedir] to '{EXP:IIF('{TXT:movedir}'='right','left','right')}'

GreyArea

  • Guest
Re: IIF statement giving me "expression error";
« Reply #2 on: March 18, 2017, 07:06:44 PM »
Genius...thank you.

mikelimtw

  • Jr. Member
  • **
  • Posts: 51
Re: IIF statement giving me "expression error";
« Reply #3 on: March 20, 2017, 08:41:31 AM »
I had the same problem as you early on. When you use the {EXP:} token to evaluate text the text token portion needs to be surrounded by the single quote '