ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

"Unexpected Identifier" Expression Error?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Christopher Bly
"Unexpected Identifier" Expression Error?
on Dec 4, 2019 at 3:44:38 pm

I've been staring at this code for way too long and can't figure out where I've messed up. Could someone help me out please?

I don't know if you'll need to understand the code to help fix it but here's a quick explanation of what this is meant to be doing: This expression is applied to the sourceText property of a text layer. The text layer then takes the text to display from part of the comp's title and changes its font based on an imported csv file that's full of font names.

The error here is probably something small and silly but I just can't find it. Any help would be appreciated. Thanks!

var bold = false;
var titleSegment = 0;

function compName() {
return thisComp.name.split(/:\s*/)[1].split(/\s*--\s*/);
};

function getFont(b) {
let fontSpreadsheet = thisComp.layer("Fonts Spreadsheet").source;
let fontName = fontSpreadsheet.name.toLowerCase();
let fnt = "HelveticaNeueLTStd-MDCn";
let fontCount = fontSpreadsheet.sourceText.split(/\r\n|\r|\n/).length;
let fontNumber = -1;
for (let i = 0; i &lt; fontCount; i++) {
if (fontSpreadsheet.dataValue([0, i]).toLowerCase() == fontName) {
fontNumber = i;
};
};
if (fontNumber > -1) {
if b = true {
fnt = fontSpreadsheet.dataValue([2, fontNumber]);
} else {
fnt = fontSpreadsheet.dataValue([1, fontNumber]);
};
};
return fnt;
};

text.sourceText.style.setText(compName()[titleSegment]).setFont(getFont(bold));


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]