Dear all, I have got a bit of a problem with understanding the difference between a global (standalone), a local macro and a macrolib.
I need some clarification for an extended axapta development training-manual I am writing. I created the following macros: tra_macro_global1: #globalmacro.TRA_Macro_Global1 print "Hello global world"; pause; #endmacro tra_macro_local1: #localmacro.TRA_Macro_Local1 print "Hello local world"; pause; #endmacro I use both of them in a job and to get something printed I need to reference the statement twice. Understandable from the point of view of the local macro assuming local macros can only be part of a macrolibrary. Notice however I have not used the word macrolib in my code. static void TRA_Macro_Global1(Args _args) { #TRA_Macro_Global1 #TRA_Macro_Global1 #TRA_Macro_Local1 #TRA_Macro_Local1 } Now I created a macrolibrary called TRA_Macro_Lib1. The contents is: #localmacro.TRA_Macro_Local1 print "Hello local world"; pause; #endmacro #localmacro.TRA_Macro_Local1 print "Hello local world"; pause; #endmacro I am testing this out on the form CustTable to see how this works. I added the statement #macrolib.TRA_Macro_Lib1 to the classDeclaration of the form. Then I add the statements: #TRA_Macro_Global1 #TRA_Macro_Local1 to the lookup() method of the VATNum field, which can be found under the tabpage setup, group salestax. To my surprise I am getting an error "the macro does not exist" referring to the global macro TRA_Macro_Global1 part of the library. I do not get the message for the local macro. So there the system knows from the classdeclaration where to find the local macro, but this is not the case for the global macro. When I add the statement #TRA_Macro_Lib1 to the lookup() method before the reference to the global macro, the error disappears. Reading the developers guide again I see that it states a macro library is a stand-alone macro, which contains (local) macros. Alright this should be the explanation, a global macro can not be part of a macro library. I however find all of this quite confusing. I get the impression there is no real difference between a global macro and a local macro. At least not if we use them in a macro library. Moreover the global macro (standalone macro) is not that standalone at all. To work with it we have to treat it as if it is a macrolibrary. Thus first reference the macrolibrary and then use it. Next it is not that global at all. The developers guide says it can be used everywhere after declaration. The example prooves that using a local macro in a macro library is more beneficial than using a global macro. I only had to reference the library once in the classdeclaration to work with the local macro. Now my question is: Am I understanding all of this wrongly? Are am I looking at the concept from a wrong angle? Let me know if that is the case. kind regards, Danny PS: Some of you might think he is using the identical names as in the macro library TRA_Macro_Lib1 as in the TRA_Macro_Local1 and TRA_Macro_Global1. That is right but it will not cause problems, I tested this with totally different names. But ok my explanation: When I use the macrolib in a job and the job is compiled the macrolib statement is the first statement processed and unfolded. In the next lines of code the statements in the macrolib will be treated as part of the code and obviously used. ------------------------ Yahoo! Groups Sponsor --------------------~--> $9.95 domain names from Yahoo!. Register anything. http://us.click.yahoo.com/J8kdrA/y20IAA/yQLSAA/kGEolB/TM --------------------------------------------------------------------~-> Sharing the knowledge on Axapta. Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/Axapta-Knowledge-Village/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/