Copy link to clipboard
Copied
Hi guys. I am pretty much stomped on this one. I am sure I'm making a mistake but I can't see it. Maybe more eyes will help.
Here's what is happening:
I get ad alert from LogRead JSX function on startup which is blank. This works just fine. The second time on a triggered event in the main.js it does not alert which means it's not working, nothing happens
Here's the code snippets:
MAIN.JS - ON START UP
csInterface.evalScript('LogRead(\'\',' + logfilepathname + ')');
HOSTSCRIPT.JSX
//save a text file or write new data
function LogRead(newfiledata,filepathname){
//read data
alert(newfiledata);
var vfiledataread = FileDataRead(filepathname);
if(vfiledataread == ""){
//create settings file if not created
FileDataCreate("theme: Default__",filepathname,"w");
};
if(newfiledata > ""){
//write update new data to file
FileDataCreate(newfiledata,filepathname,"e");
};
};
MAIN.JS - ON EVENT TRIGGER
csInterface.evalScript('LogRead(' + newstreamdata + ',' + logfilepathname + ')');
Advice appreciated, thanks!
You look to me like you are majorly messing up your quotes in MAIN.JS
Either use the old style
csInterface.evalScript('LogRead("' + newstreamdata + '", "' + logfilepathname + '")');
Or if working from CC2015 or on some apps even earlier use in the JS file
csInterface.evalScript(`LogRead("${newstreamdata}", "${logfilepathname}")`);
Copy link to clipboard
Copied
You look to me like you are majorly messing up your quotes in MAIN.JS
Either use the old style
csInterface.evalScript('LogRead("' + newstreamdata + '", "' + logfilepathname + '")');
Or if working from CC2015 or on some apps even earlier use in the JS file
csInterface.evalScript(`LogRead("${newstreamdata}", "${logfilepathname}")`);
Copy link to clipboard
Copied
Both didn't work but that was not the problem. I added the text to the variable and found the issue. The string newline in the newstreamdata was causing a problem. It read from a file which had "newlines" (\n) and it didn't work. I remove the newline spaces from the file and it works. My original code works as well.
Thanks for your help, it helped with my stream of thought! Appreciated your help!