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
 Origin Forum
 copy paste with labtalk

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
contac Posted - 02/06/2002 : 09:44:13 AM
I've a selection in a worksheet. I want to copy and paste transpose into another. Can I do it without using the menu -q xxxxx command? I've have problems with that commands, and I'd like to know if there is a different way to do the same thing
3   L A T E S T    R E P L I E S    (Newest First)
contac Posted - 02/07/2002 : 12:23:38 PM
thank you for the solutions!
Contac
scottp Posted - 02/06/2002 : 3:15:53 PM

The best method to move selected data from one worksheet to another is to first select the data in the active worksheet using the Worksheet command. The format is:

Work -s c1 r1 c2 r2

Set the specified range to be the current worksheet selection. To select entire columns, set r1 and r2 to zero. To select entire rows, set c1 and c2 to zero.

For the purpose of this example I imported Test4.dat into a worksheet, from the Origin Tutorial folder. This created a four column worksheet called Test4. I want to now select Rows 1-5 in columns 2, 3, and 4. I will use the LabTalk command " Work -s 2 1 4 5;". As you execute this command you will see the appropriate data in the worksheet highlighted.

Next I need to copy the data to the Windows clipboard. I will do this with a Domenu command. The Domenu ID's will sometimes change between Origin versions. First you must open the Script Window. To retrieve the Menu ID for copying to the clipboard, for your specific version of Origin, you need to hold down the Shift and Ctrl keys simultaneously, while you click on the Origin Menu item Edit: Copy. You will see an entry in the Script Window similar to this…

Menu id=57634

This is the menu id number for Copying to the Windows Clipboard.

To find the Menu id for pasting from the clipboard I will follow the same procedures as above but instead select Edit: Paste. This will return to the Script window:

Menu id=57637

This is the menu id number for Pasting from the Windows Clipboard.

You will also need to obtain the Menu Id to transpose the worksheet. The menu item is found under the Origin Menu Edit: Transpose. In Origin 6.1 the Menu id is 36466.

I now have the information I need to create a LabTalk script to move the selected data from one worksheet to another.

I will also need to create a blank worksheet called Test4A. To do this I will use the LabTalk command "win -T data origin Test4A;"

Now it is time to put this all together.


Win -a test4; //Makes the Test4 worksheet the active window
Work -s 2 1 4 5; //Selects rows 1-5 in Columns 3, 4 and 5
Domenu 57634; //Places the selected data on the Windows Clipboard
win -T data origin Test4A; //Creates a new worksheet from the Origin template with the name Test4A
Work -s 1 1 1 1; //Selects the upper left cell of the new worksheet
Domenu 57637; //Pastes the data from the Windows clipboard into the new worksheet
Queue{work -s; // The Queue command allows Windows time to paste the data into Origin
Domenu 36466;} //Work -s will clear the selected cell in the worksheet. Otherwise an attention
//box will appear warning about limitations of the worksheet transpose when cells are selected in the worksheet.

The example above is the easiest to understand and is fairly straightforward. It is possible to bypass the use of the domenu command but we must instead loop through the available data and use the WKS worksheet object. I have included the LabTalk script below.

In either of the examples, if you wish you can delete the first two lines of the script. This will allow you to manually select the data from the active worksheet using the mouse to drag across the relevant data.


Win -a test4; //Makes the Test4 worksheet the active window
Work -s 2 1 4 5; //Selects rows 1-5 in Columns 3, 4 and 5
%W=%H;
nrows=wks.r2-wks.r1-1;
ncols=wks.c2-wks.c1+1;
win -t data origin;
worksheet -a nrows;
set %h_a -e ncols;
for(jj=%W!wks.r1,kk=1;jj<=%W!wks.r2;jj++,kk++)
{
for(ii=%W!wks.c1,ll=1;ii<=%W!wks.c2;ii++,ll++)
{
%(%H,kk,ll)=%(%W,ii,jj);
}
}
delete -v nrows;

Finally, you can use the following to add an entry to the Analysis Menu.


menu -w;
menu 6;
menu;
menu (Trans&pose) {
%W=%H;
nrows=wks.r2-wks.r1-1;
ncols=wks.c2-wks.c1+1;
win -t data origin;
worksheet -a nrows;
set %h_a -e ncols;
for(jj=%W!wks.r1,kk=1;jj<=%W!wks.r2;jj++,kk++) {
for(ii=%W!wks.c1,ll=1;ii<=%W!wks.c2;ii++,ll++) {
%(%H,kk,ll)=%(%W,ii,jj);
};
};
delete -v nrows;
};
Jose Posted - 02/06/2002 : 1:03:01 PM
Have you tried option -e instead of -q for 'menu' command? That's what I use to paste, and it usually works.


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