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
 Loading user defined template through labtalk
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

achu6393

India
38 Posts

Posted - 11/18/2016 :  08:37:10 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello all,

I am trying to create an app and I use a lot of user defined templates for graphing. I have saved the templates in the app folder and packed it as .opx file with the package manager. However, when I install the app in other PC the program fails to load the template to its template library.

Is it possible that I can load these templates to the library using labtalk script? (I can use them in the 'after installation' section)

Thank you.

Origin Ver. 2016 and Service Release 9.3
Operating System: win 7

-Akki

such coding! much wow!

Hideo Fujii

USA
1582 Posts

Posted - 11/18/2016 :  4:32:29 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Akki,

> Is it possible that I can load these templates to the library using labtalk script?

As you see in the document (http://www.originlab.com/doc/APP/App-Development), App stuffs are
stored in the "AppData\Local" folder for the current Windows user such as:
C:\Users\myName\AppData\Local\OriginLab\Apps\myApp
So, first please make sure if your template files (.OTP and their preview images .EMF) are there.
Then, you can open the template as an empty graph window, and save it as a user defined
template using "template_saveas" x-function. The code maybe like:
//////////////////////////////////////////
%K=C:\Users\myName\AppData\Local\OriginLab\Apps\myAppName\; //App location
window -t plot "%KmyApp";  //open graph window. Do not add .OTP
template_saveas pg:=[%H] category:="UserDefined" template:="myApp" filepath:="%Y" emf:=1;
//////////////////////////////////////////

There might be much better ways, but at least this also works.

--Hideo Fujii
OriginLab

Edited by - Hideo Fujii on 11/18/2016 4:35:45 PM
Go to Top of Page

Chris D

428 Posts

Posted - 11/18/2016 :  5:00:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

A slight improvement to Hideo's response.

There is actually a string register that points to the root folder where Apps are installed (it is %@A ). So his code sample might better be:
//////////////////////////////////////////
window -t plot "%@A\MyAppFolder\myTemplate";  //Open graph template as window. Do not add .OTP extension.
template_saveas pg:=[%H] category:="UserDefined" template:="myTemplate" filepath:="%Y" emf:=1;
//////////////////////////////////////////


Thanks,
Chris Drozdowski
Originlab Technical Support

Edited by - Chris D on 11/18/2016 5:01:08 PM
Go to Top of Page

achu6393

India
38 Posts

Posted - 11/21/2016 :  10:32:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you both for your reply. It worked well.

However, Is there a function which returns whether or not if the specified template already exists in the library? or to delete a template from the library? I donot want to override existing system templates.

Thanks again.

such coding! much wow!

Edited by - achu6393 on 11/21/2016 1:06:37 PM
Go to Top of Page

achu6393

India
38 Posts

Posted - 11/22/2016 :  04:55:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I want to update my previous reply. I found the function File.exist() which helps in finding if the template is installed or not.
However I couldn't find a function to remove the template from the library.
Is there a labtalk command for the same?

-Akki

such coding! much wow!
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