The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Copy Columns from one wks to another

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
origin_noob123 Posted - 12/02/2016 : 11:36:30 AM
In a Origin C script I return in a function a vector with the DataObject of a column like this:

Vector function1 (){

Worksheet wks;
...
something happens with wks...
...

Column col(wks, 1);
Vector vec = col.GetDataObject();

return vec;
}

I now want to add the Column which I used in function1 to a new Worksheet in function2 like this

bool function2 (){

Worksheet wks2;
wks2.Create(NULL, CREATE_VISIBLE);
...
...
Dataset dsNew = *function1();
dsNew.Attach(wks2, 1);

return true
}

and then i get the error, that the dereferenciation is not valid. But i thougt vec is a Vector to a Dataset-Object? However it gets even more confusing: If I delete the * and only write Dataset dsNew = function1(); there is no error and compiling works, but it
gives me no values in wks2. Just an empty worksheet without any values. But wks1 is full at the same time!

What did i get wrong about the datatypes in Origin C?
1   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 12/05/2016 : 02:36:20 AM
Hi,

I think the following example can help you figure out the relationship in column, vector and dataset.

void DatasetAndVector_ex1()
{
    Worksheet wks = Project.ActiveLayer();// The current worksheet must have one column prior to execution
    if(!wks) 
    return;	
		
    Column col1 = wks.Columns(0);// 1st column
    int nRows = col1.GetNumRows(); // get the number of rows in the first column, also the size of the vector below
    vector &vec = col1.GetDataObject();// Get data object
	
	
    Dataset ds;            // Create Origin C Dataset object not attached to an Origin data set 
    ds.Attach(wks,1);  // Attach Origin C Dataset object ds to Origin data set wks(1)
    ds.SetSize(nRows); 
    ds = vec; // Assign values to dataset from vector.
}

Further, I think you’d better go through the document about column, vector and dataset:
http://www.originlab.com/doc/OriginC/ref/Column-Class
http://www.originlab.com/doc/OriginC/ref/vector
http://www.originlab.com/doc/OriginC/ref/Dataset

Regards,
Yuki
OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000