Getting Started
Getting Started with B2Win Suite Scripting
Before diving into the more advanced features, let's start with some basic examples to get you acquainted with the language.
Example 1: Hello, World!
A classic "Hello, World!" example to display a greeting message:
You will be able to see the returned value in real-time in the evaluation section below your code.
Note: By default, in the absence of an explicit return
statement, scripts return the value of the last evaluated statement.
Using the return
keyword, a script will return the expression that follows (or null).
Example 2: Counting Down to Christmas
For a more engaging and inclusive example, we can determine the number of days remaining until Christmas Day by utilizing the now
and of
methods in the LocalDate class, in combination with the between
method from the Duration class. Here's how you can do it:
With this code, you can effortlessly calculate the days left until the much-anticipated Christmas Day, set for December 25, 2023. It's a fun way to keep track of the holiday season!
Example 3: Simple Arithmetic
You can perform basic arithmetic operations, like addition, subtraction, multiplication, and division. Here's an example:
This example showcases how to perform simple math operations and return the results.
Example 4: Working with Strings
You can use and manipulate strings. Here's an example that combines strings:
This example demonstrates string concatenation to create a full name.
Example 5: Conditional Statements
Here's an example that checks if a number is even or odd:
Example 6: Looping
Here's an example of a for loop to print numbers from 1 to 4:
Ready to explore more? Turn the page to Language Basics to continue building your understanding of B2Win Suite Scripting.
Last updated