PreviousNextIndex

BOX function


(Windows only; GUI for .NET only)

Returns an object reference to a .NET System.Object that contains (boxes) a .NET mapping of an ABL value. At run time, this mapping depends on the kind of ABL value passed to the function. If you pass an ABL primitive value, the function returns a corresponding .NET mapped object type. If you pass an ABL array of .NET-compatible elements, the function returns a corresponding .NET array object type.

Syntax

BOX ( ABL-expression [ , AS-data-type-expression ] ) 

ABL-expression
AS-data-type-expression
Example

The following code creates a .NET DataTable with a single DataRow containing two columns. It then adds data to the row for the two columns. The Item indexed property used to access the columns has the data type System.Object. So, to add data to each column, you might have to use the BOX function to box the specified ABL value into an appropriate System.Object instance for the column. For example:

USING System.Data.* FROM ASSEMBLY. 
DEFINE VARIABLE dataTable1 AS DataTable  NO-UNDO. 
DEFINE VARIABLE dcCustNum  AS DataColumn NO-UNDO. 
DEFINE VARIABLE dcName     AS DataColumn NO-UNDO. 
DEFINE VARIABLE dcBusType  AS DataColumn NO-UNDO. 
DEFINE VARIABLE row1       AS DataRow    NO-UNDO. 
dataTable1 = NEW DataTable(INPUT "Customer"). 
/* Create columns for a dataTable */ 
dcCustNum = NEW DataColumn(INPUT "CustNum"). 
dcName    = NEW DataColumn(INPUT "Name"). 
dcBusType = NEW DataColumn(INPUT "BusType"). 
dataTable1:Columns:Add(INPUT dcCustNum). 
dataTable1:Columns:Add(INPUT dcName). 
dataTable1:Columns:Add(INPUT dcBusType). 
/* Create a new row */ 
row1 = dataTable1:NewRow( ). 
/* Add data to row */ 
row1:Item["CustNum"] = 1. 
row1:Item["Name"] = "Mr Jones”. 
    /* Without BOX, this automatically boxes System.Int32 value. */ 
row1:Item["BusType"] = BOX( 236, "UNSIGNED-BYTE"). /* System.Byte value */ 

Notes
See also

Data types, UNBOX function


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex