curvebase::TrimLeft

Description

TrimLeft removes elements having the value NANUM from the left end of a Curve object.

Syntax

int TrimLeft( BOOL bShiftLeft = FALSE )

Parameters

bShiftLeft
[input] TRUE will delete cells on the left of (before) the first valid numeric value, FASLE will cause the lower bound or index to be adjusted upward but no cells are deleted.

Return

Returns -1 on error, 0 on success, and N > 0 for number of cells deleted.

Examples

EX1

// Assumes Book1_A and Book1_B exist and contain data with some missing value in row1~3
int curvebase_TrimLeft_ex1(string wksName = "Book1")
{
    Worksheet wks(wksName);
    if(wks)
    {
        Curve    crv(wks,1);
        crv.TrimLeft(TRUE);
    }
    return 0;
}

EX2

// Assumes Book1_A and Book1_B exist and contain data with some missing value in row1~3
int curvebase_TrimLeft_ex2(string wksName = "Book1")
{
    Worksheet wks(wksName);
    if(wks)
    {
        Curve crv(wks,1);
        out_int("Lower bound before trimleft is: ",crv.GetLowerBound());
        crv.TrimLeft(); //FASLE will cause the lower bound or index to be adjusted upward but no cells are deleted. 
        out_int("Lower bound after trimleft is: ",crv.GetLowerBound());
    }
    return 0;
}

EX3

// Assumes Book1_A and Book1_B exist and contain data with some missing value in row1~3, and use them to plot a graph
int curvebase_TrimLeft_ex3(string dpName = "Graph1")
{
    GraphLayer    gl(dpName);               // Get active layer in project file
    if(gl)                                  // If valid graph layer...
    {
        DataPlot dp = gl.DataPlots(0);      // Get first data plot in graph layer
        if(dp)                              // If valid DataPlot...
        {
            Curve crv(dp);                  // Get Curve from DataPlot
            crv.TrimLeft(TRUE);
        }
    }
    return 0;
}

EX4

// Assumes Book1_A and Book1_B exist and contain data with some missing value in row1~3, and use them to plot a graph
int curvebase_TrimLeft_ex4(string dpName = "Graph1")
{
    GraphLayer    gl(dpName);               // Get active layer in project file
    if(gl)                                  // If valid graph layer...
    {
        DataPlot dp = gl.DataPlots(0);      // Get first data plot in graph layer
        if(dp)                              // If valid DataPlot...
        {
            Curve crv(dp);                  // Get Curve from DataPlot
            out_int("Lower bound before trimleft is: ",crv.GetLowerBound());
            crv.TrimLeft(); //FASLE will cause the lower bound or index to be adjusted upward but no cells are deleted. 
            out_int("Lower bound after trimleft is: ",crv.GetLowerBound());
        }
    }   
    return 0;
}

Remark

TrimLeft removes elements having the value NANUM from the left end or beginning of the Curve by advancing the lower index to the first valid numeric value. If bShiftLeft is TRUE cells containing NANUM are deleted from the Curve and a lower index value of 0 is returned shifting numeric values left to the beginning of the Curve. When bShiftLeft is TRUE TrimLeft of Curve objects causes both X and Y Datasets to be trimmed.

See Also

curvebase::TrimRight, vectorbase::GetLowerBound

Header to Include

origin.h