Lookup Method for LCFieldlist

This method locates a field from a fieldlist based on field name.

Defined In

LCFieldlist

Syntax

Set field = fldListRecord. Lookup (fieldName, index)

Parameters

Parameter

Description

fieldName

String. Name of the field to look up.

index

Long. Output, optional. Position of the field.

Return Value

Value

Description

field

LCField. The field whose name in this list is fieldName. If no such field exists, Nothing is returned.

Example

Option Public
Uselsx "*lsxlc" 
Sub Initialize
  Dim connect As New LCConnection ("db2") 
  Dim FldLst As New LCFieldlist
  Dim field As LCField
  Dim pos As Long
  REM this section assigns the appropriate properties to connect to DB2
  connect.Database = "Gold"
  connect.Userid = "JDoe"
  connect.Password = "xyzzy"
  connect.Metadata = "customer"
  REM connect to DB2
  connect.Connect
  REM now perform the catalog action - in this case for fields
  If (connect.Select (Nothing, 1, FldLst) = 0) Then
    Print "The customer table was not found."
  Else
    Set field = FldLst.Lookup ("contactname", pos)
    If Not (field Is Nothing) Then
      Print "Found 'ContactName' in the fieldlist at position " & pos
    Else
      Print "Did not find 'ContactName' in the fieldlist."
    End If
  End If
End Sub

Example Output

Found 'ContactName' in the fieldlist at position 2