4D v14

Video script

Home

 
4D v14
Video script

Video script  


 

 

In the previous video, we used a variable to display the number of records found according to the table where the search was performed.
In fact, a variable is a space in memory that we can represent by an object in a form.

So we're going to create a test project form called "test variables" in order to show how variables work.

Let's create a first variable named v1 and that we'll make non-enterable. This variable does not actually exist in memory; there is just an area on screen that represents the contents of the variable if and when it exists.

We're going to:

  • put a button next to it that we can use to declare the variable. We'll give this variable the Longint type
  • then a 2nd button that we can use to assign a value to this variable -- v1:=1500.
  • Next, we can perform a calculation with this variable in memory and display, for instance, an ALERT.

We're going to display an alert that expects an argument of the text type so we're going to convert variable v1 after multiplying it by 12.

Now let's test the form:

  • Variable v1 is not actually defined yet
  • If we declare it, then we declare the type as longint; it takes a default value of 0
  • We can assign a value to it
  • and then we can perform a calculation with this variable.

Here is the first use of a simple variable.

The principle is the same with:

  • a variable of the text type that we'll call v2
  • Since it is a text type variable, we can display its value 12 times.
  • In passing, we concatenate the variable with a space and the combination will be multiplied by 12.
  • "Hello" here will be a variable not of the longint type, but of the text type.

If we test the form:

  • Variable v2 does not exist
  • When it is declared, it contains a blank value.
  • We can assign the value "Hello" to it
  • and use the variable in a calculation.

4D includes many functions for processing strings.

Let's take the case of an array.

  • We'll display it in a pop-up menu that we call pop1
  • and we declare that it will be of the array type
  • so to make a "Pop1" text array, we indicate the number of rows in the array, for instance 3 rows.
  • Now the array exists in memory and can be represented on this object.

To assign values to the array, we're going to indicate that:

  • the 1st row is "hello"
  • the 2nd row is "bye bye"
  • and the 3rd is "see you soon".

As concerns the use of the array, we can do it as shown here for example:

1st array value + a space + 2nd array value + 3rd array value.

Now let's test the result:

  • declaration of array: the array has 3 empty rows
  • assignment of values to array: "hello"  "bye bye"  "see you soon"
  • using the array: "hello space bye bye space see you soon"

So there we have it, a simple and quick overview of how to use variables.

 
PROPERTIES 

Product: 4D
Theme: Overview of variables

 
ARTICLE USAGE

Self-training ( 4D v13)
Self-training ( 4D v14)