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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 LabTalk Forum
 Specify active worksheet after m2w
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

bhoffpauir

USA
Posts

Posted - 02/24/2009 :  10:03:25 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
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;

VincentLiu

China
Posts

Posted - 02/26/2009 :  05:30:48 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - VincentLiu on 02/26/2009 05:33:15 AM
Go to Top of Page

bhoffpauir

USA
Posts

Posted - 02/26/2009 :  2:05:52 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
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

Edited by - bhoffpauir on 02/26/2009 2:11:06 PM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000