Size Operator: Finding the Size of an Array

Overview

The Size operator can find the number of values in a string, but it can also find the number of elements in an array. This example uses a Size operator to find the number of rows in a Data Table.

Here's how your module looks in the Module Builder:

Here's how the completed use case looks in Express View with a sneak peek at the DevTools Console:

What You'll Learn

In this article, you'll learn how to use a Size operator to find the size of an array.

What You Need

To set up this use case, you need:

  • 1 Data Table component

  • 1 Text Field component

  • 1 Data Workflow component

To set up your Data Workflow, you need:

  • 1 Input operator

  • 1 Size operator

  • 1 Output operator

NOTE  These instructions assume you have a new module open, saved, and with a title.

Configuration

Configure the Data Table Component

First, add your Data Table with a list of dogs, storing their name and age.

1. Drag and drop a Data Table component onto your canvas.
2. Enter dtDogs in the Label and Property Name fields.
3. In the data table, enter the following:

A

B

name

age

Ivy

7

Lucy

10

Wally

1

Nacho

5

Thor

5

Holly

13

4. Click Save.

Configure the Text Field Component

Next, add your Text Field component. This Text Field holds the output from your Data Workflow. So, this Text Field shows the number of rows in your array. Set this Text Field to disable user input.

1. Drag and drop a Text Field component onto your canvas.
2. Enter numberOfRows in the Property ID field.
3. Enter Number of Data Table Rows in the Label Text field.
4. Set the Disable User Input toggle to ON.

5. Click Save.

Configure the Data Workflow Component

Next, add your Data Workflow component, starting with an Input operator to bring data from your table into the Data Workflow. Then, add a Size operator to find the number of rows the table holds. And finally, send the result to your Text Field with an Output operator.

1. Drag and drop a Data Workflow component onto your canvas. Place your Data Workflow below your Text Fields.
2. Enter dwfSize in the Canvas Label Text and Property Name fields.
3. Select Watch from the Trigger Type drop-down.

Configure the Input Operator

This operator references the data in your Data table.

1. Drag and drop an Input operator onto your Data Workflow canvas.
2. Configure the Input operator's Info window as follows:

Setting

Value

Category

Input

Component

dtDogs

Required

Yes

Source

Default

Configure the Size Operator

This operator finds the number of rows in your Data Table.

1. Drag and drop a Size operator onto your Data Workflow canvas.
2. Configure the Size operator's Info window as follows:

Setting

Value

Category

Size

Label

Size of Data Table

3. Connect the output port (right) of the Input operator to the input port (left) of the Size operator.

Configure the Output Operator

This operator sends the Size operator's value to your Text Field.

1. Drag and drop an Output operator onto your Data Workflow canvas.
2. Configure the Output operator's Info window as follows:

Setting

Value

Category

Output

Component

characters

Action

value

3. Connect the output port (right) of the Size operator to the input port (left) of the Output operator.
4. Click Save.
5. Save your module.

Once finished, preview your module in Express View. Your Text Field displays how many rows are in your table. If you go back and adjust the data in your table, the number here reflects that.

Lab

You can view this complete use case here: https://training.unqork.io/#/form/5f6ba3cbabf886024d4e036e/edit.