Skip to main content
qassim648
Participant
January 19, 2019
Answered

expression was working correctly before the update

  • January 19, 2019
  • 2 replies
  • 769 views

I have the following expression which was working correctly before the update..

option = thisComp.layer("Settings").effect("Invert Animation")("Pseudo/gd6e335d31yLD-0001");

if(option == 0){value}

if(option == 1){value*-1}

could anyone please help me with the correction.

thanks

This topic has been closed for replies.
Correct answer Rick Gerard

Try cleaning up the if statement:

if(option == 0) {value} else - value

or you could just open up the Project Settings and change the expression engine to Legacy Extended Script. Simplifying the if statement is a better way to go. The cleaned up if statement will work just fine with the Legacy engine and  - value will give you the same result as  value * - 1

2 replies

P.M.B
Legend
January 20, 2019

I've heard the scripting engine was updated in the latest version to require strict (or stricter) syntax.  So scripts that are written with some "shorthand" will no longer work.  That's why you needed to explicitly add the "else" to the script whereas before it worked with the shorthand.

~Gutterfish
Rick GerardCommunity ExpertCorrect answer
Community Expert
January 19, 2019

Try cleaning up the if statement:

if(option == 0) {value} else - value

or you could just open up the Project Settings and change the expression engine to Legacy Extended Script. Simplifying the if statement is a better way to go. The cleaned up if statement will work just fine with the Legacy engine and  - value will give you the same result as  value * - 1

qassim648
qassim648Author
Participant
January 19, 2019

thank you very much

Actually, I have solved the issue as per the formula you have posted in the other topic.

if(option == 0){value} else if(option == 1){value*-1}

it works fine..

but the better way as you mention by changing the project setting which will save a lot of time especially if it is a template.

.again thank you for your valuable information..

regards,

Dan Ebberts
Community Expert
Community Expert
January 20, 2019

You shouldn't end your expression with an else if, you should just use else. Otherwise if option is ever anything other than 0 or 1 the expression will break because no result will be generated.

Dan