我使用以下脚本创建插件(gtk
),但在运行脚本后,我不知道创建的插件(gtk
)文件在哪里?
我检查了文件夹
C:\ Program Files(x86)\ Gatan \ DigitalMicrograph \ PlugIns
我不知道在文件夹中看到任何新创建的gtk
文件。
这个脚本是错误的还是创建的gtk
文件应该在其他地方?
/ Define the necessary variables string base,menu,submenu,item,packageNAME,name
number maxitem,i,j,maxfolder taggroup tgFILES,tgFOLDERS,tg
// Just some starting text in the results window.
result("\n Automatic Installation of all scripts in a folder as Plugin:\n\n")
// First get the default folder. (In this case, the folder last opened within DM)
base = GetApplicationDirectory(2,0)
// Prompt the user with a dialog to choose a folder, with the default folder as first choice.
// If the user cancels the dialog, the script will stop.
If (!GetDirectoryDialog("Please select the folder containing the scripts",base,base)) exit(0)
// Ask the user for a package name
If (!GetString("Name of package file?","",packageNAME)) exit(0)
// Ask the user for a menu name
If (!GetString("Name of menu to install the scripts in","",menu)) exit(0)
// Get all files/folders in the folder as a tag-list
tgFILES = GetFilesInDirectory(base,1)
tgFOLDERS = GetFilesInDirectory(base,2)
// Install all files from the main folder as menu commands.
// Count Items in the folder
maxitem = tgFILES.TagGroupCountTags()
i = 0
// Loop through all items
while (i<maxitem)
{
// get taggroup of item
tgFiles.TagGroupGetIndexedTagAsTagGroup(i,tg)
// get name of file
tg.TagGroupGetTagAsString("Name",item)
// Only if filename end with ".s" continue
If (right(item,2)==".s")
{
// use the name without the ending
name = left(item,len(item)-2)
result("\n Installing: "+item)
// install the menu command
// use the Try-Catch loop to detect problems during install
try
{ AddScriptToPackage(base+item,packageNAME,0,name,menu,"", 0) }
catch
{ result(" \t ERROR DURING INSTALL") } }
i++ }
// Now install all files from sub-folder as sub-menu commands.
// Count subfolders in the folder
maxfolder = tgFOLDERS.TagGroupCountTags()
// Loop for all subfolders
for (j=0;j<maxfolder;j++)
{
// get taggroup of item
tgFolders.TagGroupGetIndexedTagAsTagGroup(j,tg)
// get name of subfolder which is also the name of the submenu
tg.TagGroupGetTagAsString("Name",submenu)
// Get all files in the subfolder as a tag-list
tgFILES = GetFilesInDirectory(base+submenu,1)
// Count Items in the folder
maxitem = tgFILES.TagGroupCountTags()
i = 0
// Loop through all items as before for the main folder
while (i<maxitem)
{
tgFiles.TagGroupGetIndexedTagAsTagGroup(i,tg)
tg.TagGroupGetTagAsString("Name",item)
If (right(item,2)==".s")
{
name = left(item,len(item)-2)
result("\n Installing <"+submenu+">: "+item)
try {
AddScriptToPackage(base+item,packageNAME,0,name,menu,submenu, 0) }
catch
{
result(" \t ERROR DURING INSTALL") } }
i++ } }
答案 0 :(得分:1)
这取决于GMS版本和您正在运行的操作系统版本。我假设你在Windows7或Windows8机器上使用GMS 2.x,那么命令AddScriptFileToPackage
可以有两种语法版本:
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 )
可以是 user_plugin 或插件。如果省略此参数(第二个命令版本),则假定 user_plugin 。
对于 user_plugin ,您将在以下位置找到创建的文件:
C:\Users\USERNAME\AppData\Local\Gatan\Plugins
其中USERNAME是当前的Windows用户。
对于插件,您会在&#39;插件中找到创建的文件。子文件夹相对于“DigitalMicograph.exe”的安装,最有可能出现在:
C:\Program Files\Gatan\Plugins
答案 1 :(得分:1)
您可能正在使用Windows 7的“兼容性文件”功能.GMS 1.x只有AddScriptFileToPackage
函数的一个变体,它总是希望将生成的包文件保存到标准DM PlugIns文件夹中:
C:\Program Files (x86)\Gatan\DigitalMicrograph\Plugins
但是在Windows 7中,阻止了将文件直接写入Program Files目录的子文件夹,而是将文件写入用户特定的本地目录,其名称如下:
C:\Users\USERNAME\AppData\Local\VirtualStore\Program Files (x86)\Gatan\DigitalMicrograph\Plugins
但是,通过单击标准PlugIns文件夹的Windows资源管理器窗口工具栏中显示的“兼容性文件”按钮,可以轻松地显示此类虚拟化文件。