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

Error: Syntax Error: Unexpected token else

New Here ,
Dec 31, 2020 Dec 31, 2020

Copy link to clipboard

Copied

Hello! I'm brand new to Adobe After Effects and just pasted in some code for a timer, but I'm getting a syntax error on line 1. I don't know much about codeing so I was hoping sombody smarter than me might know. Here's the code:

 

rate = 1;
clockStart = 0;
function padZero(n){
if (n < 10) return "0" + n else return "" + n
}
clockTime = clockStart + rate*(time - inPoint);
if (clockTime < 0){
sign = "-";
clockTime = -clockTime;
}else{
sign = "";
}
t = Math.floor(clockTime);
hr = Math.floor(t/3600);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
ms = clockTime.toFixed(3).substr(-3);
sign + padZero(min) + ":" + padZero(sec)

TOPICS
Error or problem , Expressions

Views

7.9K

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

correct answers 1 Correct answer

Community Expert , Dec 31, 2020 Dec 31, 2020

Try replacing this line:

if (n < 10) return "0" + n else return "" + n

with this:

return (n < 10 ? "0" : "") + n

Votes

Translate

Translate
Community Expert ,
Dec 31, 2020 Dec 31, 2020

Copy link to clipboard

Copied

Try replacing this line:

if (n < 10) return "0" + n else return "" + n

with this:

return (n < 10 ? "0" : "") + n

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 ,
Dec 31, 2020 Dec 31, 2020

Copy link to clipboard

Copied

Thanks a bunch! that worked!

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 ,
Aug 31, 2022 Aug 31, 2022

Copy link to clipboard

Copied

Happened. Thank you. Everything is working.

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 ,
Aug 31, 2022 Aug 31, 2022

Copy link to clipboard

Copied

LATEST

Happened. Thank you. Everything is working.

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