ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage syntax / Declaring variables
  • Handling a composite variable
  • Type of the members in a composite variable
  • Declaring an array member in a structure
  • Limits of a composite variable
  • Which "advanced" types can be a member?
  • Declaring variables with the same name
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
Composite variable
In french: Variable composée
A composite variable contains different types of elements (members).
Remark: If you are handling custom variables, we advise you to declare:
  • a composite variable if a single variable of this type is used in your project (to pass parameters to an API for example).
  • a structure type if several variables of this type are used in different processes of the project.
Example
ProductRef is composed of
SCode is int
PdtCode is fixed string on 10
END
ProductRef.SCode = 7
ProductRef.PdtCode = "Screen"
Syntax

Declaring a composite variable Hide the details

<Variable name> is composed of
   <Members of the composite variable>
END
<Variable name>:
Name of the composite variable to declare.
<Structure members>:
Declarations of the variables found in the composite variable. These variables are called members of the composite variable.
<END>:
End of declaration of the composite variable.

Handling a member of a composite variable Hide the details

<Variable name>.<Member name>
<Variable name>:
Name of the structure variable to declare.
<Member name>:
Name of the member to use.
Remarks

Handling a composite variable

There is no need to reference the members of composite variable.
For example:
CompositeVar is composed of
Member1 is fixed string on 8
Member2 is fixed string on 12
END
Str = CompositeVar // Str is built by concatenating all the members
// of the composite variable
CompositeVar = Str // Str is transferred to the composite variable

Type of the members in a composite variable

The members of a composite variable can have the following types:
Any other type of data (composite variable, constant, ...) is forbidden.

Declaring an array member in a structure

  • Declaring a member whose type is simple array:
    The array dimensions are fixed when the array is declared. The array dimensions can be modified by Dimension
  • Declaring a member whose type is dynamic array:
    The array dimensions must be defined (which means that the array must be allocated) before using the array.
For example:
// Declare a composite variable
MyCompVar is composed of
x1 is int
x2 is dynamic array       // Declare the array
END
 
// Allocate the array
MyCompVar.x2 = new dynamic array of 4,7 int
// Initialize the array
MyCompVar.x2[1,1] = 25

Limits of a composite variable

You cannot:
  • assign a composite variable to another composite variable directly: each member must be assigned individually.
  • compare two composite variables.
  • pass a composite variable in parameter to a procedure.
  • define an inheritance in a composite variable.
  • restrict the access to a member of a composite variable: all members of a composite variable must be public.

Which "advanced" types can be a member?

An "advanced" variable can be a member of another "advanced" variable. The table below presents the different combinations:
Composite variableStructureClassArray
Composite variableNoNoNoNo
StructureYesYesYesYes
ClassYesYesYesYes
ArrayYesYesYesNo

Declaring variables with the same name

You cannot declare:
  • two variables with the same name (regardless the type of these variables) in a process.
  • two members with the same name in the same composite variable.
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 03/06/2024

Send a report | Local help