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
 LabTalk Forum
 Copy selected columns across worksheets

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
drreaf Posted - 03/31/2006 : 6:33:16 PM
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)


5   L A T E S T    R E P L I E S    (Newest First)
drreaf Posted - 04/01/2006 : 10:53:33 AM
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



Mike Buess Posted - 04/01/2006 : 08:15:28 AM
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
larry_lan Posted - 04/01/2006 : 07:49:05 AM
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

drreaf Posted - 04/01/2006 : 04:14:20 AM
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*/
larry_lan Posted - 03/31/2006 : 9:19:28 PM
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


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