web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

To find a string in X++ code

(0) ShareShare
ReportReport
Posted on by

Hi All,

Thanks in Advance,

I need to find a string/text in X++ code using X++ job, for example in a job if I have a variable called "Var" then it need to find (without using find tool) the "Var" keyword code using another job.

Note: I have some other customizations also in my tool, so I can't use the standard find tool. Please help me!!!

Please let me know how can I achieve this. Any help would be appreciated.

Thanks,

Deepak M.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    5400 Profile Picture
    7,162 on at
    RE: To find a string in X++ code

    please use below API

    textBuffer = new TextBuffer();

    textBuffer.setText("SourceCode");

    textBuffer.find(....) and ...

  • Community Member Profile Picture
    on at
    RE: To find a string in X++ code

    Hi Bhashkar,

    Thank for your reply, but I need to go through the X++ code line by line and what you mentioned will read the text file only.

    Thanks again,

    Deepak Moorthy.

  • Suggested answer
    5400 Profile Picture
    7,162 on at
    RE: To find a string in X++ code

    you have to initialize SysScanner class with your AOT reference which source you have to pass in text buffer.

    Scanner will scan your source code line by line and pass to test buffer.

    Hope it is clear now.

  • Suggested answer
    Martin Dráb Profile Picture
    236,485 Most Valuable Professional on at
    RE: To find a string in X++ code

    You mentioned two very different things: "text var" and "variable called var".  Which one of these two things you actually want?

    If you look for text (without parsing the code), then use normal text-related tools such as what Bhaskar suggested. X++ definitely is text, so it will work. If you actually don't know how to get the text of X++ code, that's a different question and how to search it.

    If you want to find occurrences of a variable (and not others things var() method, var text in comments etc.), you'll have to use something smarter. There are several ways with different pros and cons, so it would be worth to explain your requirements in detail.

  • Community Member Profile Picture
    on at
    RE: To find a string in X++ code

    Hi Bhaskar,

    Thanks again for your reply, could you please help me with the code, because I don't know how to use SysScanner class. It would be more helpful if you provide me a example.

    Thanks,

    Deepak M.

  • Community Member Profile Picture
    on at
    RE: To find a string in X++ code

    Thanks for your reply Martin, and yes I am looking for the text from X++ code.

    It would be more helpful if you could provide me with a sample code.

    Thanks Again,

    Deepak M

  • 5400 Profile Picture
    7,162 on at
    RE: To find a string in X++ code

    Can you explain in details with example what you want to avoid the multiple iteration and confusion.

  • Community Member Profile Picture
    on at
    RE: To find a string in X++ code

    Hi Bhaskar,

    I want to scan my code line by line, please provide me sample code to achieve this.

    Thanks,

    Deepak M.

  • Martin Dráb Profile Picture
    236,485 Most Valuable Professional on at
    RE: To find a string in X++ code

    Split you problem to small parts, for example:

    1. Read code of a method to string
    2. Iterating the string by line
    3. Find giving text in the string representing a single line

    Let's say you already know how to do two of these two steps. If we tried to explain them to you, we would all just waste time.

  • Community Member Profile Picture
    on at
    RE: To find a string in X++ code

    You are right Martin, in this I want sample code for the first point with which I need to read the code of a method to string. Other two things (2nd and 3rd point) I can do it.

    Thanks,

    Deepak M.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
Community Member Profile Picture

Community Member 2

#2
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans