Control Flow Functions

Prev Next

Introduction

Flow control covers programming language features like branches (if ... lese), loops, etc. Unlike in other common programming langauges, control flow in B4P is implmented as functions which are then called as procedures which will then determine whether to execute the subsequent statements or blocks or not.

For example, a keyword as simple as if() is a B4P function called as a procedure taking one Boolean parameter. It decides whether to execute the next statement or block or not.

B4P provides a large variety of control flow functions, covering:

In case you miss the goto statement, there is a good reason for this. The highly structured B4P interpreter would have faced risky challenge if that statement would have been impleemented. Further more, see the seeparate section on control flow functions for tables where the following functions, mostly loops, are defined:


Procedures and Functions Provided:


conditional branches:
    if
    unless

one-time execution:
    once

alternative execution of code blocks:
    check
    switch
    case
    break
    break case
    break loop
    continue
    continue case
    continue loop
    continue with next case

do-loop:
    do

for-loop:
    for

Loops:
    until
    while

for-loop through parameter elements, parameter set:
    for all parameters

for-loop through variables:
    for all variables
    for all variables if existing
    for all variables if existing and valid

defining user procedures and user functions, user-defined function:
    define function
    define procedure
    define procedure and function

additional function names:
    define additional function
    define additional procedure
    define additional procedure and function
    return

function existing:
    function existing
    user function existing

delete user function:
    delete user function

start B4P program:
    start

include B4P program, include library, include libraries:
    include
    get long options
    pause
    stop
    interactive
    exit
    end
    abort
    throw
    catch
    catch if
    exception

Null function, Do nothing:
    null

Select parameter based on numeric value in 1st parameter:
    pick
    select

Select parameter based on boolean value in 1st parameter:
    pick if
    select if

Select parameter based on multiple boolean values:
    pick ifs
    select ifs

Select value from variable if existing:
    pick if existing
    pick if existing and valid
    select if existing
    select if existing and valid

Select parameter based on matching corresponding values:
    pick by value
    select by value

Selection based sequence of comparisons:
    compare pick
    compare select

Call function or procedure by name provided:
    call

Call function for every parameter set element separately:
    deep
    deepr

Execute B4P statements provided:
    exec

Calculate an expression provided:
    calc

compare [function]:
    compare

assign [function]:
    assign