AXForum  
Вернуться   AXForum > Microsoft Dynamics AX > DAX Blogs
All
Забыли пароль?
Зарегистрироваться Правила Справка Пользователи Сообщения за день Поиск

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 30.06.2009, 17:05   #1  
Blog bot is offline
Blog bot
Участник
 
25,491 / 846 (79) +++++++
Регистрация: 28.10.2006
axaptapedia: Match
Источник: http://www.axaptapedia.com/Match
==============

Summary: New page: Here is a method for searching (matching) text in the classical style: If for instance the InventTable must be searched for records whos item name contains the text MUSTER, this method ca...

Here is a method for searching (matching) text in the classical style:

If for instance the InventTable must be searched for records whos item name
contains the text MUSTER, this method can be called with the parameters:

X++:
if (myMatch('*MUSTER*', inventTable.Itemname))
{
    // Then do something
}

The method return true if a match was found and false otherwise.


X++:
static boolean myMatch(str _matchKey, str _text)
{
    str     matchKey        = _matchKey;
    str     text            = _text;
    str     tokKey;                             // Match Key Token  -  Holds actual Character being examined
    str     tokText;                            // Text Token       -  Holds actual Character being examined
    str     laTok;                              // Look Ahead Token -  Holds Character one Positition after Token Character
    int     lenKey;                             // Key Length
    int     lenText;                            // Text Length
    int     incKey;                             // Incrementor for Key
    int     incText;                            // Incrementor For Text
    int     laKey;                              // Look Ahead Incrementor for Key
    boolean ret             = true;
    ;

    #define.WC_MANY ('*')
    #define.WC_ONE  ('?')

    if (!matchKey)
        matchKey = #WC_MANY;

    lenKey  = strlen(matchKey);
    lenText = strlen(text);
    incText = 1;

    for (incKey = 1; incKey  lenText)
            ret = false;

        switch (tokKey)
        {
            case #WC_MANY   :
                if (incKey < lenKey)
                {
                    laKey   = incKey + 1;
                    laTok   = substr(matchKey, laKey, 1);
                    if (strscan(text, laTok, incText, strlen(text)))
                    {
                        incText = strscan(text, laTok, incText, strlen(text));
                        if (!myMatch(
                                     substr(matchKey, incKey + 1, strlen(matchKey)),
                                     substr(text, incText, strlen(text))
                                   ))
                        {
                            incKey--;
                            incText++;
                        }
                        else
                        {
                            return true;
                        }
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    return true;
                }
                break;
            case #WC_ONE    :
                incText++;
                break;
            default         :
                if (tokKey == substr(text, incText, 1))
                {
                    incText++;
                }
                else
                {
                    return false;
                }
                break;
        }
    }
    if (incText < lenText)
        ret = false;

    return ret;
}


Источник: http://www.axaptapedia.com/Match
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
axcoder: PowerShell + Ax Blog bot DAX Blogs 1 09.01.2009 18:05
axaptapedia: Load Web Documents Blog bot DAX Blogs 1 03.01.2009 23:50
axaptapedia: Regular expressions Blog bot DAX Blogs 0 04.06.2008 02:06
axcoder: AxPath is supported by axaptapedia Blog bot DAX Blogs 0 11.05.2007 10:00

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.
Быстрый переход

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 11:11.
Powered by vBulletin® v3.8.5. Перевод: zCarot
Контактная информация, Реклама.