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
 Saving plotting scripts into Graph Template
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Atedge

18 Posts

Posted - 05/06/2021 :  11:45:52 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2021b (64-bit) 9.8.5.201
Operating System: Windows 10 20H2 (19042.928)
I've tried the new feature of OriginPro 2021b: Support saving plotting scripts into Graph Template, though there 're not much document to introduce it in detail, like https://www.originlab.com/doc/Origin-Help/Graph-Template-Elements#Additional_Scripts_Saved_with_Template , https://d2mvzyuse3lwjc.cloudfront.net/releasenotes/detail.aspx?id=2021b3ORG-22820 .
With this new feature, I can take data from other worksheets as the "axis.from" and "axis.to" of graph plotted by a template. A demo code like:
range klwks = [Book9]Sheet1!,klcol = %(klwks)col(a),kccol = %(klwks)col(b),gr1 = !;
int klnr = klwks.maxRows;
gr1.x.from = kccol[1];
gr1.x.to = kccol[$(klnr)];


And as https://www.originlab.com/doc/Origin-Help/Graph-Template-Elements#Additional_Scripts_Saved_with_Template say, I should do like
page.info.system.plotting.LTAfter$="<the demo code above>"
.

But it didn't work. And the result of "page.info.=;" shows:
page.info.=
<SYSTEM>
[PLOTTING]
MODIFIERMATCHTYPE = 0
PRESETLN$ = "test-demo"
PRESETSN$ = "<auto>"
MODIFIERUDPNAME$ = ""
CLONEMATCH = 3
TEMPLATE$ = "test-demo"
LT$ = ""
LTAFTER$ = "range klwks = [Book9]Sheet1!,klcol = % (klwks)col(a),kccol = % (klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[0];"
[PAGE]
[DISPLAY]
NUMERICSEPARATORS = -1
[LEGEND]
CUSTOMFORMAT$ = "@LL"

SO I have some quetion about "Saving plotting scripts into Graph Template":
1) Can "LTAFTER$" handle %() and $() notations and string reqister properly? I've tried had string register in it, and it will resolve it right after you enter the command, other than running time. How to get these resovled correctly when plotting?
2) Can I use system and user defined variables inside the "LTAFTER$"?
3) Is there special limit of the syntax to take care inside the quotes of "LTAFTER$"?
4) Is there a limitation of the length of the script inside the quotes of "LTAFTER$"?

Edited by - Atedge on 05/06/2021 11:54:35 AM

Atedge

18 Posts

Posted - 05/06/2021 :  11:53:20 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
5) Could a GUI dialog for the scripts saved with the template be available in the future release? Just like "Import Wizard, The Advanced Options Page" https://www.originlab.com/doc/Origin-Help/ImpWiz-AdvanOptPage

Go to Top of Page

YimingChen

1669 Posts

Posted - 05/06/2021 :  2:01:13 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It worked for me, the steps are:
1. New a project, fill col(A) and col(B) with row index. Make a scatter plot.
2. Run the script
page.info.system.plotting.LTAfter$="range klwks = [Book1]Sheet1!,klcol = %(klwks)col(a),kccol = %(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$(klnr)];"

3. Save template and create a plot with the template. Should see the x axis has the scale range 1~32.

James

Edited by - YimingChen on 05/06/2021 2:02:37 PM
Go to Top of Page

Atedge

18 Posts

Posted - 05/06/2021 :  2:46:21 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
What's the result of the command
page.info.=;
? "gr1.x.to = kccol[0];" at the end of LTAfter$ rather than "gr1.x.to = kccol[$(klnr)];" ?
quote:
Originally posted by YimingChen

It worked for me, the steps are:
1. New a project, fill col(A) and col(B) with row index. Make a scatter plot.
2. Run the script
page.info.system.plotting.LTAfter$="range klwks = [Book1]Sheet1!,klcol = %(klwks)col(a),kccol = %(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$(klnr)];"

3. Save template and create a plot with the template. Should see the x axis has the scale range 1~32.

James

Go to Top of Page

YimingChen

1669 Posts

Posted - 05/06/2021 :  2:51:17 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
<TREE>
Binary data (167 bytes)
<SYSTEM>
[PLOTTING]
MODIFIERMATCHTYPE = 0
PRESETLN$ = "<auto>"
PRESETSN$ = "<auto>"
MODIFIERUDPNAME$ = ""
LTAFTER$ = "range klwks = [Book1]Sheet1!,klcol = [Book1]Sheet1!col(a),kccol = [Book1]Sheet1!col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[32];"

quote:
Originally posted by Atedge

What's the result of the command
page.info.=;
? "gr1.x.to = kccol[0];" at the end of LTAfter$ rather than "gr1.x.to = kccol[$(klnr)];" ?
quote:
Originally posted by YimingChen

It worked for me, the steps are:
1. New a project, fill col(A) and col(B) with row index. Make a scatter plot.
2. Run the script
page.info.system.plotting.LTAfter$="range klwks = [Book1]Sheet1!,klcol = %(klwks)col(a),kccol = %(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$(klnr)];"

