【中文版】

Introduction

MFP language introduction

operators

function

variable

if

while do for

break continue

select

try catch

class

call

citingspace

help

@compulsory_link

@execution_entry

@build_asset

MFP functions

deploy user functions

call MFP in your app

build Android APK

game programming

chart plotting

MFP math analysis

MFP file procession

number string and array

time date and system

Introduction of SCP

MFP language while, loop, do, until, for, next statements:

While and loop, do and until, and for and next are three pairs of looping statements in MFP. They should be used in the following way:

While condition

    ......

Loop

Do

    ......

Until condition

For variable var = from_value to to_value step step_value

    ......

Next

where condition is an expression which has boolean value (or can be converted to boolean value). Var is the name of for statement's index variable. From_value is the initial value of var, step_value is how much var increases each time. Note that step_value can be negative. To_value is the destination value of var variable. Var variable stops to change if it is beyond to_value. Note that if var is defined before, the variable keyword following for can be ignored. The following code is an example of for block. Note that when for statment's index variable's value equals to_value, statments inside for block are still executed. Only if index variable's value is beyond to_value the for loop finishes.

variable idx
for idx = 1 to -1 step -2
    print_line("idx == " + idx)
next

By running the above code, the output is

idx == 1

idx == -1

Note that all the three looping blocks support break and continue statement. When break is hit, MFP jumps out the current inner-most looping block. When continue is hit, MFP ignores the following statements in the inner-most looping block and goes back to the beginning of the looping block.