Mini App Document Mini App Document
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Start
  • Configuration
  • Framework
  • Custom Components
  • Basic ability
  • Configuration
  • Interface
  • FXML syntax
  • FXS syntax
API
Components
IDE
  • Developer
  • Operator
  • Configuration

  • Interface

  • FXML syntax

  • FXS syntax

    • Introduction to FXS
    • Module
    • Variable
    • Comment
    • operator
    • statement
      • if statement
        • Example syntax
      • switch statement
        • Example syntax
        • Sample code
      • for statement
        • Example syntax
        • Sample code
      • while statement
        • Example syntax
    • Data type
    • Base class library
  • Framework
  • FXS syntax
2022-08-09
Directory

statement

# if statement

In FXS, you can use an if statement in the following format:

  • 'if (expression) statement': When 'expression' is truthy, the 'statement' is executed.
  • 'if (expression) statement1 else statement2': When 'expression' is truthy, 'statement1' is executed. Otherwise, execute 'statement2'.
  • `if ... else if ... else statementN' With this sentence pattern, you can choose one of the executions between 'statement1 ~ statementN'.

# Example syntax

 if ...

if (expression) statement;

if (expression)
  statement;

if (expression) {
  Code blocks;
}


 if ... else

if (expression) statement;
else statement;

if (expression)
  statement;
else
  statement;

if (expression) {
  Code blocks;
} else {
  Code blocks;
}

 if ... else if ... else ...

if (expression) {
  Code blocks;
} else if (expression) {
  Code blocks;
} else if (expression) {
  Code blocks;
} else {
  Code blocks;
}

# switch statement

# Example syntax

switch ( expression ) {
  case variable:
    statement;
  case number:
    statement;
    break;
  case string:
    statement;
  default:
    statement;
}
  • The 'default' branch can be omitted without writing.
  • The 'case' keyword can only be used after: 'variable', 'number', 'string'.

# Sample code

var exp = 10;

switch ( exp ) {
case "10":
  console.log("string 10");
  break;
case 10:
  console.log("number 10");
  break;
case exp:
  console.log("var exp");
  break;
default:
  console.log("default");
}

Output:

# for statement

# Example syntax

for (statement; statement; statement)
  statement;

for (statement; statement; statement) {
  Code blocks;
}
  • Support for using 'break', 'continue' keywords.

# Sample code

for (var i = 0; i < 3; ++i) {
  console.log(i);
  if( i >= 1) break;
}

Output:

# while statement

# Example syntax

while (expression)
  statement;

while (expression){
  Code blocks;
}

do {
  Code blocks;
} while (expression)
  • When the expression is 'true', the loop executes the 'statement' or 'code block';
  • Support for using 'break', 'continue' keywords.
Last update: 2022/08/11, 20:42:12
operator
Data type

← operator Data type→

Copyright © 2020-2024 Neuxnet
  • Follow System
  • Light Mode
  • Dark Mode
  • Reading Mode