You are here: Using BML > Functions & Scripts > Conditional Functions

Conditional Functions

OVERVIEW

Conditional functions are commands that run only when specified criteria is met. Each conditional statement requires a Boolean expression that may or may not be visible to you. To put it more plainly, a conditional function must evaluate to true or false.

ADMINISTRATION

ClosedBreak

Using this function will break a for...loop at the element that you define.

Example of break:

In this example, we used a 1-D string array and asked it to stop when it reached the element "ccc".


ClosedContinue

This function calls out an element from an array and essentially skips it, but continues looping through the rest of the array. Unlike the break function, the loop continues after it skips over the element.

Example of continue:


ClosedFor...Loop

The for...loop function is meant to loop through a block of code until a specific condition is met.

The variable represents the element, but you can label this however you want. You can call it 'each' or 'element' or even your name if you wanted to. Let's think of a table of values that we will name Table_Array:

Now, let's use the same syntax as above:

So, what we are really saying is: "For Row 1 in Table_Array, print each element in the row".

ClosedExample of for...loop in 1-D Array:


ClosedIf...Statements

What this is saying in plain language is: "If (condition) is True, then perform the statement". If that condition is False, then no action is taken.

Example of if...:

This is a very basic example, saying that if the variable string is a number, then we want to convert it to a float.

In this case, "25" is a number, so we used atof() to convert the string to a Float.


ClosedIf...Else...Statements

An if...else statement is essentially the same as an if... statement, except that instead of doing nothing if the condition isn't met, a different statement is run.

Example of if...else...:

So, it's saying "Do something if the first condition is met, if not, do this instead". You can also have multiple else statements nested within one another.

We are saying, "if the var = 25" is a number, then convert the string to a Float. If it's not a number, print "NaN".


ClosedIf...Else...If Statements

An if...else...if statement is a statement with two or more conditions.

Example of if...else...if:

if(attr1 == 100){

return true;} elif (attr1 == 200){

return false;}


NOTES

    NULL and blank Integer values are treated as separate values.

    - NULL= 0
    - Blank = ""

    If you use logic that tests for NULL values in rule conditions or BML, this logic should be updated.

    Using "null" as an attribute value is strongly discouraged.

RELATED TOPICS

Related Topics Link IconSee Also