Table of contents

Official Content

When you write variables directly in the code, and GeneXus automatically defines it if possible. The criteria used to determine the type are:

  • Based on: If you have for example a "Name" Domain (or Attribute) and you mention &CountryName in the source, the variable CountryName is defined based on the Domain (Attribute) "Name".  If the attribute "CountryName" exists, it will be based on it instead.

  • Boolean: If the variable has the prefix "&is","&Is","&has" or "&Has", followed by a string starting with a capital letter, it will be defined as Boolean.

  • Collection: If the variable has this format: "&xx[<Attribute Name>|<Domain Name>|<SDT Name>]Collection", being "xx" a free text, it will be defined as a collection based on the attribute|domain|sdt (provided there isn't an attribute, domain, or SDT with that full name). For instance, suppose you have an SDT named "Customer". If you write &MyCustomerCollection, the variable is defined as a collection of the Customer data type.

  • Boolean Collection: 3 components are required to automatically define a variable as a Boolean Collection: "&is" + <free text starting with capital letter> +"Collection". For instance: &isAvailableCollection.

Specification and Variables not defined

Undefined variables, which have not been manually defined nor automatically defined using the criteria explained before, are assigned with a type at specification time using the following criteria:

  • If the variable is assigned with an attribute, the type and length of the attribute will be used to define the variable.
    i.e. &ClientName = ClientName, the type and length of the ClientName attribute is assumed for the variable. If there more than one for the variable, only the first one is taken into to assume the type.

  • If a function is assigned to the variable, the returned type of the function is assumed for the variable. In this case the length cannot be automatically assumed, so Numeric variables will have length = 10,2 and Character variables will have length = 40.
    i.e. &Variable1 = val(Attribute), Variable1 will be N(10.2).
    &Variable2 = Attribute.ToString(), Variable2 will be C(40).

  • Otherwise, Numeric type and length = 10,2 is assumed for undefined variables.

In all cases, when a type is assumed for a variable at specification time, a warning is displayed in the navigation report: warning: spc0047: Variable Variable2 not defined; N(10.2) assumed.

Last update: April 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant