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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Copy selected columns across worksheets
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

drreaf

Germany
45 Posts

Posted - 03/31/2006 :  6:33:16 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): Pro 7.5 SR6
Operating System: Windows XP Professional

I beg every ones pardon because I must be blind.

Nevertheless, I cannot find a LAB TALK command to be executed say in the worksheet script of Data2 which allows me to copy selectively a column from worksheet data1 by column number (not by column name!) into a column of data2. I am sure there must be a straightforward command which however I have been unable to find such as e.g.:

Data2_C = col(column-No-I-of-data1);

Any pointers are greatly appreciated.

Rainer Facius (rainer.facius@dlr.de)


larry_lan

China
Posts

Posted - 03/31/2006 :  9:19:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi drreaf:

There is a chapter "Assigning Values to a Dataset" in the labtalk help file mentions that how to use col() function to specify a column of dataset:

----------------------------------------------------------------------------------------------------------------------
The col(colname) function can also be used to assign values to a dataset. Colname is the name or numerical position of a worksheet column. To use the col(colname) function:

the dataset must be associated with a worksheet

the worksheet must be the active window.
---------------------------------------------------------------------------------------------------------------------

So to do the assignment like

Data2_C = col(column-No-I-of-data1);

You can use the Copy command to accomplish this, while setting the source worksheet active:

copy col(column-No-I-of-data1) Data2_C;

Hope it help.


Larry
Originlab GZ Office

Go to Top of Page

drreaf

Germany
45 Posts

Posted - 04/01/2006 :  04:14:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:

Hi drreaf:

<snip>

You can use the Copy command to accomplish this, while setting the source worksheet active:

copy col(column-No-I-of-data1) Data2_C;

Hope it help.


Larry
Originlab GZ Office




Many thanks, Larry.

The first two copy commands in the script below indeed perform as desired.

Later, within the for() loop, I need to analyse in Data2 consecutively the remaining columns of Data1. This aborts with the message:
----------------------------------------------------------
Attention!
Can not copy, COL(COLNO) is not a dataset.
----------------------------------------------------------

How can this be done?
And, by the way, which system command/variable gives me the length of a dataset in case that it varies from column to column?

Rainer


{/*script in Data2*/

ZHLCP=11;/*Zahl der Spalten*/

window -a Data1;
copy col(1) Data2_A;
copy col(2) Data2_B;

for(jhlcp=2;jhlcp<ZHLCP;jhclp++)
{

colno=jhlcp+1;
window -a Data1;
copy col(colno) Data2_C;
/*

{analyse Data2_C together with 2_A and 2_B}

*/

}/*for jhlcp*/

}/*script Data2*/
Go to Top of Page

larry_lan

China
Posts

Posted - 04/01/2006 :  07:49:05 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Rainer:

1. When using the col(colname) function to specify a column, make sure that "colname" in col(colname) should be a string, that is, you should use $( ) substitution when there is a numeric variable, so your script can be changed into:

zhlcp=11;
for(jhlcp=2;jhlcp<ZHLCP;jhlcp++)
{
colon=jhlcp+1;
win -a Data1;
copy col($(colon)) Data2_C;
}

2. Length of datasets in a worksheet are the same and you can use

wks.nrows=

to see the maximum column rows.
I think you don't need to worry about the length of column since Origin can match the valid XY rows automatically for your analysis.


Larry
Originlab GZ Office

Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 04/01/2006 :  08:15:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Rainer,

1. The %(wksName,colNum) method of addressing columns works much better in your script because wksName need not be active...

ZHLCP=11;/*Zahl der Spalten*/

copy %(Data1,1) Data2_A;
copy %(Data1,2) Data2_B;

for(jhlcp=2;jhlcp<ZHLCP;jhclp++)
{

colno=jhlcp+1;
copy %(Data1,colno) Data2_C
/*

{analyse Data2_C together with 2_A and 2_B}

*/

}/*for jhlcp*/


2. wks.nrows is the number of rows in the wks but wks.maxrows is maximum number that are actually used. If your column lengths vary use this to find out the actual length of column colno...

get %(Data1,colno) -e npt; // assign column length to npt

Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 04/01/2006 08:19:27 AM
Go to Top of Page

drreaf

Germany
45 Posts

Posted - 04/01/2006 :  10:53:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello, Larry and Mike:

I tried both your suggestions and of course :-) both versions achieve what so far I attempted in vain.

How easy things look, once you know the proper syntax. I should have asked much earlier :-(.

Many thanks for your hints, Rainer



Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000