X++中的字符串操作函数

每个语言中都会有很方便的操作字符串的函数库,可惜在X++的教程中没有看到这个函数库的列表,下面的函数是在看源代码的过程中发现的,汇集如下:
1.strlen(str text)
作用:获取字符串的长度
参数:text,待获取长度的字符串
返回值:字符串的长度

None.gif static   void  strlenExample(Args _args)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif     str source;
InBlock.gif     
int i ;
InBlock.gif    ;
InBlock.gif    source 
= "Axapta";
InBlock.gif     i 
= strlen(source);
InBlock.gif     print i;
InBlock.gif     pause;
ExpandedBlockEnd.gif}

2.strfind(str source,str toFindCharacters,int position ,int number)
作用:发现某个字符的位置
参数:source  源字符串
            toFindCharaters:待发现的字符
            position:开始搜索的位置
            number:搜索字符的个数
返回值:字符的位置

None.gif static   void  strfindExample(Args _args)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif     str source;
InBlock.gif     str destination;
InBlock.gif     
int i ;
InBlock.gif     ;
InBlock.gif
InBlock.gif     source 
= "Axapta Axapta";
InBlock.gif     destination 
= 'x';
InBlock.gif     i 
= strfind(source,destination,3,100);
InBlock.gif     print i;
InBlock.gif     pause;
ExpandedBlockEnd.gif}

None.gif
None.gif

3.strins(str source ,str toInsertStr,int postion)
作用:在源字符串的指定位置插入字符串
参数:source 源字符串
            toInsertStr 待插入的字符串
            postion 插入字符串的位置
返回值:插入字符串后的字符串

None.gif static   void  strinsExample(Args _args)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif     str source;
InBlock.gif     str destination;
InBlock.gif     
int i ;
InBlock.gif     ;
InBlock.gif
InBlock.gif     source 
= "Axapta Axapta";
InBlock.gif     destination 
= ' Axapta';
InBlock.gif     source 
= strins(source,destination,7);
InBlock.gif
InBlock.gif     print source;
InBlock.gif     pause;
ExpandedBlockEnd.gif}

None.gif

4.strdel(str source,int postion,int number)
作用:从指定位置开始在源字符串中删除指定长度的字符
参数:source源字符串
            postion 删除的开始位置
            number 删除字符的个数
返回值:删除指定字符后的字符串

None.gif static   void  strdelExample(Args _args)
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif     str source;
InBlock.gif     str destination;
InBlock.gif     
int i ;
InBlock.gif     ;
InBlock.gif
InBlock.gif     source 
= "Axapta Axapta";
InBlock.gif     source 
= strdel(source,1,7);
InBlock.gif
InBlock.gif     print source;
InBlock.gif     pause;
ExpandedBlockEnd.gif}

None.gif

5.strLFix,strRFix
这个难得说清楚,看代码吧,一看就明白了。
None.gif static   void  SpecialQueryBuild2()
ExpandedBlockStart.gifContractedBlock.gif
dot.gif {
InBlock.gif    str newStr;
InBlock.gif    ;
InBlock.gif    newStr 
= strLfix(int2str(8),10,"0");
InBlock.gif    print(newStr);
InBlock.gif    newStr 
= strRfix(int2str(8),10,"0");
InBlock.gif    print(newStr);
InBlock.gif
InBlock.gif    pause;
ExpandedBlockEnd.gif}

转载于:https://www.cnblogs.com/Farseer1215/archive/2006/06/05/417433.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值