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' ;
}

C#

public static bool DataEngine_GetCustomMetaData(SFQApplication sfqApplication)
{	
  Field field = sfqApplication.DataEngine.Field.AddItem("DETAILS.TOTAL_PRICE");
  field.Type = "Y";
  field.Caption = "Total Price";
  field.Format = "$";
  field.Picture = "999,999.99";
  field.SQExpression = .F.;
  field.Expression = "DETAILS.UNIT_PRICE * DETAILS.QUANTITY";
}

VB.NET

public shared function DataEngine_GetCustomMetaData(sfqApplication as SFQApplication) _
    as Boolean
  Field field = sfqApplication.DataEngine.Field.AddItem("DETAILS.TOTAL_PRICE")
  field.Type = "Y"
  field.Caption = "Total Price"
  field.Format = "$"
  field.Picture = "999,999.99"
  field.SQExpression = .F.
  field.Expression = "DETAILS.UNIT_PRICE * DETAILS.QUANTITY"
  Return True
End Function

See also

Collections

© Stonefield Software Inc., 2024 • Updated: 06/06/16
Comment or report problem with topic