Trim trailing zeroes in Dynamics AX

lnewmanlnewman Member Posts: 2
edited 2009-04-26 in Dynamics AX
Is there a method to trim a character (zeroes, in this scenario) from the end of a string? I've found strLTrim and strRTrim to trim spaces, but what about zeroes or any other character?

Comments

  • vmarinovvmarinov Member Posts: 11
    Create new job & paste this code.
    static void strRTrimZeroes(Args _args)
    {
        str txt = '505.000';
        str ch = '0';
        str result;
        str tmp;
    
        int i = strLen(txt);
    
        ;
    
        while(true)
        {
            tmp = subStr(txt, i, 1);
    
            if(i && tmp == ch)
            {
                i--;
            }
            else
            {
                break;
            }
        }
    
        result = strDel(txt, i+1, maxInt());
        
        info(result);
    }
    
Sign In or Register to comment.