Skip to main content
tokuredit
Inspiring
February 26, 2017
Question

How to run an external script from a specific line

  • February 26, 2017
  • 1 reply
  • 863 views

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);

This topic has been closed for replies.

1 reply

Jarda Bereza
Inspiring
February 26, 2017

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.

tokuredit
tokureditAuthor
Inspiring
February 27, 2017

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

Jarda Bereza
Inspiring
February 27, 2017

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.