Official Content

Returns a reference to the element located at a certain position in a collection.

Syntax

&VariableBasedOnSDTCollection.Item(Position)

Where:

&VariableBasedOnSDTCollection
   
Is a variable name based on an SDT that is a collection.

Position
    Is the position of the desired element in the collection. This parameter must be Numeric (between 1 and the Count property value). 


Description

This method returns a reference to the element located at a certain position (specified by you as the argument) in a collection.

The first possible position is 1. If the specified position is less than 1 or greater than the number of elements, the program fails.

Note: It is not possible to assign a value to the syntax. In other words, the following code is wrong:  

&VariableBasedOnSDTCollection.Item(1)= AttValue
 

Samples

Consider the following SDT:

SDTCustomersCollection2

The following code is defined in a Web Panel object:

Event 'Show customer names'
   &Customers=DPLoadCustomers()
   for &i = 1 to &Customers.Count
      &Customer = &Customers.Item(&i)
      msg(&Customer.CustomerName)
   endfor
Endevent 

Variables:
- &Customers: Customers
- &Customer: Customers.Customer
- &i: Numeric(4)

The DPLoadCustomers Data Provider definition is as follows:

DPLoadCustomers

See Also

Structured Data Type methods

 


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