Code Pieces (Func. Param. Type)

Prev Next

Introduction

Passing code pieces as function parameters is a unique feature in B4P. Code pieces can either be provided directly or as a string. When the function is called, the code piece is checked for correct syntax. While the function is running, the code pieces provided may be called multiple times, or in specific cases not at all.

Code pieces provided in strings must be referenced with a preceding colon (:) symbol in order to avoid interpreting the string value or expression as actual code to execute. Code pieces come in 4 different flavors:

Code Piece Type Description Syntax Examples
Comparison expression Expression to compare something without value on left hand side.
The parameter inside the case() function is a comparison expression.
>30
3..4
A (equals A)
Expression Any form of B4P expression as expected on right hand side of assignments
The parameter inside the while() function is an expression which must return a boolean result.
a[]+1
abs(-1)
Variables Expression on left hand side of assignments, which are destination variables, but not tables.
The dim() function makes use of this.
a[]
[table:Name,1]
Statements 1 or more statements, separated with semicolons. Braces are allowed.
The for() function expects two such statements.
a[]=b[]+2;
{ echo(test); c[]=1 }