File tree Expand file tree Collapse file tree
mdl-examples/doctype-tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 781781 * Example 6.7: WHILE loop with nested IF
782782 *
783783 * Demonstrates WHILE with conditional logic inside the loop body.
784+ * Note: RETURN inside a loop is not allowed in Mendix (CE0068),
785+ * so we use a flag variable to exit early.
784786 */
785787CREATE MICROFLOW MfTest.M024_4_WhileWithCondition (
786788 $Number: Integer
@@ -792,16 +794,17 @@ BEGIN
792794 END IF;
793795
794796 DECLARE $Divisor Integer = 2;
797+ DECLARE $IsPrime Boolean = true;
795798
796- WHILE $Divisor * $Divisor <= $Number
799+ WHILE $Divisor * $Divisor <= $Number AND $IsPrime
797800 BEGIN
798801 IF $Number mod $Divisor = 0 THEN
799- RETURN false;
802+ SET $IsPrime = false;
800803 END IF;
801804 SET $Divisor = $Divisor + 1;
802805 END WHILE;
803806
804- RETURN true ;
807+ RETURN $IsPrime ;
805808END;
806809/
807810
@@ -943,7 +946,7 @@ CREATE MICROFLOW MfTest.M028_RetrieveWithDateTimeToken ()
943946RETURNS List of MfTest.Order AS $OverdueOrders
944947BEGIN
945948 RETRIEVE $OverdueOrders FROM MfTest.Order
946- WHERE ShipDate < [%CurrentDateTime%];
949+ WHERE OrderDate < [%CurrentDateTime%];
947950 RETURN $OverdueOrders;
948951END;
949952/
You can’t perform that action at this time.
0 commit comments