3. Save template and create a plot with the template. Should see the x axis has the scale range 1~32.

James



Go to Top of Page

Atedge

18 Posts

Posted - 05/07/2021 :  01:23:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
What's the version of your OriginPro? I can't reproduce it by your steps. And "page.info.=" shows
page.info.=
<TREE>
Binary data (167 bytes)
<SYSTEM>
[PLOTTING]
MODIFIERMATCHTYPE = 0
PRESETLN$ = "<auto>"
PRESETSN$ = "<auto>"
MODIFIERUDPNAME$ = ""
TEMPLATE$ = "TestDemo-SCATTER"
LTAFTER$ = "range klwks = [Book1]Sheet1!,klcol = % (klwks)col(a),kccol = % (klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[--];"
CLONEMATCH = 3

I noticed that although I inputed "%(klwks)",it was resolved as "% (klwks)",a <space> between % and (. And "kccol[$(klnr)]" was resolved as "kccol[--]". My Origin version is OriginPro 2021b (64-bit) 9.8.5.201 (Learning Edition).I wonder if the behavior varies between different vesions of OriginPro.

quote:
Originally posted by YimingChen

<TREE>
Binary data (167 bytes)
<SYSTEM>
[PLOTTING]
MODIFIERMATCHTYPE = 0
PRESETLN$ = "<auto>"
PRESETSN$ = "<auto>"
MODIFIERUDPNAME$ = ""
LTAFTER$ = "range klwks = [Book1]Sheet1!,klcol = [Book1]Sheet1!col(a),kccol = [Book1]Sheet1!col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[32];"

quote:
Originally posted by Atedge

What's the result of the command
page.info.=;
? "gr1.x.to = kccol[0];" at the end of LTAfter$ rather than "gr1.x.to = kccol[$(klnr)];" ?
quote:
Originally posted by YimingChen

It worked for me, the steps are:
1. New a project, fill col(A) and col(B) with row index. Make a scatter plot.
2. Run the script
page.info.system.plotting.LTAfter$="range klwks = [Book1]Sheet1!,klcol = %(klwks)col(a),kccol = %(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$(klnr)];"

3. Save template and create a plot with the template. Should see the x axis has the scale range 1~32.

James





Go to Top of Page

YimingChen

1669 Posts

Posted - 05/07/2021 :  2:57:18 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OK. Here is what happened. Because when you run the script:

page.info.system.plotting.LTAfter$="range klwks = [Book1]Sheet1!,klcol = %(klwks)col(a),kccol = %(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$(klnr)];"


range klwks is not defined, so the substitution %(klwks) doesn't resolve to anything. So we want the substitution to happen when the graph is created from the template. So a workaround is use the script below instead
page.info.system.plotting.LTAfter$="range klwks = [Book1]Sheet1!,klcol = %%(klwks)col(a),kccol = %%(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$"+"(klnr)];";


See if that works. Thank you.

James
Go to Top of Page

Atedge

18 Posts

Posted - 05/08/2021 :  01:31:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I tried your new syntax, and the content of LTAFTER$ in the page.info seems to be normal now, but actually nothing happened after the script runed, neither when reploted using the template with the script had saved in the page.info.system.plotting.LT$ or page.info.system.plotting.LTAfter$.
Here is the page.info after using the new syntax:
page.info.=
<TREE>
Binary data (167 bytes)
<SYSTEM>
[PLOTTING]
MODIFIERMATCHTYPE = 0
PRESETLN$ = "<auto>"
PRESETSN$ = "<auto>"
MODIFIERUDPNAME$ = ""
TEMPLATE$ = "TestDemo-SCATTER"
CLONEMATCH = 3
LT$ = "range klwks = [Book1]Sheet1!,klcol = %(klwks)col(a),kccol = %(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$(klnr)];"
Go to Top of Page

YimingChen

1669 Posts

Posted - 05/10/2021 :  10:04:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Can you double check? It works for me. I followed the steps below:

1. New a project, fill col(A) and col(B) with row index. Make a scatter plot.
2. Run the script
page.info.system.plotting.LTAfter$="range klwks = [Book1]Sheet1!,klcol = %%(klwks)col(a),kccol = %%(klwks)col(b),gr1 = !;int klnr = klwks.maxRows;gr1.x.from = kccol[1];gr1.x.to = kccol[$"+"(klnr)];";


3. Save template and create a plot with the template. Should see the x axis has the scale range 1~32.

James
Go to Top of Page

Atedge

18 Posts

Posted - 05/11/2021 :  03:05:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I checked it again, and probably found where the problem lied: the script saved with graph behaves differently between a normal template and a cloneable template.The script within a normal graph template works well, but within a cloneale one it takes no effects. I attached my test project file here for anyone to reproduce this problem. Is this a bug?
https://my.originlab.com/ftp/forum_and_kbase/Images/DemoTest.zip

Edited by - Atedge on 05/11/2021 03:11:05 AM
Go to Top of Page

YimingChen

1669 Posts

Posted - 05/11/2021 :  4:25:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, I can reproduce the issue. I have reported it (ORG-22820).

James
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