2.1.17.2.2.8 GetDatasetXFromStep


Description

get dataset From and Step values that are used for plotting with Row# as X

Syntax

BOOL GetDatasetXFromStep( LPCSTR lpcszDatasetName, double * lpdbFrom, double * lpdbStep )

Parameters

lpcszDatasetName
[input] Dataset name
lpdbFrom
[output] plotting X from
lpdbStep
[output] plotting X increment

Return

Returns TRUE if the given dataset is a valid dataset and it is in a worksheet with no X column, or is a loose dataset, so the From/Step values are available,

Examples

EX1

// This is a self contained sample program for the function GetDatasetXFromStep, 
// Its sample data is created at the beginning of the program. 
// To run the program, enter the following command in the Script window:
//   GetDatasetXFromStep_ex1
// It returns like:
//   GetDatasetXFromStep succeeded as Data2_A has no X column. From=1 Step=1

void GetDatasetXFromStep_ex1()
{
    double dbFrom, dbStep;
    string lpcszDatasetName;
    BOOL rc;

    Worksheet wks;
    wks.Create();
    Dataset myADs(wks,0);
    
    //******* Create sample data *****************
    myADs.SetSize(5);
    myADs[0]=1;
    myADs[1]=2;
    myADs[2]=4;
    myADs[3]=8;
    myADs[4]=16;
    //******** End of Sample Data Creation *******
    Column aa = wks.Columns(0);
    aa.SetType(OKDATAOBJ_DESIGNATION_Y); // Sets A as a Y dataset
    wks.SetEvenSampling(-1, 0.2, aa); // Set Sample Rate as 0.2 X increment with first X value of -1
    lpcszDatasetName = myADs.GetName();

    // Create a new graph page and its layer from the datset
    Curve crv1(wks, 0);
    GraphPage gpg;
    gpg.Create("mGPage");
    GraphLayer gly1 = gpg.Layers(0);
    gly1.AddPlot(crv1);
    gly1.Rescale();
    
    // The graph page is now in the active window
    rc = GetDatasetXFromStep(lpcszDatasetName, &dbFrom, &dbStep);
    if(rc)
        printf("GetDatasetXFromStep succeeded as %s has no X column. From=%g Step=%g\n", 
        lpcszDatasetName, dbFrom, dbStep);
    else 
        printf("GetDatasetXFromStep Failed\n");
}

Remark

The function used for fitting function parameter initialization.

See Also

Header to Include

origin.h

Reference