Author |
Topic  |
|
kanderlee
Taiwan
Posts |
Posted - 11/20/2007 : 02:28:26 AM
|
Origin Version (Select Help-->About Origin): 7.5 SR6 Operating System:XPP
I use this code to get the range of the data which I want to process.
dotool 4;
def pointproc {
py = %C[mks1];
%A = xof(%C);
px = %A[mks1];
type -a Left marker is at index $(mks1), X is $(px),Y is $(py);
py = %C[mks2];
%A = xof(%C);
px = %A[mks2];
type -a Right marker is at index $(mks2), X is $(px),Y is $(py);
dotool 0;
};
But I want to send the index value ( mks1 & mks2 ) to Origin C for setting boundary, How can I do? Thank for helping me.
Edited by - kanderlee on 11/22/2007 10:21:52 PM |
|
Mike Buess
USA
3037 Posts |
Posted - 11/20/2007 : 08:32:38 AM
|
Use LT_get_var...
double dMks1; LT_get_var("mks1",&dMks1); out_int("mks1=",(int) dMks1);
Mike Buess Origin WebRing Member |
 |
|
kanderlee
Taiwan
Posts |
Posted - 11/21/2007 : 03:40:09 AM
|
Hi, Mike,
I have two questions to ask you. ^^"
I've got "mks1" & "mks2" from LabTalk, and then used LT_get_var to get value to set column's boundary. double dMks1; double dMks2; LT_get_var("mks1",&dMks1); LT_get_var("mks2",&dMks2);
wks.SetLowerBound(dMks1); wks.SetUpperBound(dMks2);
Before I use these two codes, all columns in wks are filling numbers. After using these codes, all numbers are gone! What happened? Please tell me! Thank you.
The other question is that I want add some code in the LabTalk section (in my previous post, dotool 4)to wait users to use "Data Selector" setting mks1 & mks2, and then transfer these two numbers to Origin C to set column's bound in wks. What codes should I add?
I'd appreciate your help.
quote:
Use LT_get_var...
double dMks1; LT_get_var("mks1",&dMks1); out_int("mks1=",(int) dMks1);
Mike Buess Origin WebRing Member
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 11/21/2007 : 08:54:04 AM
|
quote: Before I use these two codes, all columns in wks are filling numbers. After using these codes, all numbers are gone! What happened?
The values of Mks1 and Mks2 depend on which window is active. If a worksheet with no selections is active then mks1=mks2=0.
quote: The other question is that I want add some code in the LabTalk section (in my previous post, dotool 4)to wait users to use "Data Selector" setting mks1 & mks2, and then transfer these two numbers to Origin C to set column's bound in wks. What codes should I add?
Don't know what the rest of your code looks like but you probably need to activate the graph window to get the data selection markers mks1&mks2 and apply them to the worksheet as you have already done. That should not be too difficult so I'll let you work out the details. Just remember that mks1 & mks2 are LabTalk indices that start with 1 while Origin C indices start with 0. So you'll need to use LT_get_var like this...
double dMks1; LT_get_var("mks1",&dMks1); int iMks1 = dMks1 - 1; // this is the Origin C index
Mike Buess Origin WebRing Member |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 11/21/2007 : 12:10:00 PM
|
Two more comments...
1. If you call your Origin C function from the pointproc macro you might as well pass the marker indices as arguments...
dotool 4; def pointproc { dotool 0; SetBounds(mks1,mks2); };
void SetBounds(int mks1, int mks2) { GraphLayer gl = Project.ActiveLayer(); DataPlot dp = gl.DataPlots(-1); // active dataplot string sWks = dp.GetDatasetName().GetToken(0,'_'); // wks name Worksheet wks(sWks); wks.SetRange(mks1-1,mks2-1); }
2. It's easier to accomplish this task entirely in LabTalk...
dotool 4; def pointproc { dotool 0; %W=%[%C,#1,_]; // wks name set %W -e mks2; set %W -b mks1; };
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 11/21/2007 12:10:58 PM |
 |
|
kanderlee
Taiwan
Posts |
Posted - 11/21/2007 : 8:22:56 PM
|
Sorry to disturb you again....^^"
I want to copy a part of worksheet to a new worksheet. The range of the source worksheet will be defined by mks1 & mks2. After the copying, the destination worksheet will show the part of data from the source worksheet without other unecessary blanks. It is the proper function that I really need to use mks1 and mks2. Please give me a hint. Thank you. |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 11/21/2007 : 11:29:49 PM
|
If you want to do it from the pointproc macro then a LabTalk solution is once again easiest...
dotool 4; def pointproc { dotool 0; i1=mks1; i2=mks2; win -a %[%C,#1,_]; // activate worksheet work -d; // duplicate worksheet set %H -er i2; // delete extra rows at the end mark -d col(1) -b 1 -e (i1-1); // delete extra rows at the beginning };
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 11/22/2007 09:56:54 AM |
 |
|
kanderlee
Taiwan
Posts |
Posted - 11/22/2007 : 04:10:12 AM
|
Thank you, Mike.
I've found a problem in my code.
I used LT_get_var to get msk1 & mks2 value from LabTalk, but it didn't contain the correct value that I set. (I've checked the variable' values by the debugger of Origin C.)
If I set range by data selector before running the code, Could I also get mks1 and mks2 and use them in my Origin C code?
What should I know to use LT_get_var to get mks1 & mks2?
Thank a lot. |
 |
|
Mike Buess
USA
3037 Posts |
Posted - 11/22/2007 : 09:07:59 AM
|
You are probably reading dMks1 as an integer which will give you the wrong value since it is a double. You need to force as an integer as I did originally...
double dMks1; LT_get_var("mks1",&dMks1); int iMks1 = dMks1 - 1; // change to C-index needed in all OC calculations out_int("mks1=",iMks1); // that will show the correct mks1-1
...Also, are you remembering to get the marker indices while the graph window is active?
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 11/22/2007 09:10:05 AM
Edited by - Mike Buess on 11/22/2007 09:35:28 AM |
 |
|
kanderlee
Taiwan
Posts |
Posted - 11/22/2007 : 10:05:06 PM
|
Hi, Mike,
I've solved the problem. Thank for your suggestion....^_^
I got another question to ask you...^_^"
The "Curve_integrate" can do integration from curve, and the result can be extracted by several variables:xPeak, yPeak, Area. (those variables' names I've got are from Origin offical examples in their website.)
http://www.originlab.com/pdfs/programming/IntegrateColumnsAndCreateReport.pdf
But the result contains "Width" when I use the integrating function from the pull-dowm menu of Origin main program.
What name of variable represents the result "Width" of the integration?
quote:
You are probably reading dMks1 as an integer which will give you the wrong value since it is a double. You need to force as an integer as I did originally...
double dMks1; LT_get_var("mks1",&dMks1); int iMks1 = dMks1 - 1; // change to C-index needed in all OC calculations out_int("mks1=",iMks1); // that will show the correct mks1-1
...Also, are you remembering to get the marker indices while the graph window is active?
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 11/22/2007 09:10:05 AM
Edited by - Mike Buess on 11/22/2007 09:35:28 AM
|
 |
|
Mike Buess
USA
3037 Posts |
Posted - 11/22/2007 : 10:58:07 PM
|
The menu command uses LabTalk's Integrate but a similar width property is in the IntegrationResult structure of OC's Curve_integrate. If you read the Curve_integrate topic in the programming guide you'll find that structure is defined in OC_types.h.
Mike Buess Origin WebRing Member |
 |
|
|
Topic  |
|