Copy link to clipboard
Copied
Hello,
I'm trying to create a custom panel for PPro. I know this is an After Effects Discussion, but my question seems relatively simple
and this forum is more active.
The script looks for a JSON file in the same location that the project file is saved in using extendscript. It then opens up that JSON file and
returns the data structure to a JS function. Everything works fine, besides the return line in JSX which returns 'undefined'
I've tried the following
return data
return JSON.stringify(data)
encodeURIComponent(JSON.stringify(data)) // I saw this in some examples of PPro Panels
There also seems to be a way to pass info back and forth with XML files, but I cannot figure out how to do that and
have failed to find good example code to follow.
// JSX Script
#include json2.jsx
readlyricsJSON: function() {
try {
file = filePath(app.project.path) + '\\\\lyrics.json';
data = jsonLoad(file);
}
catch(e) {
data = 'Place Lyrics Here :)'
};
return encodeURIComponent(JSON.stringify(data));
}
}
function jsonLoad(jsonFile) {
var file = new File(jsonFile);
var currentLine;
var data = [];
file.open('r');
while (!file.eof) {
currentLine = file.readln();
data.push(currentLine);
};
file.close();
data = data.join('');
return JSON.parse(data);
};
// JS Script
function readLyrics() {
cs = new CSInterface;
data = cs.evalScript('$.readLyricFile.readlyricsJSON()'); // undefiened
data = JSON.parse(data); // undefined
};
I appreciate any help. Thank You
1 Correct answer
cs.evalScript
does not return a value.
If I remember correctly it needs a callback like this:
cs.evalScript('$.readLyricFile.readlyricsJSON()', function(result){
alert("the jsx script returned the value"+result);
});
Copy link to clipboard
Copied
cs.evalScript
does not return a value.
If I remember correctly it needs a callback like this:
cs.evalScript('$.readLyricFile.readlyricsJSON()', function(result){
alert("the jsx script returned the value"+result);
});

