Skip to main content
HYPPie
Known Participant
March 22, 2021
Question

Clock Expression giving error

  • March 22, 2021
  • 2 replies
  • 947 views

Hi, I'm trying to use this expression to put the time on a film in AE.
But I get an error in line 5, "else"is unexpected, AE says.
It is a very simple operation and the expression is copy/pasted, all exactly as in this tutorial

https://youtu.be/QeNHHIjgvHU?t=486

I make text 0:00, alt-click on the icon left of Source Text and paste the code.
And then I get an error.
Has something changed in the latest version (I use 18.0.1) or is this a bug, or am I going nuts?

Thank you.
Henri

This topic has been closed for replies.

2 replies

Mathias Moehl
Community Expert
Community Expert
March 22, 2021

If you don't want to write expressions code yourself, my (paid) extension iExpressions also has a very flexible solution for timers and countdowns:

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
HYPPie
HYPPieAuthor
Known Participant
March 22, 2021

The script is called Clock Automation.txt, att. in the first message, sorry

Dan Ebberts
Community Expert
Community Expert
March 22, 2021

Try it this way:

rate = 1;
clockStart = 0;

function padZero(n){
  return (n < 10 ? "0" : "") + n;
}

clockTime = Math.max(clockStart + rate*(time - inPoint),0);

t = Math.floor(clockTime);
min = Math.floor((t%3600)/60);
sec = Math.floor(t%60);
min + ":" + padZero(sec)

 

HYPPie
HYPPieAuthor
Known Participant
March 22, 2021

This works perfectly, thank you!

Any idea why the other script doesn't work for me, I see it work in quite a few tutorials?