The AddItem method adds a new member object to a collection and returns a reference to the new object. The class of the new object depends on the collection; for example, calling the AddItem method of the Fields collection returns a new Field object.

Syntax

AddItem(ItemName as String) as Object

Parameters
ItemName
The name to assign to the new item.

Return Value
A reference to the newly created object.

Example
This example, which could be used as the code for the DataEngine.GetCustomMetaData for a project, adds a new calculated field to the Fields collection.

Visual FoxPro

lparameters toApplication as SQApplication
local loField as Field
loField = toApplication.DataEngine.Fields.AddItem('DETAILS.TOTAL_PRICE')
loField.Type = 'Y'
loField.Caption = 'Total Price'
loField.Format = '$'
loField.Picture = '999,999.99'
loField.SQExpression = .F.
loField.Expression = 'DETAILS.UNIT_PRICE * DETAILS.QUANTITY'

VBScript

function Main(Application)
dim Field
set Field = Application.DataEngine.Fields.AddItem("DETAILS.TOTAL_PRICE")
Field.Type = "Y"
Field.Caption = "Total Price"
Field.Format = "$"
Field.Picture = "999,999.99"
Field.SQExpression = False
Field.Expression = "DETAILS.UNIT_PRICE * DETAILS.QUANTITY"
end function

JavaScript

function Main(Application) {
var Field ;
Field = Application.DataEngine.Fields.AddItem('DETAILS.TOTAL_PRICE') ;
Field.Type = 'Y' ;
Field.Caption = 'Total Price' ;
Field.Format = '$' ;
Field.Picture = '999,999.99' ;
Field.SQExpression = false ;
Field.Expression = 'DETAILS.UNIT_PRICE * DETAILS.QUANTITY' ;
}

See Also
Collections