General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Share common functions between forms?
dalle April 9, 2009 at 7:07 am
Share common functions between forms?April 9, 2009 at 7:07 amParticipants 0Replies 1Last Activity 13 years, 11 months ago
I'm looking for possibilities of sharing common functions between forms. Anyone know a way to achieve that?
DalleDerek Read April 10, 2009 at 12:12 am
Reply to: Share common functions between forms?April 10, 2009 at 12:12 am
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).
- You must be logged in to reply to this topic.