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

How to run an external script from a specific line

Contributor ,
Feb 26, 2017 Feb 26, 2017

Copy link to clipboard

Copied

I need to find a way to run an event starting with "line 50" ending with "line 150" of an external script: If this is possible, my purpose is to avoid creating multiple .jsx files for each event. I'll create a "base script" for various events. Could such a feat be possible? Thank you

    var estr = '//@include "~/Desktop/testes/base_script.jsx";\r\n';

    eval(estr);

TOPICS
Actions and scripting

Views

685

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
Adobe
Enthusiast ,
Feb 26, 2017 Feb 26, 2017

Copy link to clipboard

Copied

use something like this:

#include "scripts/something.jsx"

foo();

If foo() is function in something.jsx at the line 50 it will works 😉

foo() should be defined only onetimes.

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
Contributor ,
Feb 26, 2017 Feb 26, 2017

Copy link to clipboard

Copied

Jarda Bereza I confess I did not understand: Can you show me an example with some script? Thank you

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
Enthusiast ,
Feb 27, 2017 Feb 27, 2017

Copy link to clipboard

Copied

LATEST

Example

Main.jsx

#include "scripts/something.jsx" 

foo();  //call function "foo" which on line 5

Something.jsx

function bar(){

    alert("Hello");

}

function foo(){ 

     alert("world");

}

All code in something.jsx should be wraped inside functions. Otherwise it would execute this code.

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