Hi Roman,
The one line from Oliver John's earlier post is a combination of finding the Fcode, entering it into an array and send the array of Fcodes to FrameMaker to be executed. The Fcodes( ... ) command sends one or more Fcodes to FrameMaker, which are then executed. They could be keystroke sequences or, in the case we're discussing, a menu command. So the same could be done with the following code, which separates all steps:
var oCodesToBeExecuted = [ ];
var oMyCommandObject = app.GetNamedCommand ( "ApplyMasterPages" );
var iTheCode = oMyCommandObject.Fcode;
oMyCodes.push ( iTheCode );
Fcodes ( oCodesToBeExecuted );
I hope this explains the method. By the way, if you want to apply the master pages on a book object (i.e. on all its chapters, using the Apply Master Pages command in the Book's Format menu), you should replace "ApplyMasterPages" by "ApplyMasterPagesBook".
Kind regards
Jang