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
 How to use getpts in scripts?

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
Andreas Bausewein Posted - 04/27/2000 : 8:33:00 PM
Hi,

I try to write a script, which copies data selected with the data reader (uses command "getpts") in a own worksheet. Running the script line for line form the script window, it works fine. However running the script as whole, you have no possibility to select data with the data reader, while lines after the getpts command are executed. What is to do that the script waits at the getpts command for the users data selection?

Andreas

Some lines of the script:

getpts npoints; /*npoints to select from a graph*/

win -a %q; /*activates an exisiting worksheet with coloumns index and time*/
%q_index=_indx;
%q_time=_xpos;

6   L A T E S T    R E P L I E S    (Newest First)
aeolian1 Posted - 10/25/2013 : 09:33:22 AM
I think I may have solved the problem (of the script's barreling ahead without allowing me to select points) by combining various bits from

http://wiki.originlab.com/~originla/ltwiki/index.php?title=Script:Getting_Points_from_Graph&rdfrom=http%3A%2F%2Fwiki.originlab.com%2F~originla%2Fwiki%2Findex.php%3Ftitle%3DScript%3AGetting_Points_from_Graph%26redirect%3Dno

The script becomes:

@global = 1;
dataset dsx, dsy; // Create two datasets to hold the X and Y values

dotool 3; // Start the tool
// Define the macro that runs for each point selection
def pointproc {
count++; // Increment count;
din[count] = index;
dsx[count] = x; // Get the X coordinate
dsy[count] = y; // Get the Y coordinate;
}

// Define a macro that runs if user presses Esc key,
// or clicks the Pointer Tool:
def quittoolbox {
count=;
for(int ii=1; ii<=count; ii++)
{
type $(ii), $(din[ii]), $(dsx[ii]), $(dsy[ii]);
};
done = 1; // Set the variable to allow infinite loop to end
}
count = 0; // Initial point;
for( done = 0 ; done == 0; ) sec -p .1;
aeolian1 Posted - 10/23/2013 : 05:05:14 AM
Hi Laurie,

I tried incorporating your code, but still have the same problem as Andreas. That is, I can select points successfully using the Data Reader if I run the script in small chunks, but if I try to run the whole code, I don't get an opportunity to select points (the script barrels ahead without even showing me the plot). This is a serious problem, as I ultimately want to put the code portion involving the Data Reader in a loop that will cycle roughly 50 times.

I would be grateful for any help! Thank you.

Part of the script (it operates on an existing worksheet that contains at least 6 columns):

work -d data1;
work -t 1 2; // set column 1 to "disregard"
work -t 5 4; // set column 5 to "X"

numrows = wks.maxRows;
type $("total points:"), $(numrows);
numper = 1+int((numrows-68)/69);
type $("total number of periods:"), $(numper);

// analyze file contents
dataset startcheck={5:69:5+(numper-1)*69};
start=startcheck;
lengthon=startcheck;
lengthoff=startcheck;
ind = 1;
for(int jj=4; jj<=numrows-10; jj++)
{
if (isna(col(6)[jj]))
{
if (isna(col(6)[jj+1])==0)
{
start[ind]=jj+1; // row # of cycle start
ind=ind+1;
lengthon[ind]=32;// holds # pts. in ON cycle
lengthoff[ind]=32;// holds # pts. in OFF cycle
}
}
}
numrows=start[start.getsize()]+63;//last row with deltaT data

periodnum = 3;
work -s 5 start[periodnum] 6 start[periodnum]+63;
work -p 202 standard; //plot
window -z; // maximize the window

dataset din, dsx, dsy; // Create two datasets to hold the X and Y values
dotool 3; // Start the tool
// Define the macro that runs for each point selection
def pointproc {
count++; // Increment count;
din[count] = index; // Get the X coordinate
dsx[count] = x; // Get the X coordinate
dsy[count] = y; // Get the Y coordinate
}

// Define a macro that runs if user presses Esc key,
// or clicks the Pointer Tool:
def quittoolbox {
count=;
for(int ii=1; ii<=count; ii++)
{
type $(ii), $(din[ii]), $(dsx[ii]), $(dsy[ii]);
}
}
count = 0; // Initial point;

type "Click to select point, then press Enter";
type "Press Esc or click on Pointer tool to stop";

// now remove the points from the worksheet (and graph)
win -a data1;

for(int ii=count; ii>=1; ii--)
{
worksheet -s 1 din[ii] wks.nCols din[ii]; // highlight the row
menu -e 36442; // now delete it
numrows = numrows-1;
if (din[ii]-start[periodnum]<=31)
{lengthon[periodnum]=lengthon[periodnum]-1};
else
{lengthoff[periodnum]=lengthoff[periodnum]-1};
}
for(int kk=periodnum+1; kk<=numper; kk++)
{
start[kk]=start[kk]-count;
}

[the curve-fitting portion will go here]

P.S. I am using OriginPro 8.5.1.
Laurie Posted - 06/16/2009 : 3:39:03 PM
The code below should work nicely for you:

dataset dsx, dsy;  // Create two datasets to hold the X and Y values

dotool 3;          // Start the tool

// Define the macro that runs for each point selection

def pointproc {

    count++;         // Increment count

    dsx[count] = x;  // Get the X coordinate

    dsy[count] = y;  // Get the Y coordinate

}

// Define a macro that runs if user presses Esc key, 

// or clicks the Pointer Tool:

def quittoolbox {

   count=;

   for(int ii=1; ii<=count; ii++)

   {

      type $(ii), $(dsx[ii]), $(dsy[ii]);

   }

}

count = 0;  // Initial point

Type "Click to select point, then press Enter";

Type "Press Esc or click on Pointer tool to stop";


OriginLab Technical Support
Laurie Posted - 06/16/2009 : 3:00:04 PM
Yes, it is possible. Try the code for the Data Reader here.

You just want to take out the check of number of points:
if(count == 4) dotool 0;

You don't want to use "dotool 0". Esc will return you automatically to the pointer tool. The code that you want to run after you hit Esc, should be defined in the Quittoolbox macro.

OriginLab Technical Support
thiago.maf Posted - 06/12/2009 : 10:23:08 PM
Guys... I've tried but I can't do it.

I need to take a lots o points (I don't know how many. Is it possible to use a button or Esc to exit data aquisition?) and copy X and Y values to a new Worksheet.

I've already visit those links.

Thanks
rtoomey Posted - 05/01/2000 : 3:48:00 PM

In order for a selection from the getpts command to register while you are in the getpts activity, you must place your script into a macro (such as PointProc) which is used by the getpts command. To better understand this, I suggest you take a look at the Technical Review article entitled "Using the Getpts Command and Running a Script". Furthermore, below is an example of how your script might be incorporated into the format described in the aforementioned Technical Review.


EXAMPLE SCRIPT

%q=data1; /*store the name of the worksheet to assign my values to*/

getpts 2; /*2 points to select from a graph*/

def PointProc
{
   %q_index[getpts.count]=x; /*assign each successive x value to a row in index column*/
   %q_time[getpts.count]=y;/*assign each successive y value to a row in time column*/
   if (getpts.count>=getpts.max)
   {
       type end toolbox;

      {EndToolbox};/*end getpts if count is exceeded - 2 in this case*/
      doTool 0;
    }
  else
     doTool -next;
};

I hope that this information proves helpful.


Sincerely,
Ryan Toomey


[This message has been edited by rtoomey (edited 05-01-2000).]


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