Saturday, 17 May 2014

Find a char in string and replace new char using x++ in Ax2012


In following example we are find a char i.e "," in string and replace this char with new one char i.e ".".

static void FindCharAndRepalce(Args _args)
{

    str a;
    int pos;
    ;
 
    a     = "100,00";
    pos =  strFind(a, ',',1, strLen(a));
    a     =  strDel(a,pos,1);
    a     =  strIns(a,'.',pos);
    info(strFmt("%1",a));
}

2 comments:

  1. There is a built in function for this: strReplace

    ReplyDelete
  2. Thanks.., this works if there is a replace condition based on the string found

    ReplyDelete