• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

csInterface.evalScript not working correctly

Community Beginner ,
Feb 15, 2018 Feb 15, 2018

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!

Views

922

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , Feb 15, 2018 Feb 15, 2018

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}")`);

Votes

Translate

Translate
Guru ,
Feb 15, 2018 Feb 15, 2018

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}")`);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

LATEST

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines