General XMetaL Discussion
XMetaL Community Forum › General XMetaL Discussion › Global Function and variable
-
gcrews November 8, 2010 at 6:47 pm
Global Function and variable
November 8, 2010 at 6:47 pmParticipants 1Replies 2Last Activity 12 years, 4 months agoIs there a way to use the same function between different macros and have a variable that keeps its value between macros?
The On_Application_Query_Service stuff in the programmer’s guid seems to be kind of what I’m looking for. The example has the flowing line:
Application.QueriedServiceImpl = getMyService();
Where do you define the getMyService() function though? If I have a variable in a prototype class will it persist between service calls to it?Derek Read November 8, 2010 at 7:14 pm
Reply to: Global Function and variable
November 8, 2010 at 7:14 pmAlthough you can declare a function in any macro the event called On_Macro_File_Load is a good place to declare them (it is a clean place to do it and this event runs when an MCR is loaded, so the function will be there provided the MCR loaded).
To store values for document-level macros you can use these:
DocumentProperties (and its associated APIs “add“, “item” and “count“)
The actual API you use to get to DocumentProperties is ActiveDocument.CustomDocumentProperties.
For application-level macros you can use Application.CustomProperties.
gcrews November 8, 2010 at 7:20 pm
Reply to: Global Function and variable
November 8, 2010 at 7:20 pmAh I see now just found the doc “Variable scope in XMetaL Author”. I tried a while back using a function between macros and it didn’t work and thought the macro code functions were completely separate. Thank you that makes complete sense now.
-
AuthorPosts
- You must be logged in to reply to this topic.