Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
function execute() {
  if (context.min === undefined) {
    context.min = parseInt(inPorts[3].value, 10) || 0;
  }

  if (context.max === undefined) {
    context.max = parseInt(inPorts[4].value, 10) || 100;
  }

  if (context.value === undefined) {
    context.value = parseInt(inPorts[2].value, 10) || context.min;
  }

  switch (trigger) {
    case 0:
      if (context.value < context.max && context.value >= context.min) {
        context.value += 1;
        return [context.value];
      }
      // When value is out of scope return maximum
      return [context.max];
    case 1:
      if (context.value > context.min && context.value <= context.max) {
        context.value -= 1;
        return [context.value];
      }
      // When value is out of scope return minimum
      return [context.min];
    case 2:
      if (inPorts[2].value < context.min) {
        context.value = context.min;
      } else if (inPorts[2].value > context.max) {
        context.value = context.max;
      } else {
        context.value = inPorts[2].value;
      }
      editInPort(2, {});
      return [context.value];
    case 3:
      context.min = inPorts[3].value;
      break;
    case 4:
      context.max = inPorts[4].value;
      break;
    default: break;
  }
  return [];
}

...

In Ports

Position

Name

Message Type

Description

1

Increment

Trigger

This port is being used to increment the value of the 'Data Counter' object. The object executes and sends out the value.

2

Decrement

Trigger

This port is being used to decrease the value of the 'Data Counter' object. The object executes and sends out the value.

3

Value

Number

This port is being used to define the value of the 'Data Counter' object. The object executes and sends out the value.

4

Min

Number

This port is being used to define the minimum number of the 'Data Counter' object.

5

Max

Number

This port is being used to define the maximum number of the 'Data Counter' object.

...

Out Ports

Position

Name

Message Type

Description

1

Value

Number

This port is being used to send out the message including the value of the 'Data Counter' object.

...

Properties

Name

Description

Object Name

The name of the object on the canvas.

Show Code View

The switch to turn on code view for the Code Object.

Duplicate code into custom Code Object

Image Modified