Skip to content

Control Flow

Control structures define how your MLM flows from one step to the next. With IF-ELSE, you branch logic depending on conditions. Loops like WHILE and FOR let you repeat actions over lists or ranges. Together, these allow you to handle repetitive checks, conditional processing, and more sophisticated decision-making.

If-Else

We use IF-ELSE structures to make decisions in our MLMs, letting the program choose different actions depending on whether a condition is true or false.

arden-syntax
data:
    num := 2;;
logic:
    if num > 5 then
        num := num
    elseif num <= 5 then
        num := 5;
    endif

You can replace symbols like > 5 with the more readable form is is greater than 5, both will give the same result. Similarly, <= 5 can be written as is less than or equal 5. These text-based comparisons make the code easier to read, especially for those new to programming.

You can find a more elaborated example in the Basic Fever MLM.

While Loop

A WHILE loop keeps running a block of code as long as a condition stays true, perfect for repeating tasks until something changes. The following example initializes the num variable as 10, which satisfies the while condition, so the loop runs and subtracts 1. This continues, decreasing num by 1 each time.

arden-syntax
data:
    num := 10;;
logic:
    while num <= 10 do
      num := num - 1;
    enddo

Have you noticed something? This loop will never end (an infinite loop) because Arden Syntax allows negative numbers, and nothing inside the loop makes num larger than 10 to break the condition. It’s important to design loops with conditions that will eventually become false so your MLM will terminate eventually.

For a correct implementation of WHILE check this example comparing allergies.

For & Seqto

The FOR loop lets us step through a sequence or range of values, running the same code for each step along the way.

arden-syntax
data:
    num := 0;;
logic:
    for i in 1 seqto 5 do
        num := num + 1;
    enddo;

Here, we have used SEQTO is a handy Arden shortcut for generating a sequence of numbers (like 1 to 10) without having to write the full loop yourself. So num at the end of this loop is going to be- you guessed it, 5.

Call Statements

The CALL statement lets one MLM trigger another, or even talk to external code. You can use it in the data and/ or logic slot and call it either with some parameters like in The returned results, can be stored in a variable like this:

arden-syntax
data:
    // Calling with parameters
    result := CALL myOtherMLM WITH parameter_list;
    LET result BE CALL myOtherMLM WITH parameter_list;

TIP

  • Parameters are passed by value, not by reference, the called MLM gets its own copy
  • A CALL can return nothing, one value, or multiple values