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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 11.10.2009, 12:07   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
X++: Conditional breakpoint workaround
Источник: http://blogs.msdn.com/x/archive/2009...orkaround.aspx
==============

As you may know, the Ax debugger does not feature conditional breakpoints. It does obviously allow you to set breakpoints, but there is no option to make them active depending on some condition that is evaluated each time the breakpoint is encountered. There are some programming scenarios where it is highly advantageous to be able to do this, and providing this feature has been a recurring request from the Ax community.



As it happens, it is possible to mimic conditional breakpoints by using a statement that is not well known to many X++ programmers: The breakpoint statement(!). Whenever a breakpoint statement is executed, the debugger will wake up, just as if the user had set a breakpoint at the indicated position.



The way to emulate the conditional breakpoints is simply to provide the breakpoint inside an if statement:



If (condition)

Breakpoint;



in some interesting place in your source (where you would otherwise have put your conditional breakpoint). Now the whole range of what is allowed in expressions is at your disposal for determining whether or not the breakpoint should be executed: You could do stuff like



If ( (select firstonly Name from CustTable where CustTable.Name == ‘Jones’).RecId)

Breakpoint;



To break when Jones is present in the customer table.



There is another useful technique that you can use, involving the use of the setPrefix function. This function allows you to associate a string to the current call stack frame: When the current method returns, the call stack frame is destroyed and the string goes away. The getPrefix function provides a string that is the result of concatenating of all the strings on the call stack, with a trailing tab character (presumably to make printing them in the infolog reflect indentation).



If you are diligent in providing this information, typically with:



setPrefix(funcname())



you will be able to set a breakpoint according to where the method was called from (going down any number of stack frames) by examining this string. For instance by counting references to a particular function name you could easily express that the breakpoint should trigger when the function was called more than a predefined number of times.



You may want to create a static method in the Global class:



static public boolean EnableBreakpoints() { return true; }



And use that in the conditions:



If (EnableBreakpoints() && parm1 == 67)

Breakpoint;



so could easily turn them all off at once. In any case, do not ship your application to the customer with breakpoints in them!



As you can see, this is far above and beyond what can be done with normal expressions in conditional breakpoints. For your information, the .NET environment does support starting the debugger programmatically by using the System.Diagnostics.Debugger.Break() method.



This technique works on all versions of Ax.





Источник: http://blogs.msdn.com/x/archive/2009...orkaround.aspx
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
За это сообщение автора поблагодарили: alex55 (1).
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Отладка на методах контролов формы DAX 4.0 blokva DAX: Программирование 22 10.11.2011 16:26
BreakPoint-ы в разрезе пользователей naf DAX: Программирование 7 30.01.2009 17:22
daxcoder: Conditional Breakpoint Blog bot DAX Blogs 4 25.07.2008 14:47
Conditional question farlander DAX: Функционал 4 16.05.2007 09:05
axaptafreak: BREAKPOINT command in X++ Blog bot DAX Blogs 0 10.11.2006 01:14
Опции темы Поиск в этой теме
Поиск в этой теме:

Расширенный поиск
Опции просмотра

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

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

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