Description

Toggle the enable status of a task.


Syntax

designer.setEnableTask("TASK NAME", ENABLE);

Parameters

Parameter Type Description
TASK NAME String Insert the name of the task
ENABLE Boolean Set to true to enable the task and false to disable the task

Return

This function does not return anything.


Example

Toggle a task enabled/disabled with a Javascript node

Main Code

if(enable){
  if(enable_flag==0){
    designer.setEnableTask("My Task", true);
    enable_flag=1;
  }
  else if(enable_flag==1){
    designer.setEnableTask("My Task", false);
    enable_flag=0;
  }
}

Global

var enable_flag=0;

Note

Input enable is of type float.
The Switch node is not set to Toggle.

Alternate Example

Alternatively, this function can be used in a more concise way making use of the boolean type in javascript.

0 will always evaluate to false and anything other than 0 will always evaluate to true.

This way, anything can be sent as input into the javascript node to toggle the enable/disable state of the Task.

Note however that this will no longer work with boolean spikes such as those sent by other nodes or by a Switch node not set to Toggle.

Another way to toggle a task enabled/disabled with a Javascript node

Main Code

designer.setEnableTask("My Task", enable);

Note

There is no need for a Global section in this example.

Input enable is of type float.
The Switch node is set to Toggle.

Need more help with this?
Don’t hesitate to contact us here.

Thanks for your feedback.