While…Do…End Statement (FPScript)

09.03.2021

Executes a series of statements while a given condition is TRUE.

Syntax

While Condition Do

   [Statements]

End

The syntax of the While...Do...End statement consists of the following elements:

Element

Description

Condition

An expression that results in TRUE, FALSE or any numeric scalar value. For the numerical result, all values not equal to zero are taken to be TRUE.

Statements

One or more statements between Do and End that are repeated as long as Condition results in true.

Remarks

If Condition has the value TRUE, all statements until the End statement are executed. The program then returns to the While statement and checks whether the condition is still TRUE. In this case, the process is repeated. If Condition has the value FALSE, then the program continues the execution with the statement following the End statement.

While...Do...End statements can be nested as you like. An End statement always refers to the last executed While statement at the same level.

Note:   You should avoid loops over individual values of a data set, if possible. FPScript makes it possible for you to calculate complete data sets in one statement. Loops can usually be replaced by functions for event isolation in conjunction with the Index operator. The For Each Value...End loop is the fastest FPScript loop.

Available in

FlexPro View, Basic, Professional, Developer Suite

Example

The following example searches in a signal for a slope and all local maxima following thereafter and returns the X positions of the events as a data series:

Arguments Signal

Dim Pos, Result

Pos = NextSlope(Signal, , 0.2, 0.2, 0.01, EVENT_POSITIVE)

While Pos <> Empty Do

    Result := Pos

    Pos = NextExtremum(Signal, Pos, 0.01, EVENT_POSITIVE)

End

Result

See Also

Do...While Statement

For...End Statement

For Each Element...End Statement

For Each Value...End Statement

For Each Column...End Statement

For Each Row...End Statement

Share article or send as email:

You might be interested in these articles