Syntax error unexpected token else

New Here ,
Feb 02, 2022 Feb 02, 2022

Copy link to clipboard

Copied

Hello

 

My apologies I am a beginner with expressions. I can't figure out why I am getting an error for this line:

 

if(comp("Final comp").layer("Control layer").effect("Glitches on/off")("ADBE Checkbox Control-0001")==1) 50 else 0;

 

Any insight would be much appreciated.

TOPICS
Expressions

Views

85

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

LATEST

Conditional statements require curly brackets:

 

if (condition)

{do A}

else

{do B}

 

The sloppy syntax you are using is only supported by the legacy expression engine, but since it's deprtecated and one day will simply disappear you better learn how to do things correctly from the outset. It's also good practice to funnel references to controls into their own variables before using them in the code:

 

mGlitch=comp("Final comp").layer("Control layer").effect("Glitches on/off")("ADBE Checkbox Control-0001");

 

if (mGlitch == 1)

{50}

else

{0}

 

Mylenium

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines