PC SOFT

AYUDA EN LÍNEA
DE WINDEV, WEBDEV Y WINDEV MOBILE

  • Variant type and NULL
  • Type of a variant
  • ..Class property on the variants
  • Named sub-elements
  • Subscripted sub-elements
  • Nesting named and subscripted sub-elements
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReportes y ConsultasCódigo de Usuario (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Código Navegador
WINDEV Mobile
AndroidWidget Android iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Otros
Procedimientos almacenados
The Variant type (Type of variable)
 
The Variant type is used to:
  • store any simple value: boolean, numeric (Currency, Real, Integer, ...), characters and character string, date (Date, Time, DateTime and Duration), ...
  • Versiones 19 y posteriores
    store named or subscripted sub-elements.
    Nueva funcionalidad versión 19
    store named or subscripted sub-elements.
    store named or subscripted sub-elements.
  • Versiones 15 y posteriores
    store any complex value: structures, classes, advanced types, arrays, associative arrays, queues, stacks and lists.
    Nueva funcionalidad versión 15
    store any complex value: structures, classes, advanced types, arrays, associative arrays, queues, stacks and lists.
    store any complex value: structures, classes, advanced types, arrays, associative arrays, queues, stacks and lists.
  • handle the NULL value in WLanguage.
  • store the interactions with the ActiveX objects and the Automation programming.
Versiones 17 y posteriores
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
Nueva funcionalidad versión 17
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
iPhone/iPad This type of variable is now available for iPhone/iPad applications.
Versiones 18 y posteriores
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Nueva funcionalidad versión 18
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Universal Windows 10 App This type of variable is now available in Windows Store apps mode.
Versiones 21 y posteriores
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Nueva funcionalidad versión 21
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Universal Windows 10 App This type of variable is now available in Universal Windows 10 App mode.
Apple Watch This type of variable is now available in Apple Watch mode.
Versiones 22 y posteriores
Java This type of variable is now available for the Java applications.
Android This type of variable is now available for the Android applications.
Widget Android This type of variable is now available in Android Widget mode.
Nueva funcionalidad versión 22
Java This type of variable is now available for the Java applications.
Android This type of variable is now available for the Android applications.
Widget Android This type of variable is now available in Android Widget mode.
Java This type of variable is now available for the Java applications.
Android This type of variable is now available for the Android applications.
Widget Android This type of variable is now available in Android Widget mode.
Ejemplo
nValue is Variant = 10
nValue = EDT_Edit1
nValue = Customer.Name
Sintaxis

Declaring and assigning a Variant type Ocultar los detalles

<Variable Name> is Variant = <Value>

OR


 <Variable Name> is Variant
 <Variable Name> = <Value>
<Variable Name>:
Name of variable to declare.
<Value>:
Value that will be assigned to the variable. A Variant variable can be assigned with:
  • any literal value,
  • the content of a variable,
  • the content of a simple control,
  • the content of an item.
Observaciones

Variant type and NULL

To specify that a Variant variable contains no value, use the NULL constant.
Notes:
  • for a variant type, NULL means "Not assigned".
  • for a numeric type, NULL means "equal to 0".
nVal is int
IF vVal = Null THEN ... // the test returns True because nVal=0
nVal = 5
IF vVal = Null THEN ... // the test returns False because nVal=5
vVal is Variant
IF vVal = Null THEN ... // returns True because the variant is not assigned
vVal = 0
IF vVal = Null THEN ... // returns False because the variant is assigned  
// with an integer whose value is 0
vVal = 5
IF vVal = Null THEN ... // returns False because the variant is assigned
// with an integer whose value is 5
vVal is Variant
vVal = Null
IF vVal = 0 THEN ... // returns True because a non-assigned variable
// and a value cannot be compared, True is returned by convention

Type of a variant

The type of a variant is returned by ..Type. ..Type is used to find out the type of value stored in the variable.
Notes:
  • VariantConvert is used to convert the type of value stored in a Variant variable.
  • TypeVar is used to find out the type of variable (Variant type for a Variant variable).
vVal is Variant
TypeVar(vVal)  // returns the number of the variant type
vVal..Type     // returns the type of the value stored in the variant

..Class property on the variants

..Class on the Variant variables is used to find out the name of the class used if the variant corresponds to a class.
Versiones 19 y posteriores

Named sub-elements

You can directly use the members without any declaration on a Variant variable.
When assigning a member, if the member does not exist, it is automatically created ; if the member already exits, it is modified.
Example:
Person is Variant
Person.LastName = "MOORE"
Person.FirstName = "Vince"
When reading a member, if the member does not exist, it is not created. You have the ability to check the presence of a member via ..Exist.
Example:
Person is Variant
IF NOT Personn.Name..Exist THEN
Error("The name was not specified")
END
If the member does not exist, the returned value is Null. Several methods can be used to explicitly test the Null value:
  • use ..Value .
    Example:
    Element is Variant
    IF Element.MemberNotFound..Value = Null THEN
    ...
    END
  • Versiones 23 y posteriores
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
    Nueva funcionalidad versión 23
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
The named sub-elements can be handled by the following properties:
ExistReturns:
  • True if the element exists,
  • False if the element does not exist. The element is not created.
NameElement name
TypeType of element (same values as TypeVar).
ValueElement value.
..Member on the Variant variables is used to get the array of named elements. This array can be handled by FOR EACH, the ..Occurrence property, the [ ] operator, ...
Nueva funcionalidad versión 19

Named sub-elements

You can directly use the members without any declaration on a Variant variable.
When assigning a member, if the member does not exist, it is automatically created ; if the member already exits, it is modified.
Example:
Person is Variant
Person.LastName = "MOORE"
Person.FirstName = "Vince"
When reading a member, if the member does not exist, it is not created. You have the ability to check the presence of a member via ..Exist.
Example:
Person is Variant
IF NOT Personn.Name..Exist THEN
Error("The name was not specified")
END
If the member does not exist, the returned value is Null. Several methods can be used to explicitly test the Null value:
  • use ..Value .
    Example:
    Element is Variant
    IF Element.MemberNotFound..Value = Null THEN
    ...
    END
  • Versiones 23 y posteriores
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
    Nueva funcionalidad versión 23
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
The named sub-elements can be handled by the following properties:
ExistReturns:
  • True if the element exists,
  • False if the element does not exist. The element is not created.
NameElement name
TypeType of element (same values as TypeVar).
ValueElement value.
..Member on the Variant variables is used to get the array of named elements. This array can be handled by FOR EACH, the ..Occurrence property, the [ ] operator, ...

Named sub-elements

You can directly use the members without any declaration on a Variant variable.
When assigning a member, if the member does not exist, it is automatically created ; if the member already exits, it is modified.
Example:
Person is Variant
Person.LastName = "MOORE"
Person.FirstName = "Vince"
When reading a member, if the member does not exist, it is not created. You have the ability to check the presence of a member via ..Exist.
Example:
Person is Variant
IF NOT Personn.Name..Exist THEN
Error("The name was not specified")
END
If the member does not exist, the returned value is Null. Several methods can be used to explicitly test the Null value:
  • use ..Value .
    Example:
    Element is Variant
    IF Element.MemberNotFound..Value = Null THEN
    ...
    END
  • Versiones 23 y posteriores
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
    Nueva funcionalidad versión 23
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
    test the Null value directly (available from version 230042). Example: test the Null value directly. Example:
    Element is Variant
    IF Element.MemberNotFound = Null THEN
    ...
    END
The named sub-elements can be handled by the following properties:
ExistReturns:
  • True if the element exists,
  • False if the element does not exist. The element is not created.
NameElement name
TypeType of element (same values as TypeVar).
ValueElement value.
..Member on the Variant variables is used to get the array of named elements. This array can be handled by FOR EACH, the ..Occurrence property, the [ ] operator, ...
Versiones 19 y posteriores

Subscripted sub-elements

You can directly use the Variant variable like an array of variants. Using the [ ] operator automatically creates the array.
Example:
Days is Variant
Days[1] = "Monday"
Days[2] = "Tuesday"
Days[3] = "Wednesday"
Days[4] = "Thursday"
Days[5] = "Friday"
Days[6] = "Saturday"
Days[7] = "Sunday"
The array operations can be directly performed on the Variant variable: FOR EACH, ..Occurrence, [ ] operator, ...
Nueva funcionalidad versión 19

Subscripted sub-elements

You can directly use the Variant variable like an array of variants. Using the [ ] operator automatically creates the array.
Example:
Days is Variant
Days[1] = "Monday"
Days[2] = "Tuesday"
Days[3] = "Wednesday"
Days[4] = "Thursday"
Days[5] = "Friday"
Days[6] = "Saturday"
Days[7] = "Sunday"
The array operations can be directly performed on the Variant variable: FOR EACH, ..Occurrence, [ ] operator, ...

Subscripted sub-elements

You can directly use the Variant variable like an array of variants. Using the [ ] operator automatically creates the array.
Example:
Days is Variant
Days[1] = "Monday"
Days[2] = "Tuesday"
Days[3] = "Wednesday"
Days[4] = "Thursday"
Days[5] = "Friday"
Days[6] = "Saturday"
Days[7] = "Sunday"
The array operations can be directly performed on the Variant variable: FOR EACH, ..Occurrence, [ ] operator, ...
Versiones 19 y posteriores

Nesting named and subscripted sub-elements

The named sub-elements and subscripted sub-elements being themselves of Variant type, you can recursively nest them.
Example:
Library is Variant
Library.Book[1].Title = "Mrs Dalloway"
Library.Book[1].Author = "Virginia Woolf"
Library.Book[2].Title = "Oliver Twist"
Library.Book[2].Author = "Charles Dickens"
Nueva funcionalidad versión 19

Nesting named and subscripted sub-elements

The named sub-elements and subscripted sub-elements being themselves of Variant type, you can recursively nest them.
Example:
Library is Variant
Library.Book[1].Title = "Mrs Dalloway"
Library.Book[1].Author = "Virginia Woolf"
Library.Book[2].Title = "Oliver Twist"
Library.Book[2].Author = "Charles Dickens"

Nesting named and subscripted sub-elements

The named sub-elements and subscripted sub-elements being themselves of Variant type, you can recursively nest them.
Example:
Library is Variant
Library.Book[1].Title = "Mrs Dalloway"
Library.Book[1].Author = "Virginia Woolf"
Library.Book[2].Title = "Oliver Twist"
Library.Book[2].Author = "Charles Dickens"
Versión mínima requerida
  • Versión 14
Esta página también está disponible para…
Comentarios
Comentarios Sobre tipo Variant
http://windevdesenvolvimento.blogspot.com.br/2016/01/a-incrivel-variavel-do-tipo-variant-e.html

http://forum.pcsoft.fr/fr-FR/pcsoft.br.windev/854-incrivel-variavel-tipo-variant-buffer-uma-das-solucoes/read.awp
De matos AMARILDO
09 01 2016