📄 vector.h
字号:
}
Dataset dsB(dsA); // Generates a temporary dataset of size 3 having values 1,2,3
}
Parameters:
dsOriginal=Origin C Dataset object to copy
*/
Dataset(Dataset dsOriginal); // Copy constructor for Dataset class.
/**
Constructor to create an Origin C Dataset object and attach it to an Origin
worksheet column. An Origin C worksheet object and worksheet column number
are passed as arguments. Please note Origin C column numbers are 0 based
offsets while internal Origin column numbers are 1 based offsets.
Example:
// Worksheet columns Data1_A and Data1_B must exist prior to execution
Worksheet wksW("Data1"); // Create an Origin C Worksheet object attached to the Origin worksheet Data1
Dataset dsB(wksW,1); // Create an Origin C Dataset object attached to an Origin data set
// contained in column 2 of the Origin worksheet Data1
dsB.SetSize(5);
dsB = 4;
Parameters:
wks=Origin C worksheet object attached to an Origin worksheet
nCol=Origin C column number to attach to (nCol=1 attaches to second column in Origin worksheet)
SeeAlso:
Worksheet::Worksheet, Dataset::Attach, Dataset::Detach
*/
Dataset(Worksheet &wks, int nCol); // Constructor to create a Dataset from worksheet object and column number.
/**
Constructor to create an Origin C Dataset object from an Origin C Column object.
Example:
// Worksheet columns Data1_A and Data1_B must exist prior to execution
Column colB("Data1",1); // Create an Origin C Column object attached to the second column
// in the Origin worksheet Data1
Dataset dsB(colB); // Create an Origin C Dataset object attached to the data set
// contained in column 2 of the Origin worksheet Data1
dsB.SetSize(5);
dsB = 5;
Parameters:
col=Origin C column object attached to an Origin worksheet column
SeeAlso:
Column::Column, Dataset::Attach, Dataset::Detach
*/
Dataset(Column & col); // Constructor to create a Dataset from a Column object.
/**
Attach an Origin C Dataset object to an internal Origin data set whose
name is passed as an argument. Origin C Dataset objects must be attached
to internal Origin data sets either by constructor or by the Attach method.
Example:
// Worksheet columns Data1_A and Data1_B must exist prior to execution
Dataset ds1; // Create unattached Dataset object
if(ds1.Attach("Data1_A")) // Attach Dataset object to Origin data set Data1_A
{
ds1.SetSize(10);
for(int ii = 0; ii < 10; ii++)
ds1[ii] = ii;
}
if(ds1.Attach("Data1_B")) // Attaching to different dataset detaches from previous dataset
{ // and attaches to new one
ds1.SetSize(10);
for(int ii = 0; ii < 10; ii++)
ds1[ii] = -ii;
}
Parameters:
lpcszDatasetName=Name of Origin data set to attach to
Return:
Returns TRUE on successful exit and FALSE on error.
SeeAlso:
Dataset::Dataset, Dataset::Detach
*/
BOOL Attach(LPCSTR lpcszDatasetName); // Attach Dataset object to an Origin data set identified by name.
/**
Attach an Origin C Dataset object to an Origin worksheet column.
Origin worksheet name and column number are passed as arguments. Please
note Origin C column numbers are 0 based offsets while internal Origin
column numbers are 1 based offsets. Origin C Dataset objects must be attached
to internal Origin data sets either by constructor or by the Attach method.
Example:
// Worksheet columns Data1_A and Data1_B must exist prior to execution
Dataset ds1; // Create unattached Dataset object
if(ds1.Attach("Data1",0)) // Attach Dataset object to first column in Data1 worksheet
{
ds1.SetSize(10);
for(int ii = 0; ii < 10; ii++)
ds1[ii] = ii;
}
if(ds1.Attach("Data1",1)) // Attaching to different dataset detaches from previous dataset
{ // and attaches to new one
ds1.SetSize(10);
for(int ii = 0; ii < 10; ii++)
ds1[ii] = -ii;
}
Parameters:
lpcszWksName=Name of worksheet in which column resides
nCol=Origin C column number to attach to (nCol=1 attaches to second column in worksheet)
Return:
Returns TRUE on successful exit and FALSE on error.
SeeAlso:
Dataset::Dataset, Dataset::Detach
*/
BOOL Attach(LPCSTR lpcszWksName, int nCol); // Attach a Dataset object a worksheet column identified by worksheet name and column number.
/**
Attach an Origin C Dataset object to an Origin worksheet column.
An Origin C Worksheet object and column number are passed as arguments.
Please note Origin C column numbers are 0 based offsets while internal
Origin column numbers are 1 based offsets. Origin C Dataset objects must
be attached to internal Origin data sets either by constructor or by
the Attach method.
Example:
// Worksheet columns Data1_A and Data1_B must exist prior to execution
Worksheet wksW("Data1"); // Create Origin C Worksheet object and attach to Origin Data1 worksheet
Dataset ds1; // Create unattached Dataset object
ds1.Attach(wksW,0); // Attach Dataset object to first column in Data1 worksheet
ds1.Attach(wksW,1); // Attaching to different data set detaches from previous data set
// and attaches to new one
Parameters:
wks=Origin C worksheet object attached to an Origin worksheet
nCol=Origin C column number to attach to (nCol=1 attaches to second column in worksheet)
Return:
Returns TRUE on successful exit and FALSE on error.
SeeAlso:
Worksheet::Worksheet, Dataset::Dataset, Dataset::Detach
*/
BOOL Attach(Worksheet &wks, int nCol); // Attach a Dataset object to a worksheet column identified by Worksheet object and column number.
/**
Attach an Origin C Dataset object to an Origin worksheet column
identified by an Origin C Column object. Origin C Dataset objects
must be attached to internal Origin data sets either by constructor
or by the Attach method.
Example:
// Worksheet columns Data1_A and Data1_B must exist prior to execution
Column colB("Data1",1); // Create an Origin C Column object attached to the second column
// in the Origin worksheet Data1
Dataset ds1; // Create unattached Dataset object
ds1.Attach(colB); // Attach Dataset object to first column in Data1 worksheet
Parameters:
col=Origin C column object attached to an Origin worksheet column
Return:
Returns TRUE on successful exit and FALSE on error.
SeeAlso:
Column::Column, Dataset::Dataset, Dataset::Detach
*/
BOOL Attach(Column & col); // Attach a Dataset object to a worksheet column identified by a Column object.
/**
Create a temporary (or permanent) Origin data set and attach the
Dataset object to it. If Option=1 is specified and data set is not
destroyed by calling the Dataset::Destroy method the data set will
remain in Origin after the Origin C function completes execution.
Example:
int ii;
{
LT_execute("list s;");
Dataset ds0;
ds0.Create(3); // Size=3 & Option=0 by default (create and attach to temporary data set)
for(ii = 0; ii < 3; ii++)
ds0[ii] = ii;
LT_execute("list s;"); // Note new ds0 TEMP_ data set
}
LT_execute("list s;"); // Out of ds0's scope, note new ds0 TEMP_ data set is destroyed
Dataset ds1;
ds1.Create(3,1); // Size=3 & Option=1 (create and attach to a second data set that is not temporary)
for(ii = 0; ii < 3; ii++)
ds1[ii] = ii;
LT_execute("list s;"); // Note new ds1 TEMP_ data set
ds1.Destroy(); // Destroy ds1 TEMP_ data set (comment out this line and TEMP_ data set does not get deleted)
LT_execute("list s;"); // Note new ds1 TEMP_ data set is destroyed (or not if above line is commented out)
Parameters:
Size=Size of the data set
Option=0 (default) causes temporary Origin data set to be automatically deleted when program control exits scope
of Dataset object, Option=1 causes data set to not be deleted unless user calls Dataset::Destroy method
Return:
Returns TRUE on successful exit and FALSE on error.
SeeAlso:
Dataset::Destroy, Dataset::Detach, Dataset::Dataset, Dataset::Attach
*/
BOOL Create(int Size, UINT Option = 0); // Create an internal Origin data set (may or may not be temporary).
/**
Delete (destroy) an Origin data set created using the Dataset::Create
method. For data sets not created by the Dataset::Create method the
Destroy method functions identically to the Dataset::Detach method.
Example:
// Worksheet column Data1_A must exist prior to execution
int ii;
Dataset ds1;
ds1.Create(3,1); // Create data set with Size=3 & Option=1 (not a temporary data set)
for(ii = 0; ii < 3; ii++)
ds1[ii] = ii;
LT_execute("list s;"); // Note new ds1 TEMP_ data set
ds1.Destroy(); // Destroy ds1 TEMP_ data set
LT_execute("list s;"); // Note new ds1 TEMP_ data set is destroyed
Dataset ds2("Data1_A"); // Construct and attach to pre-existing Origin data set
ds2.Destroy(); // Detaches ds2 from Data1_A but does not delete pre-existing data set from Origin
LT_execute("list s;"); // Note ds2 is an Invalid Object but Data1_A still exists
SeeAlso:
Dataset::Detach, Dataset::Attach, Dataset::Create
*/
void Destroy(); // Detach the Origin C Dataset object and Destroy (delete) the internal Origin data set.
/**
Detach an Origin C Dataset object from an internal Origin data set. The
Dataset object can only be attached to one internal Origin data set at
a time but it may be sequentially detached and re-attached as many times
as desired.
Example:
// Worksheet columns Data1_A and Data1_ B must exist prior to execution
Dataset dsD("Data1_A"); // Attach to Origin data set Data1_A
vector vV(dsD); // Copy Data1_A data set to vector
dsD.Detach(); // Explicitly Detach dsD from Data1_A
dsD.Attach("Data1_B"); // Now Attach dsD to Data1_B
dsD = vV; // Copy vector to data set Data1_B
dsD.Detach(); // Detach dsD from Data1_B
Return:
Returns TRUE on successful exit and FALSE on error.
SeeAlso:
Dataset::Destroy, Dataset::Attach, Dataset::Create
*/
BOOL Detach(); // Detach the Dataset object from an internal Origin data set.
/**
Set the text value of a cell in an Origin data set. The Origin data set
must be of type Text & Numeric.
Example:
string strTextVal;
// Worksheet column Data1_A must exist prior to execution and must have a column type of Text & Numeric
Dataset dsTextA("Data1_A"); // Attach to data set
dsTextA.SetSize(3);
for(int ii = 0; ii < 3; ii++) // For rows 0 to 2...
{
strTextVal.Format("Row %d",ii); // Format text value
dsTextA.SetText(ii,strTextVal); // Set text value of row ii
}
Parameters:
nRow=Row number (O based offset) of an Origin data set whose text value is to be set
lpcszTextValue=Text value to set
Return:
Returns TRUE on successful exit and FALSE on failure.
SeeAlso:
Dataset::GetText, Worksheet::SetCell, Worksheet::GetCell, Worksheet::Cell, Worksheet::TCell
*/
BOOL SetText(int nRow, LPCSTR lpcszTextValue); // Set the text value of a cell in an Origin data set of type Text & Numeric.
/**
Get the text value of a cell in an Origin data set. The Origin data set must
be of type Text & Numeric.
Example:
string strTextVal;
// Worksheet columns Data1_A and Data1_B must exist prior to execution and must have a column type of Text & Numeric
LT_execute("Data1_A[1]$=Row 0;"); // Use LabTalk to initialize text values
LT_execute("Data1_A[2]$=Row 1;"); // LabTalk row numbers use 1 based offset
LT_execute("Data1_A[3]$=Row 2;");
Dataset dsTextA("Data1_A");
dsTextA.SetSize(3);
Dataset dsTextB("Data1_B");
dsTextB.SetSize(3);
for(int ii = 0; ii < 3; ii++) // Origin C row numbers use 0 based offset
{
dsTextA.GetText(ii,strTextVal); // Get text value in column A
dsTextB.SetText(ii,strTextVal); // Set text value in column B
}
Parameters:
nRow=Row number (O based offset) of an Origin data set whose text value is returned
strTextVal=Returned text value
Return:
Returns TRUE on successful exit and FALSE on failure.
SeeAlso:
Dataset::SetText, Worksheet::GetCell, Worksheet::SetCell, Worksheet::Cell, Worksheet::TCell
*/
BOOL GetText(int nRow, string& strTextVal); // Get the text value of a cell in an Origin data set of type Text & Numeric.
/**
Get the contents (from row nRow1 to nRow2) of a Text Dataset and copy the elements into a
StringArray.
Example:
// This test function assumes a Data1 worksheet with columns A, B, and C
// Column A should have some number of text entries
StringArray sa1, sa2, sa3;
BOOL bRet;
Dataset ds1("Data1_A");
Dataset ds2("Data1_B");
Dataset ds3("Data1_C");
bRet = ds1.GetStringArray(sa1, 2, 5);
bRet = ds1.GetStringArray(sa2);
bRet = ds2.PutStringArray(sa1, 3);
bRet = ds3.PutStringArray(sa2);
Parameters:
as=Output StringArray
nRow1=Input starting row number, default 0
nRow2=Input ending row number, default -1 means to upper bound of Dataset
Return:
Returns TRUE on successful exit and FALSE on failure.
SeeAlso:
Dataset::PutStringArray
*/
BOOL GetStringArray(vector<string>& as, int nRow1=0, int nRow2=-1); // Copy the contents of a Text Dataset into a StringArray.
/**
Put (copy) the contents of a StringArray to a Text Dataset starting in row nRow1
of the destination Dataset.
Example:
// This test function assumes a Data1 worksheet with columns A, B, and C
// Column A should have some number of text entries
StringArray sa1, sa2, sa3;
BOOL bRet;
Dataset ds1("Data1_A");
Dataset ds2("Data1_B");
Dataset ds3("Data1_C");
bRet = ds1.GetStringArray(sa1, 2, 5);
bRet = ds1.GetStringArray(sa2);
bRet = ds2.PutStringArray(sa2, 3);
bRet = ds3.PutStringArray(sa2);
Parameters:
as=Input StringArray to copy
nRow1=Input starting row number of destination Dataset
Return:
Returns TRUE on successful exit and FALSE on failure.
SeeAlso:
Dataset::GetStringArray
*/
BOOL PutStringArray(vector<string>& as, int nRow1=0); // Put (copy) the contents of a StringArray to a Text Dataset.
/**
Set the upper display index of the Dataset range. Index values are 0 based
offsets so use SetUpperBo
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -