Home Forums General XMetaL Discussion Share common functions between forms? Reply To: Share common functions between forms?

Derek Read

Reply to: Share common functions between forms?

Each instance of an XFT form instantiates it's own scripting engine (ie: JScript, VBScript, etc).

So, I guess it depends on what you mean by “share common functions” (that phrase can be interpreted different ways).

Two different XFT forms could both launch a 3rd XFT form using CreateFormDlg() and DoModal() thereby “sharing” it.

Or perhaps you are talking about “functions” in the scripting sense. If you were to create an MCR containing a macro, other macros and XFT forms should be able to run that macro using the Application.Run() method. Or if you were to define a function in an MCR file's On_Macro_File_Load event that function can be used by other macros.

One trick we use for DITA is to save JScript in text files (we give them a .js extension but that is not necessary) and then load the file into a string (using FSO or other means) and use JScript's eval() on the string.

If the forms need to share data then you will also likely need to use the CustomProperities or CustomDocumentProperties objects (because of the first point in this reply).

In theory I suppose you could try to create a JScript prototype object and store it using CustomProperities or CustomDocumentProperties (though I have not tried this so not sure exactly how to code that, and it might also be different depending on your real need).