Sign Up

Statements

In a function, various types of statements can be created to perform specific actions and control the flow of execution:

  • Create Variable: Generates a new variable, which can be initialized from scratch, reference an existing variable or parameter, the result of a function, retrieve data from the data store and assign it to the variable, or set a value to NULL.
  • Update Variable: Modifies the value of an existing variable.
  • Run Function: Invokes a function, which can be from the current class, an imported class, or a built-in function.
  • Data Store Action: Enables the saving or deletion of data and is exclusively used with Models having a data store.
  • Add Condition: Evaluates to either true or false. It directs the flow of function execution, determining which set of statements should be executed based on the outcome of the evaluation.
  • Add Count Loop: Repeats inner statements a specified number of times based on a Number variable.
  • Add List Loop: Selects a list variable to iterate over its contents. Each list item is accessible through a list item variable.
  • Exit Loop: Exits the Count or List loop at the current statement.
  • Skip Loop Item: Skips the current loop item and progresses to the next item.
  • Exit Function: Exits the Function at the current statement.
  • Add Try/Catch: Surrounds statements where you expect an error to be thrown. Allows code continuation instead of a 500 response.
  • Throw Error: Raises an error, and if the error is not caught, a 500 response is returned from the API.
  • Return Variable: This statement is only available in functions that have a return type. It sends a variable back from the function as the result.
  • Add Assertion: Checks the variable's value, which is necessary for test execution. This functionality is exclusively accessible in test class mode.

These statement types enable you to build robust and dynamic functions that can interact with data, make decisions, perform repetitive tasks, handle errors, and return meaningful results. The use of these statement types enhances the functionality and flexibility of functions within the API.

Related Topics

Import Classes

In the current class, you have the option to import your own classes and utilize functions that were created earlier. This helps minimize the requirement for duplicate classes. Once a class is imported, you can access all of its functions by using the "Run function" statement.

Global Variables

To access the view of global variables, simply click on the globe icon located in the workspace toolbar within a class. Additionally, you can press CTRL + G to initiate the opening of the global variables view. Global variables are variables declared at the global scope, providing accessibility from...

Validation Errors

Validation errors are similar to class errors but are performed at a lower level than the class. Any validation errors that arise will be displayed in the problems section of the bottom workspace bar. Clicking on the validation error will highlight the specific area where the problem occurs. If any ...

What is a Class?

A class in the API serves as a structured entity that holds both variables and functions. These functions are used in both endpoints and events to define specific functionalities. Variable A variable within the API is represented by a symbolic name or identifier, acting as a storage location in the ...

Testing

To ensure the proper functioning of your functions, it is essential to create tests that validate their output and ensure the reliability of your classes. To create tests, switch your class to test mode by clicking the "Tests" button in the bottom toolbar. This will display an alternate workspace de...