Skip to main content
scottm29310603
Inspiring
April 30, 2019
Answered

file.open

  • April 30, 2019
  • 3 replies
  • 1238 views

Hi,

 

So I have my CEP Html panel working, but discovered in my work place some who install my plugin it goes into a different Library folder.

 

This works fine if I trigger the jsx file in AE

 

var thisFile = new File($.fileName);

          var basePath = thisFile.path;

          var file = new File(basePath + "/test.jsx");

          file.open("r");

          eval(file.read());

          file.close();

 

However if I do it via the CEP Panel

 

main.js

var csInterface = new CSInterface;

var button = window.document.getElementById('btna');

button.onclick = function (){

    csInterface.evalScript("myBtnone()");

      }

 

MainScript.jsx

function myBtnone(){

          var thisFile = new File($.fileName);

          var basePath = thisFile.path;

          var file = new File(basePath + "/test.jsx");

          file.open("r");

          eval(file.read());

          file.close();

}

 

it doesn't like it.

 

I've tried alerting and I get undefined or a number, which doesn't help narrow it down.

 

Any suggestions would be much appreciated.

This topic has been closed for replies.
Correct answer scottm29310603

So if anyone is having the same problem I discovered this and played around with it
Wrong syntax again

in your

main.js

var button = window.document.getElementById('btna');

button.onclick = function (){

  var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/scripts/test.jsx";

  csInterface.evalScript("myBtnone('" + extensionRoot + "')")

}

Then in


MainScript.jsx

function myBtnone(extensionRoot){

pathOK = extensionRoot;

var file = new File(extensionRoot);

file.open("r");

eval(file.read());

file.close();

}

you can tidy this to shave a few lines if you have a few jsx scripts that are opened on button clicks, but this works exactly how I want it to.

So unless someone has a tidier or better way I'm classifying this as a win after 24 hours of brain hurt.

3 replies

January 16, 2020
Order support

--
Jackson Chung
PECourtejoie
Community Expert
Community Expert
January 16, 2020

Moved to Exchange.

scottm29310603
scottm29310603AuthorCorrect answer
Inspiring
May 1, 2019

So if anyone is having the same problem I discovered this and played around with it
Wrong syntax again

in your

main.js

var button = window.document.getElementById('btna');

button.onclick = function (){

  var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/scripts/test.jsx";

  csInterface.evalScript("myBtnone('" + extensionRoot + "')")

}

Then in


MainScript.jsx

function myBtnone(extensionRoot){

pathOK = extensionRoot;

var file = new File(extensionRoot);

file.open("r");

eval(file.read());

file.close();

}

you can tidy this to shave a few lines if you have a few jsx scripts that are opened on button clicks, but this works exactly how I want it to.

So unless someone has a tidier or better way I'm classifying this as a win after 24 hours of brain hurt.

Ten A
Community Expert
Community Expert
May 7, 2019

Extension Builder 3 already discontinued and this forum is also inactive.

However, You can join the below forum to get more help about CEP Extensions.

Extensions / Add-ons Development.