jackzhf
Subscriber

One of the possible causes:

User-defined functions can be defined within your main script file, or saved in separate files, and must be defined at global scope. If you save the function in a separate file, ensure the script file name is different than the function name. It must also be different than any standard Lumerical script functions.

 

Note that the function “add” needs to be defined in the global scope, and it won’t be recognized if it is defined inside the “add4” function. The following definition of the functions will give an error:

 

function add4(i, j, k, l){  
function add(a, b) {
return a+b;
}  return add(add(i, j), add(k, l));
}
Error: add is not a valid function or variable name

 

https://optics.ansys.com/hc/en-us/articles/360034923573-function-Script-command-Create-your-own-functions