You can run any script file from the Lumerical script prompt simply by typing the name of the file (without the .lsf extension). For example, if you create the file create_array.lsf, you can run this file from the command prompt, or from within another script file, with the command
create_array;
The current working directory is always in the Lumerical script path, and is the most common location for your script files. You can add additional locations to the path with the addpath script function.
Script file names
It is generally not recommended to create script files that have the same name as the standard script functions. In such cases, where there is a conflict between a script file and standard script function, the script file will run. In other words, this allows you to override the behavior of a standard script function. This can be helpful, but it can also lead to very confusing behavior when done unintentionally.
Common variable work space
All script files use a common variable space. As a consequence, variables defined in the scripts are global, and the script files have access to and act on the same variables in the workspace. This can lead to problems when two script files use the same variable names. In the example below, script_1 sets the variable i=1, then runs script_2. Finally it prints the value of i. The final value of i will be 10 rather than 1, since script_2 modified the value of i. To avoid this issue and to make your code more modular, use the function command instead.
script_1.lsf:
i=1; script_2; ?i;
script_2.lsf:
for(i=1:10) { # do something }
See also