ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage syntax / Declaring variables
  • Declaring the combinations
  • Enabling or disabling the options of a combination
  • Reading the combination options
  • Passing a combination as a parameter to a procedure
  • Code suggestions
  • Extensible combinations
  • Preset combinations
  • Mutual exclusion
  • Associated properties
  • Available WLanguage functions
  • Limitations
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
A combination is a set of options. You can assign one or more combination options to a Combination variable or parameter, or assign no values.
Example
// Declaration code
// Declare a combination
CombinationType is Combination
	CreateFile
	ReadFile
	WriteFile
	DeleteFile
END
// Déclaration d'une variable de type Combinaison
ActionFichier is TypeCombinaison
// Affectation de la variable
ActionFichier = LectureFic + EcritureFic
// ActionFichier = 0 // Désactive toutes les options
...

// Pour tester la valeur de la combinaison:
IF ActionFichier[EcritureFic] THEN
	// L'option EcritureFic est activée
ELSE
	// L'option EcritureFic n'est pas activée
END
Syntax

Declaring a combination Hide the details

<Combination name> is Combination
   <Combination options>
END
<Combination name>:
Name of the combination to declare
<Combination options>:
Different options available for the combination.
<END>:
End of declaration.

Declaring a Combination variable Hide the details

<Variable name> is <Combination name>
<Variable name>:
Name of the Combination variable to declare.
<Combination name>:
Name of a previously declared combination.
Remarks

Declaring the combinations

A combination must be declared in:
  • The project initialization code so that it can be used in all the processes of the project (code of the project, windows, controls, procedures, etc.).
  • The global declaration code of a window so that it can be used in all the processes of the window (code of the window, controls in the window, local procedures, etc.).
  • The opening code of a report so that it can be used in all the processes of the report (code of the report, controls in the report, local procedures, etc.).
  • The class declaration code so that it can be used in the class.
    • To access this combination from a method of the class, use the "::<Combination name>" syntax.
    • To access this combination from outside the class, use the "<Class name>::<Combination name>" syntax.
  • The declaration code of a set of procedures so that it can be used in all the procedures of the set.
Remark: A combination is always global:
  • to a project,
  • to a window,
  • to a report,
  • to a class.

Enabling or disabling the options of a combination

Several syntaxes can be used to enable or disable the options of a combination. For example:
  • Declaration of the combination used for the examples:
    TypeCombinaison is Combinaison
    	CréationFic
    	LectureFic
    	EcritureFic
    	SuppressionFic
    END
    
    // Déclaration d'une variable de type Combinaison
    ActionFichier is TypeCombinaison
  • Disabling all options:
    Syntax:
    <Variable Combinaison> = 0

    Example:
    ActionFichier = 0
  • Enabling one or more options:
    Syntax:
    <Variable Combinaison> = Option 1
    <Variable Combinaison>[Option 1] = Vrai

    <Variable Combinaison> = Option 1 + Option 2
    <Variable Combinaison>[Option 1 + Option 2] = Vrai

    Examples:
    ActionFichier = LectureFic  // Active une option
    ActionFichier = LectureFic + EcritureFic // Active 2 options
    
    ActionFichier[LectureFic] = True  // Active une option
    ActionFichier[LectureFic + EcritureFic] = True // Active 2 options
  • Disabling one or more options:
    Syntax:
    <Variable Combinaison>[Option 1] = Faux

    <Variable Combinaison>[Option 1 + Option 2] = Faux

    Examples:
    ActionFichier[LectureFic] = False  // Désactive une option
    ActionFichier[LectureFic + EcritureFic] = False // Désactive 2 options

Reading the combination options

