Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Unexpected Identifier” Expression Error?

  • “Unexpected Identifier” Expression Error?

    Posted by Christopher Bly on December 4, 2019 at 3:44 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 < 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));

    Christopher Bly replied 6 years, 5 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy