General XMetaL Discussion

XMetaL Community Forum General XMetaL Discussion Global Function and variable

  • gcrews

    Global Function and variable

    Participants 1
    Replies 2
    Last Activity 12 years, 4 months ago

    Is 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

    Reply to: Global Function and variable

    Although 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.



    Reply to: Global Function and variable

    Ah 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.


  • You must be logged in to reply to this topic.

Lost Your Password?