RunScript

Runs NexScript saved in a file with the specified name.

Syntax

RunScript(scriptName)

Parameters

Parameter

Type

Description

scriptName

string

The name of the script. See Note below for details on how to specify script name parameter

Return

None.

Note

How to specify script names.

When the script name is specified as "MyScript", for example:

RunScript("MyScript")

NeuroExplorer will use the following script file

C:\Users\<USER>\Documents\NeuroExplorer 5\Scripts\MyScript.nsc

(where <USER> is your Windows user name).

You can also specify the script name relative to the main scripts folder

C:\Users\<USER>\Documents\NeuroExplorer 5\Scripts

For example, the script line

RunScript("Grant\MyScript.nsc")

means that the script file

C:\Users\<USER>\Documents\NeuroExplorer 5\Scripts\Grant\MyScript.nsc

will be used.

Finally, you can specify the absolute path of the script file:

RunScript("C:\MyScripts\Script.nsc")

In Python, you can run another Python script by defining a function and using import statement.

For example, if you have a script file MyScript1.py with the following contents:

def MyFunction():
   print('in MyFunction')

then, in another script file (in the same directory) you can call MyFunction using the following code:

from MyScript1 import MyFunction
MyFunction()

You can also run NexScript script from a Python script:

nex.RunScript('AnotherScript')
nex.RunScript('\\Grant\\AnotherScript.nsc')
nex.RunScript(r'C:\MyScripts\Grant\AnotherScript.nsc')

Examples

Python

import nex
# run NexScript
nex.RunScript(r'C:\Data\Scripts\ModifyTemplate.nsc')

NexScript

RunScript("MyOtherScript")