2.2.3.19.2 vectorbase::Append

Description

Append data to a vector


Append a COM object of type _VARIANT to a vector or Dataset.

Syntax

BOOL Append( vectorbase & vv )


BOOL Append( _VARIANT & var )

Parameters

vv
[input]vectorbase object to be appended


var
[input]a COM data object of type _VARIANT

Return

Return true if success, else false


Return true if success, else false

Examples

EX1

void vectorbase_Append_Ex1()
{
    vector vec1 = {1, 2, 3, 4, 5};
    vector vec2 = {6, 7, 8, 9, 10};

    // Append contents of a vector 2 to vector 1
    if( FALSE == vec1.Append(vec2) )
    {
        out_str("Error appending vector.");
        return;
    }

    // Output Append results
    for( int i = 0; i < vec1.GetSize(); i++ )
        printf("%2d == %f\n", i, vec1[i]);
}

EX1

// For this example to run, have an Excel workbook inside Origin with the name "Book2",
// and put some data into it. For example: {6, 7, 8, 9, 10}
void vectorbase_Append_Ex2()
{
    vector vec1 = {1, 2, 3, 4, 5};
 
    WorksheetPage	wkbk("Book2");
    if (!wkbk)
    {
        out_str("Invalid Excel WorksheetPage!");
        return;
    }
    
	Object	objxlWkbk, objxlWorksheet, objxlRange;
 
    // Get the COM object associated with the Excel:
    BOOL	bOK = wkbk.GetExcelCOMObject(objxlWkbk);
    if (!bOK)
    {
        out_str("Failed to get the Excel COM object!");
        return;
    }
    
	// The active sheet:
    objxlWorksheet = objxlWkbk.ActiveSheet;
    // The Range object:     
    objxlRange = objxlWorksheet.Range("$A$1:$A$5");

	// Get the values from the Range as a vector
    _VARIANT vec2;
    vec2 = objxlRange.Value;

    // Append contents of Excel "Book2" to vector 1
    if( FALSE == vec1.Append(vec2) )
    {
        out_str("Error appending vector.");
        return;
    }
 
    // Output Append results
    for( int i = 0; i < vec1.GetSize(); i++ )
        printf("%2d == %f\n", i, vec1[i]);
}

Remark

Append data from an object of type _VARIANT to this vectorbase derived object. _VARIANT is a universal type that exists in COM to hold various types of data. It is used to set or get the values or properties of COM objects. It can represent individual values of int, double, etc., as well as arrays and other composite types.

See Also

Header to Include

origin.h