English
Basic Syntax
About 634 wordsAbout 2 min
2026-01-09
Table of Contents
1. Custom function
Example: <data type> <variable> = <expression>
| Syntax Component | Description |
|---|---|
| Data Type | Custom functions provide 12 major data types. For details, refer to the data type chapter. Data types are case-sensitive. |
| Variable | The name of the data, used for later logic calls. It can be customized, but cannot be the same as a data type. |
| Expression | The value assigned to the variable. It can be directly defined or be an expression. If it is an expression, make sure the expression return type matches the data type, otherwise an error will occur. |
Note: In custom functions, def can be used to represent the data type, and the compiler automatically identifies the data type.
Example:
String str = "fxiaoke" // directly defined
Boolean boo = ["red", "blue", "green", "yellow"].isEmpty() // expression definition
def result = ["red", "blue", "green", "yellow"].isEmpty() // def represents the data type2. switch
Used to determine whether a given condition is satisfied, and decide which operation to execute based on the result (true or false).
2.1 Definition
switch(<key>){
case <value-1>: statements-1; break;
case <value-2>: statements-2; break;
default: statements-3; break;
}
// Execution order: when key has the same value as value-1, execute statements-1 and end; if key is not equal to value-1 but equals value-2, execute statements-2 and end; ...; if none are equal, execute statements-3 and endNote
- Multiple case statements can exist.
- The default statement can be omitted, but to prevent errors when no case statement matches a value equal to the key, try to keep one (at most one) default statement.
- A break statement can be omitted after each case or default statement, which means the switch statement does not end and execution continues. For example, if there is no break statement in the example above and key equals value-2, statements-3 will be executed after statements-2 finishes.
2.2 Example
Integer = 3
switch (day) {
case 0: x="Today it's Sunday"; break;
case 1: x="Today it's Monday"; break;
case 2: x="Today it's Tuesday"; break;
case 3: x="Today it's Wednesday"; break;
case 4: x="Today it's Thursday"; break;
case 5: x="Today it's Friday"; break;
case 6: x="Today it's Saturday"; break;
}// Final result: Today it's Wednesday3. if-else
Used to determine whether a given condition is satisfied, and decide which operation to execute based on the result (true or false).
3.1 Definition
if(condition1) {
If condition1 is true, execute here
}else if(condition2){
If condition2 is true, execute here
}else {
If neither condition1 nor condition2 is true, execute here
}Note: In an if control statement, both if and else control statements must exist. There can be zero or more else if statements, depending on the actual scenario.
3.2 Example
String str = "fxiaoke"
if(str.contains("s")) {
str = "hello"
}else if(str.contains("f")){
str = "welcome"
}else {
str = "hi"
}// Final result: str=welcomeChangelog
| Version | Date | Changes | Author |
|---|---|---|---|
| v1.0 | 2026-05-19 | Initial version |
Background
This document describes the related features and usage methods of Basic Syntax, helping developers quickly understand and use the relevant capabilities.
Applicable Scenarios
Specific applicable scenarios are determined by actual business requirements. Developers can select the corresponding syntax and capabilities as needed.
Prerequisites
- Access to Fxiaoke Open Platform
- Application authorization and configuration completed
- Basic knowledge of the relevant business domain
Steps
Please refer to the detailed descriptions in each section.
Notes
- Ensure prerequisites are met before using the syntax
- Pay attention to syntax rules and data type matching
- Refer to error code documentation for exception handling
Compatibility note: This version currently has no deprecated or compatibility notes.
