How to fix error: expected ;

New Here ,
Jul 07, 2022 Jul 07, 2022

Copy link to clipboard

Copied

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

Views

61

Likes

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

Copy link to clipboard

Copied

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;
    }
    }
}

Likes

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

Copy link to clipboard

Copied

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

 

 

Likes

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

Copy link to clipboard

Copied

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?

Likes

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

Copy link to clipboard

Copied

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. 

Likes

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

Copy link to clipboard

Copied

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

"SyntaxError: Unexpected token)

Likes

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

Copy link to clipboard

Copied

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()

 

Likes

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

Copy link to clipboard

Copied

Object.assign({}, obj)

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

 

Mylenium

Likes

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

Copy link to clipboard

Copied

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

Likes

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