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
 plotxy loop

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
morganico Posted - 04/09/2009 : 09:24:26 AM
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
5   L A T E S T    R E P L I E S    (Newest First)
morganico Posted - 04/16/2009 : 04:19:41 AM
Many thanks, this works great.

cpyang Posted - 04/10/2009 : 10:56:21 AM
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;
}


morganico Posted - 04/09/2009 : 11:11:47 AM
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!
morganico Posted - 04/09/2009 : 10:30:37 AM
Hmmmm, your suggested code returns #Command Error!, any ideas?
Laurie Posted - 04/09/2009 : 10:00:18 AM
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

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