Getting Subscription Field Information

The Subscription class provides the GetFieldName and GetFieldOrdinal methods to give access to subscription field information.

The GetFieldName method returns the name of a field by providing its ordinal number. The GetFieldOrdinal method of returns the ordinal of a field by providing its name.

The examples below show how to get subscription field information using managed code and using Microsoft Visual Basic Scripting Edition (VBScript) to illustrate COM interop.

The example shows how to use a Subscription object in managed code to return subscription field name information.

string instanceName = "Tutorial";
string applicationName= "Weather";
string subscriptionClassName= "WeatherCity";
string fieldName = "City";
int ordinal = 2;

// Create the NSInstance object.
NSInstance testInstance = new NSInstance(instanceName);

// Create the NSApplication object.
NSApplication testApplication =
    new NSApplication(testInstance, applicationName);

// Create the Subscription object.
Subscription testSubscription =
    new Subscription(testApplication, subscriptionClassName);

// Use the GetFieldName method to return a field name
Console.WriteLine("Name of field " + ordinal.ToString() + ": " + 

// Use the GetFieldOrdinal to return a field ordinal
Console.WriteLine("Ordinal for the " + fieldName + " field: " +

The following VBScript example shows how to use a Subscription object in unmanaged code to return subscription field name information:

Dim testInstance, testApplication, testSubscription, _ 
    ordinal, fieldName

const instanceName = "Tutorial"
const applicationName = "Weather"
const subscriptionClassName = "WeatherCity"
ordinal = 2

' Create the NSInstance object.
set testInstance = WScript.CreateObject( _ 
testInstance.Initialize instanceName

' Create the NSApplication object.
set testApplication = WScript.CreateObject( _
testApplication.Initialize (testInstance), applicationName

' Create the Subscription object.
set testSubscription = WScript.CreateObject( _
testSubscription.Initialize (testApplication), subscriptionClassName

' Get the name for a field identified by ordinal.
fieldName = testSubscription.GetFieldName(ordinal)
WScript.Echo "Field Name: ", fieldName 

' Get the field ordinal for the field.
fieldName = testSubscription.GetFieldOrdinal(fieldName)
WScript.Echo "Field Ordinal: ", fieldName