Entering Interpreter Mode

interpreter_mode(clearQueueOnEnter = True, clearOnEnd = True)

This is a blocking function that puts the controller in interpreter mode.

This function can only be called in the main thread, and nested interpreter modes are not supported. This means that one can’t send an interpreter_mode() call to the interpreter socket.

Parameters

clearQueueOnEnter: If True queued statements will be cleared before interpreter mode is started.

It is possible to send statements to the interpreter socket before interpreter mode is run. These are put into a queue, which by default is cleared when interpreter_mode() is called. However, setting the clearQueueOnEnter argument to False will cause interpreter mode to start executing the statements already in the queue when entering interpreter mode.

clearOnEnd: If True interpreted statements will be cleared when end_interpreter() is called.

Interpreted statements become part of the running program in the scope from which interpreter_mode() was called, but are by default removed from the program again when end_interpreter() is called. However, when entering interpreter mode it is possible to choose to have a persistent behavior by calling interpreter_mode(clearOnEnd = False). The interpreted statements will in that case be a part of the program until the end of program execution, thus they can be called/accessed in subsequent calls to interpreter_mode().

Example statement:

  • interpreter_mode()
    • Starts interpreter mode with default behavior.
  • interpreter_mode(clearQueueOnEnter = False)
    • Starts interpreter mode by interpreting and executing the statements already in the interpreter queue.

Important: It is the programmers responsibility to implement the synchronization necessary to ensure that the program is in the wanted interpreter mode, and that it is ready to receive the statements. It is insufficient to detect if interpreter mode is running, as multiple interpreter mode can exist in the same program.