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
 plotxy loop
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

morganico

10 Posts

Posted - 04/09/2009 :  09:24:26 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi all, I'm trying to get Origin to plot cols(6,3) then cols(12,9) then cols(18,15) etc...

i thought something like this would work...

int mycol1 = 6;
int mycol2 = 3;

loop (i,1,24)
{
plotxy (1:end)!(mycol1,mycol2) plot:=200; 
mycol1 = mycol1 + 6;
mycol2 = mycol2 +6;
//}


Error returned is `Failed to resolve range'?

What is going on?
Do the xy in plotxy need to be a string? How can I convert an integer to a string in Origin LabTalk script?

I have looked all over but cannot find information for converting datatypes in orgin labtalk script

Many thanks

Laurie

USA
404 Posts

Posted - 04/09/2009 :  10:00:18 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
When you just use mycol1 and mycol2, Origin is looking for columns named mycol1 and mycol2, and when it doesn't find them it correctly returns the "failed to resolve range" error.

You need to use the wcol( ) function:

plotxy (1:end)!(wcol(mycol1),wcol(mycol2)) plot:=200;

Keep in mind that the loop will only run once. The next time it tries to evaluate the input for plotxy, the workbook is no longer active, so it won't be able to. Your input range for the plotxy function needs to contain the workbook name.

You can update your code as follows:


string bk$=%H; //store bookname

int mycol1 = 6;
int mycol2 = 3;

loop (i,1,24)
{
plotxy [bk$](1:end)!(wcol(mycol1),wcol(mycol2)) plot:=200;
mycol1 = mycol1 + 6;
mycol2 = mycol2 +6;
}





OriginLab Technical Support
Go to Top of Page

morganico

10 Posts

Posted - 04/09/2009 :  10:30:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hmmmm, your suggested code returns #Command Error!, any ideas?
Go to Top of Page

morganico

10 Posts

Posted - 04/09/2009 :  11:11:47 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi there,

I have something working but it plots each of the loop iterations as a separate layer, i desire each loop iteration to draw the plot on the same sheet. The code i have which does this is


range rSheet = $(page.active)!; // range is the active worksheet object
range rPage = rSheet.GetPage()$; // range is page to which the sheet is attached

int mycount = int(rSheet.NCOLS); // number of cols in the sheet

int mycol1 = 6;
int mycol2 = 3;

for( ix = 1 ; ix < mycount/6 ; ix += 1 )
{
   plotxy [%(rPage.name$)]%(rSheet.name$)!($(mycol1),$(mycol2)) plot:=200; 
   
   mycol1 = mycol1 +6;
   mycol2 = mycol2 +6;
   
}


How do you draw them on the same sheet?

Many thanks!
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 04/10/2009 :  10:56:21 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try this, following your original code as closely as possible.


int mycol1 = 6;
int mycol2 = 3;
string wbkname$=%H;
win -t plot;//create empty plot first so it remains %H
//plot all into 1st layer of active plot
loop (i,1,24)
{
   plotxy [wbkname$](1:end)!(wcol(mycol1),wcol(mycol2)) 
        plot:=200 ogl:=1!;
 
   mycol1 = mycol1 + 6;
   mycol2 = mycol2 +6;
}


Go to Top of Page

morganico

10 Posts

Posted - 04/16/2009 :  04:19:41 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Many thanks, this works great.

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