Skip to main content
rombanks
Inspiring
December 3, 2019
Question

FM2019 event-driven scripts do not run automatically while in Autorun

  • December 3, 2019
  • 2 replies
  • 2118 views

Hello fellows,

I see that in FM2019, exactly like in FM2015, event-driven scripts do not fire automatically in Autorun mode. To make them run, I still need to select a script in the Scripts window and click run. Is there anything that can be done about it, except for filing a bug and waiting for the best? 😉

 

Thanks,

Roman

This topic has been closed for replies.

2 replies

Klaus Göbel
Legend
December 4, 2019

I did severals tests and in my opinion this is a bug.

When the function is called "manually", everything works.

I've tried using SimpleSave(), but that also didn't work:  FA_errno -44

I've tried SimpleSave with interactive = 1 and that also failed.

So using Notification always is a kind of "russian roulette".

I had several cases where notification failed by "forgetting" global variables.

 

frameexpert
Community Expert
Community Expert
December 4, 2019

Hi Klaus, I haven't tested Roman's code, but I checked some of my past scripts and in one I actually used PreSave events to do this. Roman, try modifying the code below and testing it. Thanks. -Rick

#target framemaker

Notification (Constants.FA_Note_PreSaveDoc, true);
Notification (Constants.FA_Note_PreSaveBook, true);

function Notify (note, object, sparam, iparam) {
 
    switch (note) {
        case Constants.FA_Note_PreSaveDoc :
        case Constants.FA_Note_PreSaveBook :
            if (app.VersionMajor > 12) { 
                // Cancel the built-in save.
                ReturnValue (Constants.FR_CancelOperation);
                saveAsFm12 (object, sparam);
            }
            break;
    }
}
 
function saveAsFm12 (doc, name) {
	
    var params, returnParams, i;
    
	// Get required parameters for the save function.
    params = GetSaveDefaultParams ();
    returnParams = new PropVals ();
    
    // Get the FileType save parameter and set it to FrameMaker 12.
    i = GetPropIndex (params, Constants.FS_FileType);
    params[i].propVal.ival = Constants.FV_SaveFmtBinary120;
    // Add the name to the recently opened list.
    i = GetPropIndex (params, Constants.FS_UpdateFRVList);
    params[i].propVal.ival = true;

    // Save the document as FrameMaker 12.
    doc.Save (name, params, returnParams);
    PrintSaveStatus (returnParams);
}
www.frameexpert.com
rombanks
rombanksAuthor
Inspiring
December 5, 2019

Rick,

Thank you for another version of the script! 

Could you please explain why you check the app version and why you save as FM12 and not as FM13?

In addition, it's not clear to me what the following does:

Constants.FS_UpdateFRVList

PrintSaveStatus (returnParams);

 

The script runs correctly for a while but then error -94 pops up again and I can no longer save the file in any format, including mif.

 

Best Regards,

Roman

frameexpert
Community Expert
Community Expert
December 3, 2019

Hi Roman, Can you be more specific? Thanks. -Rick

www.frameexpert.com
rombanks
rombanksAuthor
Inspiring
December 3, 2019

Hi Rick,

 

I appreciate your quick response!

I have a script that saves an active doc or book as FM13 while hitting Save or Ctrl+S. I moved it to Autorun. 

When I run FM19, open a book or book component, make changes and save them, the file is not saved as FM13, until I go to the Scripts pod, select the event script and hit Run. I experienced the same problem with event scripts in FM13. I don't see this was impoved in FM19.

 

Best Regards,

Roman

frameexpert
Community Expert
Community Expert
December 3, 2019

Is the script in your startup folder? Can you post the script? Thanks.

www.frameexpert.com