if, else

Top  Previous  Next

Scripts > Class elements and c++ instructions > Interpreted C++ instructions > Control structures > if, else




if ( <condition> )  <statement1>;


if ( <condition> )  <statement1>;

  else <statement2>;




Use if to implement a conditional statement.

The condition statement must convert to a bool type. Otherwise, the condition is ill formed.

When <condition> evaluates to true, <statement1> executes.

If <condition> is false, <statement2> executes.

The else keyword is optional, but no statements can come between an if statement and an else.


In contrast to the C/C++ standard inside of the condition no variables may be defined and no assignments can be executed. That means the following is not possible:


if (int val = stoi("1")) or  // false

int val; if (val = stoi("1"))   // false        


Possible is:


if (stoi("1"))


This page belongs to the TextTransformer Documentation

Home  Content  German