Step-by-step guide
Different code blocks expect different data types. Attempting to snap the wrong data type to a code block will not work, so it is important to understand the different data types.
In this example, there are four code blocks relating to a Height parameter, and each expects a different data type:
- The first Nominal Wall Height parameter block is set to values, and expects a list or collection of data. The list can be composed of any data type, and in this case, includes two numeric blocks, 8 and 10.
- The second block is set to value and expects a numeric data type, such as 8.
- The third is set to label, which expects a Text data type. In this case, a Text block with the word “Length” is used.
- The last block is set to readOnly, which sets a Parameter to be editable or not editable in the form. This block expects a True False data type.
Modify each block to see how it impacts the form.
- For the Values block, click plus (+) to add a new list member, Duplicate a Number block, and input a value of 7.
- Click Update form, and the new value appears in the Length parameter drop-down.
- In the Value block, change the number to 7. Click Update form, and the new value appears in the Length input.
- For the Label block, change the text to “Hello World”. Click Update form, and the label updates in the form. Change the label back to “Length”.
- Change the Read-only block to be true. Click Update form to make the parameter read-only. Change the value back to false and click Update form to make the parameter editable again.
To further understand how parameter blocks handle data type changes:
- Add a Nominal Wall Height value equals parameter block and add a Number block set to 8.
In addition to Number blocks, the Parameter block also accepts mathematical equations:
- Add an Equation block, move the 8 to the first position, and then set it up to subtract 1. Connect the block to the parameter.
To see what happens when the wrong data type is added to a parameter block:
- Change the drop-down from value to the plural, values.
The equation block is rejected because a parameter set to values expects a list, not a numeric data type.
- Snap the Equation back to the parameter block, and it is rejected again. Try a Number, and it is rejected as well. A Text block is also rejected. The block will not accept data types that may generate an error.
Recall that the Values parameter block expects a list.
- Add a Create List With block. This data type is accepted.
- Snap each of the rejected blocks to the Create List With block, and all are accepted.
- Change the parameter block to a Label block to see that it rejects the List data type, as well as a Number block.
- Add a Text block, and it is accepted, because the Label requires text for the form label.
- Change the block to Read-only and test the different data types.
In summary, different code blocks expect different data types. The program prevents snapping incompatible data types to a code block. The general code block data type categories are text, numeric, lists, and true false.