Home > X++ stuffs > Usage of “Match” Keyword in Dynamics AX

Usage of “Match” Keyword in Dynamics AX

I was trying to match a word based on a wild card expression in AX and found an interesting keyword

Syntax:    

           int match (str pattern, str text)

 

Match Searches for a string or expression within another string. It compares the fixed expression specified by pattern with the text string specified by text.

Note: The system does not differentiate between lower and upper case. The following special characters can be used to create the pattern in the fixed expression.

 

Here is the sample example illustrated.

static void matchFunction()

{

    //An expression followed by an asterisk requires a match for none, one, or more occurrences of the preceding expression.

    #define.matchKeyword(‘g*’)

    SysDictClass        sysDictClass;

    Set                 setList;

    SetEnumerator       setEnum;

    str                 methodName;

    TextBuffer          text;

    ;

 

    // Object Initialization

    sysDictClass     = new SysDictClass(classnum(Info));

    setList          = new Set(Types::String);

    text             = new TextBuffer();

 

    setList = sysDictClass.objectMethodSet(true);

    setEnum = setList.getEnumerator();

 

    while (setEnum.moveNext())

    {

        if(match(#matchKeyword, setEnum.current()))

        {

            methodName = strrem(setEnum.current(), ‘["]’);

            text.appendText(methodName + ‘\n’);

        }

    }

 

    text.toFile(@’C:\MethodNames.xls’, FileEncoding::UTF8);

}

 

To know more about the usage of match keyword please refer

http://msdn.microsoft.com/en-us/library/aa886279.aspx

 
Advertisements
Categories: X++ stuffs
  1. Anitha
    May 31, 2010 at 4:30 pm

    As always, this entry is useful … Keep blogging 🙂

  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: