Random Number
Description
This object is being used to generate a random number.
App Builder Object
Source Code
function execute() {
const min = parseFloat(inPorts[1].value) === undefined ? 0 : parseFloat(inPorts[1].value);
const max = parseFloat(inPorts[2].value) === undefined ? 0 : parseFloat(inPorts[2].value);
const resolution = parseFloat(inPorts[3].value) === undefined ? 0 : parseFloat(inPorts[3].value);
if (resolution === 0) {
return [Math.floor((Math.random() * (max - min + 1)) + min)];
}
return [(Math.random() * (max - min) + min).toFixed(resolution)];
}
In Ports
Position | Name | Message Type | Description |
---|---|---|---|
1 | Trigger | Trigger | This port is being used to trigger the 'Random Number' object. |
2 | Min | Number | This port is being used to receive a message containing the min number for the 'Random Number' object. |
3 | Max | Number | This port is being used to receive a message containing the max number for the 'Random Number' object. |
4 | Resolution | Number | This port is being used to receive a message containing the resolution for the 'Random Number' object. |
Out Ports
Position | Name | Message Type | Description |
---|---|---|---|
1 | Value | Number | This port is being used to sent out the random number that has been generated by the 'Random Number' 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 |