T O P I C R E V I E W |
ds755 |
Posted - 06/16/2018 : 1:56:06 PM Origin Ver. and Service Release (Select Help-->About Origin): Origin 2018 SR1 Operating System: Windows 8.1
Hello,
I have noticed that when I use Labtalk to create graphs using templates whose names have a dash (-), the command does not work. The graph is created but does not have the properties of the template. Once I remove the dashes, the command works. This is inconvenient, as I frequently use the dash as a delimiter, along with underscore (_).
Is there something I am missing or is this a fundamental limitation? Which characters will work as delimiters in template names, except underscore?
Thank you |
11 L A T E S T R E P L I E S (Newest First) |
ds755 |
Posted - 06/19/2018 : 6:14:17 PM I see. So, the double quotes prevent the integer conversion.
It seems to work in my example. I will try this out in my code and come back if I encounter any more problems.
I really appreciate the help. |
cpyang |
Posted - 06/19/2018 : 5:40:12 PM should be
win -t p "%(arch$).otpu" Test;
this is because you are using a string variable inside "", only string register can be used directly.
CP
|
ds755 |
Posted - 06/18/2018 : 7:09:52 PM I think it drops the ball on %(arch$). Since it transforms arch$ into an integer variable, the dash becomes minus, which is probably parsed differently in the program.
In my previous example, %(arch$) will equal -1 (as in: 1-2=-1).
Also, it works if I use string registers (which I do not want to do, in general).
The code:
%K=arch$;
win -t p "%K.otpu" Test;
will load the template properly, even with the dashes, as no integer conversion occurs.
The code:
win -t p "arch$.otpu" Test;
will fail, with or without the quotes.
So, I guess my question translates to: how to load a template with string variables, while avoiding the conversion to an integer variable, as well as string registers. |
ds755 |
Posted - 06/18/2018 : 2:59:54 PM I can provide more code but we also need templates to fully investigate the problem, and I'm not sure how to upload one.
If your schedule allows, I would propose to investigate this problem with a "minimum working example".
For example, you can do the following test:
1. Create a blank text file named a_1-2.txt
2. Save a template as 1-2.otpu (and 1-2.emf). Please alter something from the default graph template, to make sure that you know when your template has loaded successfully.
3. Load the text file (import Single ASCII), run the following code and please tell me if the template loads successfully.
string sheetname$=page.longname$;
string arch$ = sheetname.GetToken(2,"_")$;
// arch$ should contain 1-2.txt
arch$ = arch.GetToken(1,".")$;
// arch$ should contain 1-2
win -t p %(arch$).otpu Test;
// A graph will be created
If the template does not load, perhaps you can try without the dashes.
In my case, the graph is created but without loading the template. I get the default graph template from Origin. |
Chris D |
Posted - 06/18/2018 : 2:36:38 PM Without seeing more of what you are going, it is hard to tell what is wrong because the last example shows correct parsing tokens containing "-"'s.
Perhaps you can provide more code.
Thanks, Chris Drozdowski Originlab Technical Support
|
ds755 |
Posted - 06/18/2018 : 2:09:00 PM I get exactly what you expected. |
Chris D |
Posted - 06/18/2018 : 1:22:12 PM Run this code and tell me what you get:
string sheetName$ = "Sheet1_A-Test";
string architecture$ = sheetname.GetToken(2,"_")$;
architecture$=;
It should output "A-Test" (without the quotes).
Thanks, Chris Drozdowski Originlab Technical Support
|
ds755 |
Posted - 06/18/2018 : 12:39:28 PM It works! But then why doesn't it work when the dash is fed in the string variable from the GetToken command?
(e.g. string architecture$ = sheetname.GetToken(2,"_")$;)
|
Chris D |
Posted - 06/18/2018 : 12:15:47 PM Hi,
Try this:
string architecture$ = "My-Template"; // For testing.
win -t p "%(architecture$)_I_vs_time.otpu" I_vs_t;
Notice I put the template name in double quotes.
Thanks, Chris Drozdowski Originlab Technical Support
|
ds755 |
Posted - 06/18/2018 : 11:47:22 AM Hi Chris,
Actually, my code looks more like this:
win -t p %(architecture$)_I_vs_time.otpu I_vs_t;
The "architecture" string is extracted from the filename. If the string has a dash, the command fails.
How could I go around this problem?
|
Chris D |
Posted - 06/18/2018 : 09:04:41 AM Hi,
Try enclosing the template name in double quotes.
For example:
plotxy (1,2) ogl:=<new template:="My-Template">
Thanks, Chris Drozdowski Originlab Technical Support
|