Programmatic copy vs. manual copy
What is the hidden secret here?
- The script is copied from a desktop-subdirectory into FrameMaker Startup by mans of an installation program.
- The script is manually copied (using File explorer) from the desktop-subdirectory into FrameMaker Startup.
Starting FM after case 1 executes the script twice !
Starting FM after case 2 executes (as expected) the script once.
I have cut down my script to something manageable and did the tests with this stub.
// FMdict_test.jsx ------ UTF-8 ------------------------------------------------------------------------
#target framemaker
ShowDictInfo () // At start of FM inform about the User dictionary
SetUpMenus() // inactivate for debugging // Establish menu item to get the information also later.function SetUpMenus() { // =========================================================================
// This function MUST NOT be named DefineMenu - because this is a reserved function!
var sDictMenu = "Dictionary information";
var sShortLbl = "ESC q d i";
var sShortCut = "\\!qdi";var menuLocation = app.GetNamedMenu("FileMenu");
var cmdDoc = menuLocation.DefineAndAddCommand(1, "FMdict_DocInfo", sDictMenu, sShortCut);
cmdDoc.KeyboardShortcutLabel = localize(sShortLbl);
UpdateMenus(); // refresh and actually make the new menu appear
} // --- end SetUpMenusfunction Command(cmd){
switch(cmd) {
case 1:
ShowDictInfo();
break;
}
} // --- end Commandfunction ShowDictInfo () { // === Alert the dictionary information ================================
var appdata = app.UserSettingsDir; // %appdata%\Adobe\FrameMaker\<version>
var FMdictDir = appdata.replace (/Adobe.*/ , "D+DD\\FMdict");
var iniFile = FMdictDir + "\\scripts\\FMdict.ini";
var title = "FMdict — Dictionary information";
var currentPrj = "current Project" // GetIniValue (iniFile, "currentPrj");
var currentDir = "current Directory" // GetIniValue (iniFile, "currentDir");
var text = "The User dictionary was loaded from \nFMdict project:\t" + currentPrj + "\nLocated in: \t" + currentDir;if (currentPrj !== "NONE") { // must fit with FMdict
alert (text, title, false);
}
}
the installation routine is a compiled AHK (AutoHotKey) script which uses this statement:
FileCopy, %installDir%\scripts\*.jsxbin, %FMtarget%, 1
This expands to
FileCopy, C:\Users\Klaus\Desktop\InstallThis\scripts\*.jsxbin, C:\Users\Klaus\AppData\Roaming\Adobe\FrameMaker\14\Startup, 1
Parameter 1 allows to overwrite an existing file.
After deleting the target file I repeated the experiment with the command prompt:
Copy C:\Users\Klaus>copy C:\Users\Klaus\Desktop\InstallThis\scripts\*.jsxbin C:\Users\Klaus\AppData\Roaming\Adobe\FrameMaker\14\Startup
This copied script also hits twice!
Find the jsxbin here - it shoud be the same if you 'Export as Binary' the above script.
A very bewitched situation...
Klaus

