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

How to fix error: expected ;

New Here ,
Jul 07, 2022 Jul 07, 2022

Hello! So I have been following this tutorial below to try to make my own ranking system in AE:

 

https://youtu.be/STw_ZIw3uVE 

 

I've followed the tutorial step by step when typing the code but then I came into this issue below which puzzles me since I have already placed the semicolon in that line.

 

7FFF5791-5F1F-4EE1-AEE3-BBCB35D5E052.png


Anyone know what I can do this fix this? Cheers!!

TOPICS
Error or problem , Expressions , How to
2.0K
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 ,
Jul 07, 2022 Jul 07, 2022

Just in case anyone wants to see the entire code, here it is!: 

pi = 0;
dt = effect("RankTransTime ")("Slider");
sTime = Math.floor(time/dt)*dt;
z = [0, 0, 0, 0, 0];
if (time - sTime < 0.1){
    n = effect("n")("Slider");
    if (Math.floor(n/5) >= pi){
        let r = [];
        for (i=1, i <= n; i ++){
            ssTime = thisComp.layer(i).masterProperty("Slider").valueAtTime(sTime);
            if (ssTime == 0) ssTime = (n-1)/1000;
            let obj = {t: ssTime, id: i}
            r[i-1] = Object.assign({}, obj);
        }
    r.sort(function(a,b){return b.t - a.t});
    for (i = 1; i <= 5, i++){
        z[i-1] = r.findIndex(function (a){return a.id == i + (pi*5)}/20;
    }
    }
}
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
Community Expert ,
Jul 07, 2022 Jul 07, 2022

My guess is that you're using the Legacy ExtendScript expression engine instead of the JavaScript engine. Change that in File > Project Settings > Expressions.

 

 

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 ,
Jul 07, 2022 Jul 07, 2022

Oh the codes before did not work until I changed it to the Legacy Extendscript engine before though. Will changing it back affect the previous codes?

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
Community Expert ,
Jul 07, 2022 Jul 07, 2022

Possibly--it depends on the code. There are some differences, so you may have to edit your code to get it to run on one engine or the other. 

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 ,
Jul 07, 2022 Jul 07, 2022

I changed it back to JavaScript and line 1 had the error: 

"SyntaxError: Unexpected token)

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
Community Expert ,
Jul 07, 2022 Jul 07, 2022
LATEST

Hard to say for sure without setting everything up the way the tutorial has it, but I do see several syntax errors in your code.

for (i=1, i <= n; i ++){

should be:

for (i=1; i <= n; i ++){
for (i = 1; i <= 5, i++){

should be:

for (i = 1; i <= 5; i++){

and

z[i-1] = r.findIndex(function (a){return a.id == i + (pi*5)}/20;

should be:

z[i-1] = r.findIndex(function (a){return a.id == i + (pi*5)})/20;

But this code definitely needs the JavaScript engine, because it's using array.sort()

 

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
LEGEND ,
Jul 07, 2022 Jul 07, 2022
Object.assign({}, obj)

It probably should read object.assign. Case-sensitivity matters in JS...

 

Mylenium

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 ,
Jul 07, 2022 Jul 07, 2022

I'll give it a shot but iirc, the error message popped up before I even typed in that line 😕

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