| Fields |  |  |
Fields Collection
See also: Using collections.
| |

 |
Add method, ( Category, Type, Name As String, [Before] ) As Object.
Adds a new field declaration to the specified Fields collection. Returns a Field object that represents the field to be added.
Category An enum of type VpFieldCategory that indicates the category of the field to be created. Following are the possible values, which have the Long type:
vpcField = 1 vpcEventIn = 2 vpcEventOut = 3 vpcExposedField = 4
Type An enum of type VpFieldType that indicates the type of a new field. Following are the possible values, which have the Long type:
| vpfSFBool = 1 |
vpfSFNode = 6 |
vpfSFVec3f = 11 |
vpfMFRotation = 16 |
| vpfSFColor = 2 |
vpfSFRotation = 7 |
vpfMFColor = 12 |
vpfMFString = 17 |
| vpfSFFloat = 3 |
vpfSFString = 8 |
vpfMFFloat = 13 |
vpfMFTime = 18 |
| vpfSFImage = 4 |
vpfSFTime = 9 |
vpfMFInt32 = 14 |
vpfMFVec2f = 19 |
| vpfSFInt32 = 5 |
vpfSFVec2f = 10 |
vpfMFNode = 15 |
vpfMFVec3f = 20 |
Name A String that represents the name of field you want to create. The name must be unique in the specified collection.
Before (Optional) An index of a new item in the collection. The field to be added is inserted in the collection before the field identified by the Before argument.
If a numeric expression, Before must be a number from 1 to Count.
If a string expression, Before is a field name that can be used instead of the positional index.
If an object expression, Before is a Field object from the collection or any Entity object with the same owner.
By default, a new field declaration is inserted at the end of the collection.
The following example creates a Script node and adds an interface field declaration.
Dim n As Node
Set n = Document.RootNodes.Add("Script")
n("url") = "javascript:" + vbCrLf + "function onClick(){}"
n.Fields.Add vpcEventIn, vpfSFTime, "onClick", "url"
|
|

| |

 |
Count property, read-only, Long.
Returns the number of items in the specified collection.
|

| |

 |
Item property, default, read-only, ( IndexOrName ) As Object.
Returns a Field object that represents a member of the collection, either by position or by name.
IndexOrName The name or index number of a member of the collection. The index can be a numeric expression (a number from 1 to the value of the collection's Count property), a constant, or a string, that represents the name of an existing field from the collection. If the value provided as IndexOrName doesn't match any existing member of the collection, an error occurs.
The following example hides all fields of the first root node that have a default field value.
Dim flds As Fields
Set flds = Document.RootNodes(1).Fields
For i = 1 To flds.Count
flds(i).Implicit = True
Next
|
|

| |

 |
_NewEnum property, read-only.
References fields in the specified collection.
With C++, you can browse a collection to find a particular item by using the _NewEnum or the Item properties. In Visual Basic and VBScript, you do not need to use the _NewEnum property, because it is automatically used in the implementation of For Each ... Next or in For ... in statement in JavaScript.
The following example hides all fields of the first root node that have a default field value.
Dim f As Field
For Each f In Document.RootNodes(1).Fields
f.Implicit = True
Next
|
The following example is a C++ code snippet you can insert into an add-in's command handler method. This example uses the _NewEnum property to iterate through all fields of a node and hide those that have default field value.
Node *pNode;
...
Fields *pFields;
pNode->get_Fields( &pFields );
IEnumVARIANT *pFieldsEnum;
pFields->get__NewEnum( (IUnknown**) &pFieldsEnum );
VARIANT varField;
VariantInit( &varField );
while( pFieldsEnum->Next( 1, &varField, NULL ) == S_OK )
{
Field *pField;
if ( SUCCEEDED(varField.pdispVal->
QueryInterface( IID_Field, (void**) &pField)))
{
pField->set_Implicit( VARIANT_TRUE );
pField->Release();
}
VariantClear( &varField );
}
pFieldsEnum->Release();
pFields->Release();
|
|

|
|
|