Execute Tasks Across Terminals


Please refer to getCurrentScriptable for more information.


How to Use

Introduction:

In this example, we demonstrate how to use getCurrentScriptable() to obtain the Scriptable instance associated with the current callback function, and then share and operate on it across different terminals. This ensures that the callback always runs in the correct execution context, preventing issues such as inaccessible variables, invalid function references, or unavailable exit codes. It is suitable for multi-terminal collaboration, cross-script debugging, and multi-task data sharing scenarios.

Before Running:

  1. Download and install Total Control 11.0 (Update 20) or later (Download)
  2. Open two terminals:
    • Main Panel → Script → Terminal → Terminal 1
    • Main Panel → Script → Terminal → Terminal 2


Source Code

Terminal 1: Save the current Scriptable and write shared variables

>> _shared.x = getCurrentScriptable()
[ModuleScope FileRepository[C:\Program Files\Sigma-RT\Total Control\]]

>> exit(400)

>> aaa = "Hello"
Hello

>> add = (a,b)=>a+b;

Terminal 2: Retrieve the shared Scriptable and access its context data

>> _shared.x
[ModuleScope FileRepository[C:\Program Files\Sigma-RT\Total Control\]]

>> _shared.x.getExitCode()
400

>> _shared.x.aaa
Hello

>> _shared.x.add(300, 400)
700
700

Execution Result (Terminal 1)

Save the Scriptable instance returned by getCurrentScriptable() to _shared.x

Execution Result (Terminal 2)

Successfully access the same execution context via _shared.x, including:

  • getExitCode() → 400
  • Variable aaa → "Hello"
  • Function add(300, 400) → 700

TCHelp