How to convert DM-script files (*.s) into a plugin file (*.gtk)

混江龙づ霸主 提交于 2021-01-29 02:26:46

问题


I have written some DM-script files (.s), and thus I would like to convert (compile?) them into plugin files (.gtk). In this case, should I prepare some kind of compiler and Gatan Software Development Kit (SDK) package, or others? If there is a good way, please teach the procedure in detail. I will be really grateful, if you share some wisdom to create *.gtk files.


回答1:


.GTK files are not compiled - you will not gain any speed benefit of having them in a .gtk (or .gt1, .gt2 ) file. They are only packed into those files for convenience of sharing and distributing them easily without sharing source code.

That said, the way to "pack" scripts into those files is to use a script-command itself, i.e. write a script which build these files from a set of .s files on the hard drive.

The command to add a script-file to a script package is AddScriptFileToPackage with the syntax:

void AddScriptFileToPackage( String file_path, String packageName, Number packageLevel, String packageLocation, String command_name, String menu_name, String sub_menu_name, Boolean isLibrary )
void AddScriptFileToPackage( String file_path, String packageName, Number packageLevel, String command_name, String menu_name, String sub_menu_name, Boolean isLibrary )

The command to add a script (string) to a script package is AddScriptToPackage with the syntax:

void AddScriptToPackage( String script, String packageName, Number packageLevel, String packageLocation, String command_name, String menu_name, String sub_menu_name, Boolean isLibrary )
void AddScriptToPackage( String script, String packageName, Number packageLevel, String command_name, String menu_name, String sub_menu_name, Boolean isLibrary )

The paramters in the two commands are:

Note, that the created plugin-file will by default appear in the user_plugin location:

C:\Users\USERNAME\AppData\Local\Gatan\Plugins

The second syntax allows specifying the path, where the packageLocation parameter might be any of the names also accepted in the command GetApplicationDirectory, most often either being user_plugin (see above) or just plugin referring to the current run DigitalMicrograph.exe relative plugin folder, i.e.

.\Plugins relative to where the DigitalMicrograph.exe sits, typically C:\Program Files\Gatan\Plugins\

Note, that one can append scripts to an existing file, but can not "unistall" one from it. In that case, one has to delete the file and re-create it anew. Also, if an error occurs in the to-be-added scripts, they will not install correctly and you might need to start over.

The F1 help documentation (of later GMS versions) has an example script showing how to typically use the command:


The difference between libary and command install is the same as when using the File-Menu command to "install a script". A library usually is a set of methods (or classes) which, when installed, remain available and in memory. The command installs a script as a menu-command to the UI. i.e. selecting the menu executes the scirpt (once). While the "File/Install Script" install things into the general prefereces-file of DigitalMicrograph, the commands above create separate .gtk files which load on startup if found in the plugins-folder. Any code that is installed as "library" is run once on startup.



来源:https://stackoverflow.com/questions/53129923/how-to-convert-dm-script-files-s-into-a-plugin-file-gtk

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!