Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Answered

X++ symbol primer wanted

Posted on by Microsoft Employee

Hello,

I know, total newb question but here it goes. I'm looking for a source to help me understand the X++ reserved keywords and symbols (e.g., @, #). I've looked over this source ...

msdn.microsoft.com/.../aa661012.aspx

... but there isn't much in practical examples. I'd say I'd emphasize the symbols more than the keywords. Reason is I see sample codes and the AX X++ code often use these symbols but I'm often totally confused on how they're used.

Thank you!

  • Suggested answer
    Rudi Hansen Profile Picture
    Rudi Hansen 3,983 on at
    RE: X++ symbol primer wanted

    So that leaves the question, was AX inspired by XAL witch was inspired by C++, or was AX inspired directly from C++?? :-)

  • Martin Dráb Profile Picture
    Martin Dráb 225,588 Super User on at
    RE: X++ symbol primer wanted

    Just for reference, macros are explained in great detail on MSDN: Macros in X++ [AX 2012]. I think that most AX developers don't actually know all of that...

    I'm pretty sure that X++ macros have been inspired by C++ preprocessor macros.

  • Verified answer
    Rudi Hansen Profile Picture
    Rudi Hansen 3,983 on at
    RE: X++ symbol primer wanted

     I understand your confusion, the hash character (#) is used for creating what they call macros in AX. And it is mostly used for constants as you might have figured.

    So there should be plenty of examples in all the Macros in the AOT.

    But the idea is that you can make a macro/constant like this.

    #define.io_write('W')

    And the you can use it in your code like this.

    file = new BinaryIo(_filename, #io_write);

    I think the reason they are still called macro, is dating back to the "old" Dynamics XAL, where macros where the functions of that language. And when they made Dynamics AX they kept the macros in the language, to keep a little backwards compatibly with Dynamics XAL.
    But I am not sure if there are still some Macros left in Dynamics AX with some of the more advanced functions.

    Hope this helps you a little.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ symbol primer wanted

    msdn.microsoft.com/.../aa661012.aspx  for keywords

    msdn.microsoft.com/.../aa856741.aspx  for functions

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: X++ symbol primer wanted

    Hi Rudi,

    Thank you for the suggestions. The one that often throws me is the hash character (#). The example from the link makes sense when I read it but I've seen in sample codes where the hash is used with the "define" keyword. It appears to denote a constant? Would you be able to point me to some simple examples of its use?

    Much appreciated.

  • Suggested answer
    Rudi Hansen Profile Picture
    Rudi Hansen 3,983 on at
    RE: X++ symbol primer wanted

    Hmm that article you found actually explains the symbols pretty well.

    If you are looking for example code, you really just have to search the existing AX code base for them.

    Go to the AOT Properly just classes node, and press Ctrl+F and put what you are looking for in the "Containing Text" field.

    If you are looking for Symbols like @ you have to use \ before each of them for the search to work, like if you want to search for && you but in \&\&

    Also sometimes doing a Google search for Dynamics AX "&&" (On Google put the symbols between quotes) will also help, but granted on symbols it might be a little hard to find the right things.

    Hope this helps, if not you are welcome to ask here for the specific symbol you are having problems with.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,989 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,588 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans