| T O P I C R E V I E W |
| jeff46 |
Posted - 05/24/2004 : 09:08:51 AM I program a buton in Labtalk for apply "Analysis"->"Extract Worksheet Data" the worsheet script is: menu -e 36496;
but I can't put a name in "Put in worksheet" by programing. |
| 3 L A T E S T R E P L I E S (Newest First) |
| Mike Buess |
Posted - 05/26/2004 : 10:44:04 AM As you probably found out when you learned its menu ID there are no scripts associated with this command. It is built in to the Origin program and there is no method that I know about to determine how the 'if' condition is stored.
If you already know the 'if' condition and have a name in mind for the output wks you can probably accomplish the operation with your own script. For example, say you want to extract from the active wks all rows for which col(B)[i]>0.5 and want the output to go to Data23 (which does not already exist).
win -d; // duplicate active wks doc -e W {%W=%H}; // Find the name of the last wks created (your duplicate) win -r %W Data23; // rename it Data23 win -a Data23; // activate Data23 // The rest is the LabTalk equivalent to a while loop for(i=1;i>0;) { if(col(B)[i]==0/0) break; // abort when you find missing value (no data) if(col(B)[i]>0.5) i++; // increment row index if condition is met else { mark -d col(B) -b i -e i; // delete row i if condition not met }; };
There are might be more efficient ways to do it but it's a place to start.
...Here's a better way to deal with thresholds. It assumes the X values are in col A in ascending order.
%O="output wks name"; threshold=0.5; win -d; doc -e W {%W=%H}; win -r %W %O; win -a %O; sort -wd %H col(B); // sort wks in descending order of col B col(B)=(col(B)>threshold)?col(B):0/0; // replace all values below threshold in col B with missing values // Use the tReplace function in Origin 6.1 or later (more efficient than ternary operator) sum(col(B)); set %H -er sum.n; // set # rows to # of actual (non-missing) values sort -w %H col(A); // resort in ascending order of col A
Mike Buess Origin WebRing Member
Edited by - Mike Buess on 05/26/2004 10:49:32 AM
Edited by - Mike Buess on 05/26/2004 12:33:19 PM |
| jeff46 |
Posted - 05/26/2004 : 08:45:02 AM Thanks Mike, So "Put in worksheet" is generated internally but I had to use it several times and the "If" field have to be changed but when I call "Put in worksheet" again "If" preserves the last. Can I change it by script before posting ? |
| Mike Buess |
Posted - 05/24/2004 : 3:43:25 PM The "Put in worksheet" name in that dialog is generated internally and can't be changed by script.
Mike Buess Origin WebRing Member |