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

 
 
Опции темы Поиск в этой теме Опции просмотра
Старый 29.06.2011, 01:13   #1  
Blog bot is offline
Blog bot
Участник
 
25,643 / 848 (80) +++++++
Регистрация: 28.10.2006
dax-ideas: Con2str and str2con functions in the Global Class
Источник: http://dax-ideas.blogspot.com/2011/0...in-global.html
==============

Many a times we use the functions which are available in the global class of AX.
2 important methods which we normally use during the import of text file or CSV file is con2str() and str2con() functions. Both these functions have limitations of use .

With respect to con2str it is that the string returned from the container cannot exceed more than 1000 char and with respect to the str2con the limitation is that chopps of the zero added before the string for example if you add str2con("00001,0002",",") then the entry in the container would be 1 and 2 respectively at position 1 and 2 of the container . This creates an issue where the Items in the system starts with the 0.

So I twisted both the functions slightly to get our desired o/p
i.e. String greater than 1000 char with con2str() method and
inclusion of 0 with str2con() method.

Here is what I changed :

static str con2strwithchange(container c, str 10 sep = ',')


{
int idx = 0;
int len = conlen(c);
str tmp;
str retStr;
;
while (idx < len)
{
idx += 1;
if (retStr)
retStr += sep;
tmp = conpeek(c,idx);
retStr += tmp;
}
return retStr;
}




static container str2conChanged(str _value, str 10 _sep = ',')


{
int length = strlen(_value);
int i = 1;
int j = strscan(_value, _sep, 1, length);
container ret;
void add2Ret(str _current)
{
// v-artemt, 26 Jul 2004, PS#: 1741
//if (match('', _current))
// ret += str2int(_current);
//else
ret += _current;
}
;
while (j)
{
add2Ret(substr(_value, i, j-i));
i = j+1;
j = strscan(_value, _sep, i, length);
}
add2Ret(substr(_value, i, length-i+1));
return ret;
}


Источник: http://dax-ideas.blogspot.com/2011/0...in-global.html
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору.
 


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

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

Рейтинг@Mail.ru
Часовой пояс GMT +3, время: 10:43.