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
 Origin Forum
 copy paste with labtalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

contac

Chile
8 Posts

Posted - 02/06/2002 :  09:44:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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

Jose

Netherlands
93 Posts

Posted - 02/06/2002 :  1:03:01 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Have you tried option -e instead of -q for 'menu' command? That's what I use to paste, and it usually works.

Go to Top of Page

scottp

USA
60 Posts

Posted - 02/06/2002 :  3:15:53 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply

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;
};
Go to Top of Page

contac

Chile
8 Posts

Posted - 02/07/2002 :  12:23:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thank you for the solutions!
Contac
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