• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

2.2K

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
LEGEND ,
Feb 03, 2022 Feb 03, 2022

Copy link to clipboard

Copied

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

Votes

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
New Here ,
Feb 10, 2024 Feb 10, 2024

Copy link to clipboard

Copied

LATEST

Thank you for the info, but why the patronizing tone? Why can't you just point out the correct syntax? The one in the original post can be found all around the web in examples, how should one supposed to know that it's "sloppy" whatever that means.


In C# for example, which is a high level language, you can write conditional assigments like this:
result = control == 1 ? 50 : 0;
Is the tenary conditional operator also sloppy?
This is the attitude why people prefer chatgpt over these forums, be it stackoverflow or similar technical platforms. Nobody needs the patronizing, finger-waging, superiority-complex driven lectures. All the some actual information can be presented without any of this nonsense, as chatgpt demonstrates it. 


Votes

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