Previous in Contents Next in Contents

Creating and Accessing IColumn Interface Objects

You create an IColumn interface object by calling the IColumns.Add method. You can access a specific IColumn interface object by calling the Item property. Because IColumns is a collection, you can access all IColumn interface objects using a for each loop, as in the following example, where objColumn is the name you give to the IColumn interface object:

Option Explicit 
On Error Resume Next 

Dim objSearchAdmin, objBuildCatalog, objColumn 
Dim Name, Desc, ColType, PropGuid, PropPid, Index, Retrieve, Length

Set objSearchAdmin = CreateObject("Search.SearchAdmin.1") 

'Add a new column to KMSampleCatalog1 catalog definition
Set objBuildCatalog  = _
  objSearchAdmin.BuildServer.BuildCatalogs("SampleCatalog")

Name     = " HitCount" 
Desc     = "The number of hits (words matching query) in file" 
ColType  = "I4" 
PropGuid = "49691c90-7e17-101a-a91c-08002b2ecda9" 
PropPid  = "4" 
Index    = False 
Retrieve = True 
Length   = 0 

objBuildCatalog.Schema.Columns.Clear

objBuildCatalog.Schema.Columns.Add _
  Name, Desc, ColType, PropGuid, PropPid, Index, Retrieve, Length 

For Each objBuildCatalog IN objSearchAdmin.BuildServer.BuildCatalogs 

  Wscript.Echo "The schema for " & objBuildCatalog.Name _
    & " has these columns:"

  For Each objColumn in objBuildCatalog.Schema.Columns
    Wscript.Echo "  Name:         " & objColumn.Name 
    Wscript.Echo "  Description:  " & objColumn.Description 
    Wscript.Echo "  PropGuid:     " & objColumn.PropGuid 
    Wscript.Echo "  PropPid:      " & objColumn.PropPid 

    If objColumn.Retrieve Then
      Wscript.Echo "  Retrievable:  Yes"
    Else
      Wscript.Echo "  Retrievable:  No"
    End If 

    If objColumn.Index Then
      Wscript.Echo "  Indexable:    Yes"
    Else
      Wscript.Echo "  Indexable:    No"
    End If 

    Wscript.Echo "  Type:         " & objColumn.Type
    Wscript.Echo "  Length:       " & objColumn.Length
    Wscript.Echo ""
  Next
Next

'Release objects 
Set objColumn       = Nothing 
Set objBuildCatalog = Nothing 
Set objSearchAdmin  = Nothing 
 

© 1997-2000 Microsoft Corporation. All rights reserved.