|
|
|
|
- Lesson 2 - Variables
- Practical example
- What is a variable?
- Declaring a variable
- Assignment and use
- Types of variables
- Simple operations on variables
- Tips
- Variable type details: String variables
- The String type
- Building a string
- Operations on strings
- Finding a string
- Comparing two strings
- To sum up
Tutorial - WLanguage basicsWe will cover the following topics: - What is a variable?
- The different types of variables.
- The String type in detail.
20 mn To follow the steps in this lesson, we will use the "WLanguage" project that we created in the previous lesson (see A project to discover WLanguage in lesson 1). We will write the code directly in the project initialization code. This is the first section of code executed when the project is tested: we can do tests very simply, without any interface. To view the results of our operations, we will use Trace, which lets us write the desired information both to a trace window and to the debugger pane at the bottom of the editor. In this tutorial, we will use the debugger pane. Trace window "Debugger trace" pane This pane is not displayed by default. The "Debugger trace" pane will be displayed automatically when you test the example. First step for our tests: open the WLanguage events of the project. To do so: - Right-click the "P" button next to the open element tabs. The context menu appears.
- Select "Element code".
- The code editor displays the different WLanguage events associated with the project.
In a programming language, a variable is used to store data. These memory sections contain strings, numbers, etc. Variables are used to perform calculations, comparisons, or to store information that will be used later.
A variable is represented by: - a name: Name given to the variable so that it can be manipulated in the code.
- a type: Type of the data stored in the variable. In this tutorial, we will look at a few types of variable in detail.
- a value: Information stored in the variable.
- a scope: Scope of the variable in the program. The scope is mainly defined by the location where the variable is declared. For more details on this topic, see Scope of variables.
Simple operations on variables Variable type details: String variables
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|