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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 23.06.2016, 14:12   #1  
Blog bot is offline
Blog bot
Участник
 
25,475 / 846 (79) +++++++
Регистрация: 28.10.2006
palleagermark: One of those functions...
Источник: http://www.agermark.com/2016/06/one-...functions.html
==============

Now and then you come across AX functions you haven't heard about or that you have never really used. The lack of usage is often linked to the lack of documentation, but that's another story.

Today I came across the formattedStr2Num function. It is able to take a formatted string with some arithmetic and do a calculation of the expression. Something I have often seen developers write code to pass through the compiler and run the compiled code to do.

Here is a small example of how to use it:

static void formattedStr2NumDemo(Args _args)
{
str s = "(8 + 2) / 2 * 4";

info(strFmt("%1", formattedStr2num(s)));
}
The function actually also pass the expression through the compiler, but in a controlled way so can't just run any old arbitrary (dangerous) code through it.

If you combine this with a dynamic strFmt call, you have yourself a small expression calculation engine.

The timing for me to figure this out is awful, since the function is deprecated in AX 7. From AX 7 you could instead use something like ADO.NET's expressions parser in DataTable.Compute.

Thanks to Marco Scotoni, Johan van Veldhuizen and of course Peter Villadsen for being smarter than me and learning me this today through the Yammer group we share membership of. And I hope I wasn't the last AX developer on earth to learn about this function.

Источник: http://www.agermark.com/2016/06/one-...functions.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 

Похожие темы
Тема Автор Раздел Ответов Посл. сообщение
Van Vugt: NAV 2015 Glance 4: New Functions are Local by Default? Blog bot Dynamics CRM: Blogs 0 17.10.2014 16:51
atinkerersnotebook: Create Composite Menus That Combine Functions From Multiple Areas Blog bot DAX Blogs 0 02.07.2014 23:16
Microsoft Dynamics CRM Team Blog: New Xrm.Utility Functions in Update Rollup 8 for Microsoft Dynamics CRM 2011 and Microsoft Dynamics CRM Online Blog bot Dynamics CRM: Blogs 0 19.07.2012 01:11
Gareth Tucker: Reusable Jscript Library of Common Functions for CRM 2011 Blog bot Dynamics CRM: Blogs 0 16.04.2012 06:13
NAV Team: Test Automation Series 2 - Creation Functions Blog bot Dynamics CRM: Blogs 0 04.11.2010 11:01

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

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

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