zoukankan      html  css  js  c++  java
  • X++中的字符串操作函数

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

    static void strlenExample(Args _args)
    {
         str source;
         
    int i ;
        ;
        source 
    = "Axapta";
         i 
    = strlen(source);
         print i;
         pause;
    }

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

    static void strfindExample(Args _args)
    {
         str source;
         str destination;
         
    int i ;
         ;

         source 
    = "Axapta Axapta";
         destination 
    = 'x';
         i 
    = strfind(source,destination,3,100);
         print i;
         pause;
    }


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

    static void strinsExample(Args _args)
    {
         str source;
         str destination;
         
    int i ;
         ;

         source 
    = "Axapta Axapta";
         destination 
    = ' Axapta';
         source 
    = strins(source,destination,7);

         print source;
         pause;
    }

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

    static void strdelExample(Args _args)
    {
         str source;
         str destination;
         
    int i ;
         ;

         source 
    = "Axapta Axapta";
         source 
    = strdel(source,1,7);

         print source;
         pause;
    }


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

        pause;
    }
  • 相关阅读:
    【JAVASCRIPT】call和apply的用法以及区别
    web开发中的支付宝支付和微信支付
    【input】标签去除默认样式
    npm run build后如何打开index.html跑起项目
    Sass的混合-@mixin,@include
    ios h5 长按时出现黑色透明遮罩
    ios h5 长按放大镜效果关闭
    vue.$nextTick 解决了哪些问题
    原生JS代码封装(将字符串转换为日期 2019.08.24 )
    原生JS代码封装(获取年月日时分秒 )
  • 原文地址:https://www.cnblogs.com/Farseer1215/p/417433.html
Copyright © 2011-2022 走看看