Workspace 6.21.5
|
Workspace operations often require not individual inputs of a particular type, but an unbounded number. For example, to concatenate two strings together, we might create an operation that has two QString inputs and one QString output, where the output is the result of the two input strings concatenated together. But what if we wanted to contatenate three strings? Or four? We could either:
Clearly, the second option above is the most useful. Workspace allows us to do this through the use of Array Inputs; inputs that provide a whole array of input data to the operation they are attached to. In fact, for the case of concatenating strings, such an operation already exists; the ConcatenateStrings operation:
If we look closely at the ConcatenateStrings operation above, we will see that the "Strings" input is decorated with four small dots. These dots indicate that the input is an Array Input, and thus it can be comprised of any number of data elements.
There are three ways to add an element to an array input:
Each of the above options is equivalent - whichever you use is a matter of personal preference. Once you've added elements, you can identify them on the workflow as the sub-inputs of the array input.
To delete an array input, simply right click on it and select the "Delete input element" option in the context menu. If the element already has a connection, you will be prompted as to whether you wish to delete it.
Once you've created array input elements, as with ordinary inputs, you are able to edit the data assigned to unconnected elements using the Operation Editor. Simply click on the operation itself, and you will see the inputs in the OperationEditor as we can see from the ConcatenateStrings screenshot below.
In many cases, the order of elements in an array input is significant. For example, in the case of the ConcatenateStrings operation, the order of elements in the Strings input indicates the order that the strings will be contatenated together. If we put the strings in a different order, we will result in different output strings. If we wish to know which index a particular element is, we can hover over it to see a tooltip.
It also is possible to re-order array input elements. To do this, right click on the array input and select "Re-order inputs".
You'll then be presented with a dialog where it is possible to control the exact order of the input elements. The dialog shows the source output, source operation and data for each input element, as can be seen in the screenshot below.
To change the order, drag and drop the row to where you want it. The indices will be reassigned in order when the dialog box is closed.