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
 PointProc and Doc -e DY

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
CStorey Posted - 10/17/2001 : 12:26:05 PM
--> I've also sent this to tech support. But since it's a similar problem to perger's I thought I would post it here too.

Hello,

This is the first time I've tried to program the DoToolBox. I'm trying to write a script for Origin 6.1 that will allow the user to select the range over which to do a LR/fit to each curve in the graph. I've tried to do this with doc -e DY and dotool -dh 4. The problem is that the doc -e DY command does not wait for the execution of PointProc or EndToolBox. This cause problems with indices I'm using to record the results as well. I can insert a delay using sec -p X but this isn't acceptable as it doesn't always allow the markers to be moved (why?). Is there a way to do this properly??

Here's what I have tried ...

[RangeSelect]
type.redirection=1; // All "type" statements are printed to the 'Script Window'
system.debug=1; // Debugging is turned ON!

////// Create a Worksheet for the Output //////
win -t wks Origin WksXInt; // Create a new worksheet
%N=%H; // Remember worksheet name
wks.col1.format=2; // Set Colum A as Text
wks.col1.name$="Curve"; // Rename A to Dataset
wks.col2.name$="Xint";
wks.col1.width=20; // Widen to 2 chars

nmo=1; // Initialize Counter
win -a Graph1; win -z; // Makes "Graph1" active graph and Maximized!

#!type "Begining Linear Regression for X-intercept";

///// Loop over all the Datasets in all layers of Graph1 /////
doc -e DY {

type "Analysisc for %V";
dotool -dh 4; // Open the Data selector tool -dh -r -s

////// Macro that defines what to do after points are selected //////
def PointProc
{
%B=getpts.xData$;
%B[getpts.count]=x;
%B=getpts.indexData$;
%B[getpts.count]=index;
if (getpts.count>=getpts.max)
{
%V=%C; // Capture the Current Dataset name
{EndToolbox %V nmo}; // If points were selected then Run the EndToolBox Macro
doTool 0;
}
else
doTool -next;
};

////// Macro that defines LR analysis /////
def EndToolBox
{
// The index of the selections are stored in variables mks1, mks2
type "%2 Dataset: %1";
// Do LR over selected range!
lr -n %1 -b mks1 -e mks2; // Do LR over the range selected -b == BEGIN, -e==END and -n DO NOT draw a line
xintercept=-1*(lr.a)/(lr.b); // Calculate the x-intercept from y=mx+b --> y=(lr.b)x + lr.a , thus x(y=0)=-1*(lr.a)/(lr.b);
type " --> Slope = $(lr.b,%9.4g) +- $(lr.sdB,%9.4g)"; // %9.4g is C style formatting
type " --> Y-intercept = $(lr.a,%9.4g) +- $(lr.sda,%9.4g)";
type " --> Correlation R = $(lr.r,%9.4g)";
type " --> X-intercept = $(xintercept,%9.4g)";
%N_Curve[%2]$="%1"; // Record Dataset name
%N_Xint[%2]=xintercept; // Add x-intercept to worksheet
type " "; // Insert a blank line
};

nmo=nmo+1; // Increment counter

};

Return;

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring

Edited by - CStorey on 10/17/2001 12:59:25
2   L A T E S T    R E P L I E S    (Newest First)
Laurie Posted - 10/17/2001 : 5:50:30 PM
Hi Craig,

I also had some trouble using doc -e DY. What about using something like the following? It seems to work pretty well.

[main]

layer -c;
loop(ii,1,count)
{
%C=%[%Z,#ii];
run.section(,LRAnalysis);
}


[LRAnalysis]

type -b "Select the range of data for the fit.";

dotool 4;
def pointproc{
lr -n %C -b mks1 -e mks2;
type -a "Slope value is $(lr.b).";
type -a "Intercept value is $(lr.a).";
done=1;
dotool 0;
};
for(done=0;done==0; ) {
sec -p .05;
}



OriginLab Technical Support
CStorey Posted - 10/17/2001 : 2:11:43 PM
One more interesting problem.
If I use Doc -e inside the EndToolBox (which is not really what I want to do) then I get one extra curve in the loop that is not plotted in the graph. This extra curve is called "MARKER" it's easy to skip but maybe doc -e should not loop over this to begin with?

Craig Storey
Origin WebRing Member - http://nav.webring.yahoo.com/hub?ring=originwebring

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