在Axapta中实现trim函数
在Axapta中找了半天都没找到字符串的trim函数,用strFind和subStr写了一个,应该有更好的实现方式,先凑合着用吧.
补记:
今天在System Document->Functions里找到了strlTrim和strrTrim两个函数,公用的系统函数解释都在这里放着在,有时间看一下,还是挺有用的,嗯.
static void strTrim(args a)
{
int position;
str srcStr;
;
srcStr = " aaa aaa ";
position = 1;
//left trim
while(true)
{
position = strFind(srcStr," ",1,1);
if(!position)
break;
srcStr = substr(srcStr,position+1,strlen(srcStr)-position);
}
//right trim
while(true)
{
position = strFind(srcStr," ",strlen(srcStr),1);
if(!position)
break;
srcStr = substr(srcStr,1,position-1);
}
print srcStr;
pause;
}
{
int position;
str srcStr;
;
srcStr = " aaa aaa ";
position = 1;
//left trim
while(true)
{
position = strFind(srcStr," ",1,1);
if(!position)
break;
srcStr = substr(srcStr,position+1,strlen(srcStr)-position);
}
//right trim
while(true)
{
position = strFind(srcStr," ",strlen(srcStr),1);
if(!position)
break;
srcStr = substr(srcStr,1,position-1);
}
print srcStr;
pause;
}
补记:
今天在System Document->Functions里找到了strlTrim和strrTrim两个函数,公用的系统函数解释都在这里放着在,有时间看一下,还是挺有用的,嗯.
static void strTrim(Args _args)
{
str aa = " aa ";
;
aa = strltrim(aa);
aa = strrtrim(aa);
print aa;
pause;
}
{
str aa = " aa ";
;
aa = strltrim(aa);
aa = strrtrim(aa);
print aa;
pause;
}