How to call a .js script in another .js script?

hi, I have written several .js scripts to execute different explorations in AB analysis window.

Now I would like to create another .js script where I would call those .js scripts that I have created.

I have tried to do it by using tips from the net but I get compilation errors.

I appreciate your help,

Regards

@Malierta, I prefer to use a DOS batch file to call multiple scripts in sequence:

For example:

C:
CD "C:\Program Files (x86)\AmiBroker\Scripts"
call Update_Europe.js
call Update_America.js
call Update_Asia.js

If you want to run a jscript file (or any other executable file) from another jscript you could use a syntax similar to the following one:

filename = "C:\\Program Files (x86)\\AmiBroker\\Scripts\\listCustomFormulas.js";
shell = WScript.CreateObject("WScript.Shell");
// the called custom script in this example requires no parameters 
// shell.Run has 3 parameters: command (required), windowtype (optional), wait (optional)
shell.Run("\"" + filename + "\"", 1, true); // 1 = SW_SHOWNORMAL = 1 , True = Wait (default is False - no wait)

filename = "C:\\Program Files (x86)\\AmiBroker\\Scripts\\popupMsg.js";
// the called custom script in this example requires 3 parameters (message, title, timeout)
// note how to pass strings (incuding the command with the full path) that contains spaces
shell.Run("\"" + filename + "\"" + " " + "\"Custom message with spaces....\"" +  " \"A popup window\"" + " " + "10") ;

I hope this will help.

4 Likes

Why not just put them in 1 .js script. they would run consecutively. I personally do that with 8 individual scripts that I put into 1 master script.

This is not really AFL programming topic. Answers can be found on StackOverflow: