Crash Course 101
10 modules
5 weeks

Global Variables

Click to copy

Creating and using global variables

The next step in studying web applications is to create the ability to edit records in the database. To do this, we need the ability to use global variables. Let's see how to use them, why they are needed and how they differ from ordinary local variables.

Difference between global and local variables

We have already used local variables before. The point of using them was to declare them in one part of the business process and then use the data from them in another part. In this sense, global variables perform similar tasks but at a more advanced level. Consider the differences:

  • The global variable is initialized immediately when the application starts
  • It has its own name for ease of identification
  • It is available in any business process of application

It is worth noting right away that the various components of the application (backend, web, mobile) use their own independent set of global variables. At the same time, for web applications the launch of global variables is their opening in a browser tab. It is in this tab that global variables "live." If you open the same application in another tab, then their own global variables will already be independent of the first tab.

If we consider global variables for the server part, for the backend, then we can be sure that each global variable exists in a single copy, even if it is accessed by different users from different parts of the world.

Creating global variables

Let's jump right into practice and create the first global variable for web applications. It will be useful to us to implement the possibility of editing records in the database.

Web application global variables are managed in the corresponding tab. Let's go there, create a new variable and fill in the required parameters.

The variable is intended to store the ID of the record that is being edited at the moment so that the appropriate name would be Record ID and the type Integer. The variable's value will change, so the Read-only option must be left off. It is also possible to set a Default value, but in this case, this is also not necessary.

Was this article helpful?
Still looking for an answer?
Join the Community