Matrix::Detach

Description

Detach a Matrix object from an internal Origin matrix.

Syntax

BOOL Detach( )

Parameters

Return

Returns TRUE if detachment is successful and FALSE if unsuccessful.

Examples

EX1

// Detach a matrix object from the matrix layer
void Matrix_Detach_ex1()
{
    BOOL rc;
    double dMean;
    
    MatrixPage MatPg1;
    MatPg1.Create("Origin");
    MatrixLayer MatLy1 = MatPg1.Layers(0);
    
    String LyName = MatLy1.GetName();
    Matrix Mat1;             // Declare OC Matrix object
    rc=Mat1.Attach(MatLy1);     // Attach the Matrix object to the matrix layer
    String MatName = Mat1.GetName();
    if(!rc)
        printf("  Error: Attach failed.\n");
    else 
        printf("  Attaching an internal matrix object to %s in %s succeeded.\n",LyName,MatName);

    matrix mat1 = {
        {1, 2, 3},
        {4, 5, 6}
    };
    Mat1=mat1; // Assigning the matrix values setting in the proper matrix sizes

    printf("  Observe that GetMean succeeds before detaching.\n");
    dMean = Mat1.GetMean();  // Use matrixbase::GetMean function
    printf("    >> Mean of %s in %s = %g\n",LyName,MatName,dMean); // Print out mean
    
    rc=Mat1.Detach();           // Detach OC Object from the internal Origin matrix
    if(!rc)
        printf("  Error: Detach failed.\n");
    else {
        printf("  Detaching an internal matrix object to %s in %s succeeded.\n",LyName,MatName);
        printf("  Observe that GetMean on a detached matrix causes a run-time error.\n");
        dMean = Mat1.GetMean();  // Use matrixbase::GetMean function
        printf("     >> Mean of %s in %s = %g\n",LyName,MatName,dMean); // Print out mean
    }
}

Remark

Detach a Matrix object from an internal Origin matrix.

See Also

Matrix::Attach, Matrix::IsValid, Matrix::Matrix

header to Include

origin.h