Skip to main content

Array

Array is used to store multiple values in a single variable, instead of declaring separate variables for each value.

Example, when we have multiple data with the same data type and we need to store them in our flow, we can store it in different variables but that can make it more complex for us to handle in flow, to simplify the flow we can use array where multiple data with same data type can be stored in one variable and we can also perform different operations such as adding new data and removing the existing data.

Properties

  • An array in Smowcode is represented as [1,2,3,4,5].
  • In an array, data is separated by commas.
  • The datatype of elements in array should be the same.
  • In array every element has an index number, the index number starts from 0 eg. array [1,2,3,4,5] here the index of 1 is zero and index of 2 is one and for 3 it’s two.
  • The number of data elements in an array is known as size of an array eg. For an array [1,2,3,4,5] there are 5 values so its size will be 5.
  • It supports different data types such as int, float, text and many more.

Create Array Node

Create array node is used to create an array.

To use an if condition in your flow:

  • Take a create array node and open its properties.

  • Name the array.

  • In declaration type input we have two feature one “Declare with value” which sets the array size as per the number of elements in an array, and second “Declare with size” where we have to specify the size of an array.

  • In the value input we assign our data for eg. in the below properties we have assigned 9 elements which are separated by comma, and with same data type init32 which is specified in Datatype input.

    Image1

  • Example, here we have created an array name arr , and declaration type as “Declare with value” and we have assigned value as [1,2,3,4,5,6,7,8,9] and data type is int32 and the output variable is named as arr.

  • To display the array elements, we have used a for loop to print the print the array element.

Image2

Array Get Size Node

Image3

Array get size node is used to get the array size.

  • Example, In the below flow we have created an array and we want to know it’s accurate size so we have connected it to array get size node where in properties the array name is given and the array size is displayed using display num node.

Array Append Node

Array append node is used to add a new value in data and it’s added after last element.

Example

Example, we have created an array name length of eight elements [1,2,3,4,5,6,7,8] and we have to append a new element 9 so it will be added after 8 and final array will be [1,2,3,4,5,6,7,8,9].

Image4

Array Insert Node

Image5

Array insert node is used to manipulate with data, we can the change the element of array using index number.

  • Example, there's an array of nine elements [1,2,3,4,5,6,7,8,9] and want to change the value 5 to 0 and it’s index is 4.

Remove Array Node

Image6

Remove array node is used to remove an element of array.

  • Example, we have an array of 10 elements [1,2,3,4,5,6,7,8,9,10]. And we want to remove 1, so will use a remove array node where we have to assign index number of element as an input and array name.