Official Content

Returns the number of columns defined for an array.

Syntax

Cols(&array())

Type returned:
Numeric constant, the same used to define the array.

Scope

Objects: Procedure, Transaction, Web Panel Panel, Data Provider
Generators: .NET, .NET Framework, JavaApple, Android, Angular

Description

By using this function, the array's dimensions within the program source is avoided. Modifying the array's dimensions would only cause the corresponding modification throughout the model, but there would be no need to modify the program's source where the array is used.

Samples

The following example illustrates how to load a 2D-array whose elements are the sum of their bi-dimensional positions (row and column):

&I = 1
Do while &I <= rows(&m())
   &J = 1
   Do while &J <= Cols(&m())
      &m(&I,&J) = &I + &J
      &J += 1
   EndDo
   &I = &I + 1
EndDo

See Also

Rows Function

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