Data as A = <COLLECTION>.GET( Key as A )[. Child_Name as C ])

Data as A = <COLLECTION>.GET( Key as D )

Data as A = <COLLECTION>.GET( Key as N )


keyAny Type Date Numeric

Any type


The name of a child variable.


DataAny Type

Returns the value for the specified Key. If the key does not exist, the type of the returned value will be "Z".


Get the value for an element from the collection.


The <COLLECTION>.GET() method returns the Data associated with a specified Key.

Trailing spaces in the specified key are considered part of the key and are not trimmed.

dim mycollection as u
mycollection.set("FJ", "Fred Jones")
mycollection.set("BB", "Bryan Boyd")
mycollection.set("KL", "Kim Lee")
mycollection.set("KB", "Karen Boyd")
mycollection.set("EL", "Erica Loyd")
? mycollection.get("BB")
= "Bryan Boyd"
' The key is not case sensitive
? mycollection.GET("bb")
= "Bryan Boyd"
? mycollection.get("b")
= <No data returned>
x = mycollection.get("somekeythatdoesnotexist") ?typeof(x) ="Z"

The "value" that you assign to a collection entry does not have to be a scalar. It can be a dot variable with multiple children, as shown in the following example.

dim a as P
dim b as P
dim u as U = "Fred" = "Boston" = "Alpha" = "Ed" = "Nashua" = "Beta
u.set("Fred", a)
u.set("Ed", b)
? u.get("Ed").company
= "Beta"
? u.get("Fred").city
= "Boston"

If the data in a field is a logical field that allows NULL values, <COLLECTION>.GET() can return up to three possible values: .t., .f., or NULL. This primarily applies to collections populated from a DBF table using the from_table() method. For example:

dim collection as U
t ="products")
filename = t.filename_get()

? collection.get("122")
= .F.

? collection.get("123")
= .T.

? collection.get("124")

See Also