Several syntaxes can be used read the combination options. For example:
  • Combination declaration
    TypeCombinaison is Combinaison
    	CréationFic
    	LectureFic
    	EcritureFic
    	SuppressionFic
    END
    
    // Déclaration d'une variable de type Combinaison
    ActionFichier is TypeCombinaison
  • Check whether all the options are disabled:
    Syntax:
    SI <Variable Combinaison> = 0

    Examples:
    IF ActionFichier = 0 THEN ...
  • Check whether an option is enabled:
    Syntax:
    SI <Variable Combinaison> = Option 1 ...
    SI <Variable Combinaison>[Option 1] = Vrai ...

    Examples:
    IF ActionFichier = LectureFic THEN ...
    IF ActionFichier[LectureFic] = True THEN ...
  • Check whether several options are enabled:
    Syntax:
    SI <Variable Combinaison> = Option 1 + Option 2 ALORS ...
    SI <Variable Combinaison>[Option 1 + Option 2] = Vrai ...

    Examples:
    IF ActionFichier = LectureFic + EcritureFic THEN ...
    IF ActionFichier[LectureFic + EcritureFic] = True THEN ...
  • Check whether at least one option is enabled:
    Syntax:
    SI <Variable Combinaison>[Option 1] OU <Variable Combinaison>[Option 2] ALORS ...

    Examples:
    IF ActionFichier[LectureFic] OR ActionFichier[EcritureFic] THEN ...

Passing a combination as a parameter to a procedure

A Combination variable can be passed as a parameter to a procedure. To do so, use the following syntax:
<Nom de la procédure>(<Nom de la variable de type Combinaison>)
For example:
// Procédure avec un paramètre de type Combinaison
PROCEDURE TypeFichier(p is TypeCombinaison)

// Appels avec un paramètre de type Combinaison
TypeFichier(LectureFic + EcritureFic)
TypeFichier(ActionFichier)

Code suggestions

Code suggestions for a Combination parameter include the different options of the combination.

Extensible combinations

You can include one or more options from other combinations and add new options.
The following syntax is used:
<Nom de la combinaison> est une Combinaison
   [Combinaison de base]
   <Options supplémentaires de la combinaison>
FIN
where:
  • <Nom de la combinaison> Name of a previously declared combination.
  • Basic combination: Name of the basic combination to be used.
  • <Options supplémentaires de la combinaison> Additional options to be included in the combination.
Example:
TypeCombinaison is Combinaison
	CréationFic
	LectureFic
	EcritureFic
	SuppressionFic
END


TypeCombinaisonAvancé is Combinaison
	[TypeCombinaison]
	AutresAttributs
END

Preset combinations

Several options can be combined to force a preset combination. The combined options must belong to the combination (or to base combinations)
The following syntax is used:
<Nom de la combinaison> est une Combinaison
<Option 1 de la combinaison>
<Option 2 de la combinaison>
<Option 3 de la combinaison> = <Option 1 de la combinaison> + <Option 2 de la combinaison>
FIN
Example:
TypeCombinaison is Combinaison
	CréationFic
	LectureFic
	EcritureFic
	SuppressionFic
	Lecture_Ecriture_Fic = LectureFic + EcritureFic
END

Mutual exclusion

You can implement mutual exclusion in the combination options.
For example, a combination contains three options: Option1, Option2 and Option3.. Option2 and Option3 are mutually exclusive:
  • Option1 and Option2 can be active.
  • Option1 and Option3 can be active.
  • Option2 and Option3 cannot be enabled.
  • Option1, Option2 and Option3 cannot be active.
The following syntax must be used:
<Nom de la combinaison> est une Combinaison
<Option 1 de la combinaison>
<Option 2 de la combinaison>
<Option 3 de la combinaison>
// Exclusions
<Option 2 de la combinaison> - <Option 3 de la combinaison>
FIN
Note: By combining extensions and exclusions, it is possible to obtain for the same options:
  • a parameter of a function that imposes an exclusion,
  • a parameter of a function that does not impose any exclusion or that imposes a different exclusion.

Associated properties

The following properties are associated with Combination variables:
NameGets the name of a Combination variable.
ValueGets the value of a Combination variable.

Available WLanguage functions

A combination can be stored in an HFSQL item or in another file format. If necessary, you can store the name or the value of the combination (Name or Value property, respectively).
The following WLanguage functions allow you to get the characteristics of a stored combination:
CombinationCheckNameChecks whether a combination of one of more options known by their names is valid.
CombinationFromNameReturns a combination of one or more options known by their names.
CombinationFromValueReturns a combination of one or more options known by their associated values.

Limitations

  • Combinations are not available in dynamic compilation.
  • Combinations cannot be used outside the project.
Minimum version required
  • Version 18
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/19/2024

Send a report | Local help