FAQ>Lists

Dynamically access a result in a List

 

Article #:

0033

Contributor:

Daniel Todes

GF version:

All

Applies to:

Lists

Last updated:

February 4, 2002

Question

How can I access a result in a List, if I know the corresponding item but I do not want to open the List at run time?

Answer

Using the name of the item, you can return the position of the item in the List. Once you have the position (index), you can use it to access the corresponding result.

 

For example

  1. Select the List:

%[x = Lists.Select ('\GF General Office Samples\Company', 'Committee')]

  1. You may have an existing variable whose value corresponds to an item in a list. If, for example, the value of the variable "Name" is "D Jones", you can use this variable to determine the position of D Jones in the List:

%[y = x.IndexOfItem(Name)]

This FillPoint returns the index of D Jones and stores it in the "y" variable.

  1. You can now use the index to refer to the result associated with this item:

%[x.Result(y)]