doWhileLoop
Description
Loop runs, and it continues to repeat as long as the condition remains true, executes the loop first then evaluates the condition.
Input / Parameter
condition
The condition to evaluates after the loop
boolean
-
-
Yes
Output
N/A
Callback
yesCallback
This will be triggered for every loop that happens while the condition remains true.
Example
In this example, we will do console logging by using console function in doWhileLoop callback
Code Equivalent
let m = 0;
do {
m++;
console.log("do while loop"+m);
} while(m < 5);Steps
Drag a
buttoncomponent into the canvas and open theActiontab. Select thepressevent of the button and drag thesetVarfunction to the event flow, add the valuemonvarparam and add the value0onvalueparam.
Drag the function
doWhileLoopto the eventflow, on it'sconditionparam change the param type to function/subflow then add functionlessinside the subflow, for thevalue1param change the param type to function/subflow then add functiongetVarinside the subflow, for thevarparam add valuem.
Drag the function
setVarinside functiondoWhileLoopyes callback, add valuemon paramvarand change the param type to subflow/function on paramvalue. Inside paramvaluesubflow addaddfunction then on it'svalue1change the param type to subflow/function, addgetVarfunction in it, then putmon it'svarparam value.
Drag the function
consoleinside functiondoWhileLoopyes callback, change the param type to subflow/function on paramvalue. Inside paramvaluesubflow addplusfunction then on it'svalue1param adddo while loopvalue, as forvalue2param change the param type to subflow/function, addgetVarfunction in it, then putmon it'svarparam value.
Result
Now click the button in preview, it will show the list of
do while loopwith the current loop number on the console.
Links
Related Information
See also:
Functions
Last updated