As you all know, there are multiple ways to define and use macros in X++.
For those that need a refresher, please look up the corresponding section on MSDN
(Direct link: http://msdn.microsoft.com/en-us/library/cc197107.aspx)
Below is a simple X++ job, that demonstrates an existing shortcoming in the #define command, and a possible workaround for this problem.
Nothing complicated, basically, just use #localmacro, if you can't compile your code.
static void ClosingBracketInMacroDefinition(Args _args)
{
//#define.Question("Why are brackets ')' not working ?")
//#define.Question(@"Why are brackets ')' not working ?")
//#define.Question("Why are brackets '\)' not working ?")
#define.LegalCharacters(' !"#$%&\'(*+,-./:;<=>?@[\\]^_`{|}~\n\r\t')
#localmacro.Question
"Why are brackets ')' not working ?"
#endmacro
Box::info(#Question);
Box::info(#LegalCharacters);
}
Thanks for finding the issue to Bogdana, one of our new developers.
don't see the closing bracket in #define.LegalCharacters(' !"#$%&\'(*+,-./:;<=>?@[\\]^_`{|}~\n\r\t') ???
ReplyDeleteIf you add it, it won't compile. So I specifically removed it.
ReplyDeleteThat's what the post is about :)
Unless you define it as a localmacro.