The relevant action can be used to emulate batch code.
The output view reports the execution result.
The emulator is exposed to the SDK:
from Pkg.SimpleBatchEmulator import * script = r''' set foo="hello" echo %foo% ''' emu = SimpleBatchEmulator(script) emu.run()
The output of the code is:
echo: "hello"
The emulator allows single-step execution:
from Pkg.SimpleBatchEmulator import * script = r''' set foo="hello" echo %foo% ''' emu = SimpleBatchEmulator(script) while emu.step(): print("line:", emu.getCurrentLine(), "- variables:", emu.getVariables())
The output of the code is:
line: 1 - variables: {} line: 2 - variables: {'foo': '"hello"'} echo: "hello" line: 3 - variables: {'foo': '"hello"'}
The “getCurrentLine” method returns the number of the line which is going to be executed by the next invocation of “step”. Therefore, the first line of the output reflects the state of the variables after the first line of the batch script, which in this case is an empty line.