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
 Specify active worksheet after m2w

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
bhoffpauir Posted - 02/24/2009 : 10:03:25 PM
Origin Ver. 8pro SR4:
Operating System:XP

Using labtalk script...

Trying to convert a matrix to a xyz worksheet and then filter and sort the data. I need to do this multiple times and I want to put the results into different worksheets in the same workbook. The following script works one time. However, upon running a second time (with new value for %J) the matrix converts correctly but after that step, I get the following error:
Failed to resolve range string, VarName = w, VarValue = <active>
#Command Error!

...presumably b/c the new worksheet is not active, but I can't figure out how to select that worksheet. I tried inserting win -a [MaxDat1]%J! but that doesn't work. Am I using the wrong syntax?
Script follows:

GetNumber (Rest or -60) %%J (Minimum Voltage) minVolt (Maximum Voltage) maxVolt (Minimum Time) timeMin (Maximum Time) timeMax;

m2w ow:= [MaxDat1]%J! method:= xyz option:= xconstx; //convert matrix to worksheet.

rowCount=wks.nrows;
wks.addcol(space);
wks.addcol(T);
wks.col5.type=4; // set column to x
wks.addcol(V);
wks.addcol(R);
wks.col7.type=6; // set column to z

jj=1; // need counter for row count of new data
ii=1;

repeat rowCount
{
if (minVolt<=col(2)[ii])
if (maxVolt>=col(2)[ii])
{
col(5)[jj]=col(1)[ii];
col(6)[jj]=col(2)[ii];
col(7)[jj]=col(3)[ii];
jj=jj+1;
};
ii=ii+1;
};

wsort descending:=1 c1:=5 c2:=7 bycol:=7;
2   L A T E S T    R E P L I E S    (Newest First)
bhoffpauir Posted - 02/26/2009 : 2:05:52 PM
THanks for the reply Vincent,

I was working by opening the appropriate matrix window and the xfunction m2w was working fine. I altered the text as suggested but still have the same problem, which I finally resolved with the following changes:


GetNumber (Matrix Book Name) %%L (Rest or -60) %%J (Minimum Voltage) minVolt (Maximum Voltage) maxVolt (Minimume Time) timeMin (Maximum Time) timeMax;


m2w im:= [%L]1!1 ow:= [MaxDat1]%J! method:= xyz; //converts matrix to worksheet
win -a MaxDat1;
page.active$=%J;

This brings up the appropriate worksheet and no worries with the lines thereafter.

Thanks,
Brian
VincentLiu Posted - 02/26/2009 : 05:30:48 AM
Hi bhoffpauir,

You need to specify the input matrix for the m2w X-Function. If you don't specify the input matrix,this X-Function will use the active window as input by default. After you performing your scripts for one time, the active window should be the worksheet window "MaxDat1". Then when you performed the scripts again, the X-Function cannot find the input (Matrix) correctly. So you need to modify the line

m2w ow:= [MaxDat1]%J! method:= xyz option:= xconstx; //convert matrix to worksheet.

to

m2w im:=[MBook2]MSheet1!Mat(1) ow:= [MaxDat1]%J! method:= xyz; //convert matrix to worksheet.

The line above has specified the input matrix with range notation. Please change the name of the input matrix accordingly when you use it.

Best regards,
Vincent Liu
OriginLab Technical Services

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