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

Error: Syntax Error: Unexpected token else

New Here ,
Dec 31, 2020 Dec 31, 2020

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
8.1K
Translate
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

Translate
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

Translate
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

Thanks a bunch! that worked!

Translate
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

Happened. Thank you. Everything is working.

Translate
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
LATEST

Happened. Thank you. Everything is working.

Translate
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