How replace the blank space?

RyuRyu Member Posts: 26
edited 2006-06-02 in Dynamics AX
Hi,

I want replace the blank space by a caracter in an export of data. Because I have a problem when I want read the csv file in Excel. The blanck space is considering like a Return.

Do you have an idea?

Thanks a lot.

Comments

  • David_CoxDavid_Cox Member Posts: 509
    Sorry I did not see the Axapta - A Dynamics answer is no good in here :oops:
    Analyst Developer with over 17 years Navision, Contract Status - Busy
    Mobile: +44(0)7854 842801
    Email: david.cox@adeptris.com
    Twitter: https://twitter.com/Adeptris
    Website: http://www.adeptris.com
  • RyuRyu Member Posts: 26
    Thank for your answer, but I don't find the repstr function.

    If I have understand, this function realize a replacement of character by another? It's true?
  • TitofTitof Member Posts: 4
    For me you have to write the function you need :

    You can try to do a "while" instruction with the instruction strfind.
    This function return the position of the caracter you are looking for.
    Then you can add your string.

    other interresting instructions :
    strlen : return the Lenght of the string
    strLtrim : delete the spaces in the beginning of the string
    strRtrim : delete the spaces in the end of the string
    substr : return a piece of a string

    En français :
    Pour moi, tu dois écrire la fonction dont tu as besoin car elle n'existe pas

    Tu devrais essayer de faire une boucle en utilisant l'instruction strfind.
    Cette instruction te permet de trouver la position du caractère que tu cherche.
    Tu peux ensuite remplacé ce caractère par celui de ton choix en faisant des concaténations de morceau de chaine.

    autres instructions qui peuvent te servir :

    strlen : pour connaitre la taille d'une chaine de caractère.
    strLtrim : supprime tous les blanc en début de chaine
    strRtrim : supprime tous les blanc en fin de chaine
    substr : renvoi un morceau de chaine de caractère

    Bon courage
  • RyuRyu Member Posts: 26
    Merci titof pour cette réponse. Je regarde pour créer cette fonction.
  • kashperukkashperuk Member Posts: 53
    Instead of writing your own code and debugging it after that, you might consider checking out the Global methods strReplace

    The code of strReplace is as follows:
    static str strReplace(str _str, str _fromStr, str _toStr)
    {
        int charNum;
        int fromLength  = strLen(_fromStr);
        int toLength    = strLen(_toStr);
    
        if (_fromStr != _toStr)
        {
            charNum = strScan(_str, _fromStr, 1, strLen(_str));
    
            if (fromLength != toLength)
            {
    
                while (charNum)
                {
                    _str = strDel(_str, charNum, fromLength);
                    _str = strIns(_str, _toStr, charNum);
                    charNum = strScan(_str, _fromStr, charNum + toLength, strLen(_str));
                }
            }
            else
            {
                while (charNum)
                {
                    _str = strPoke(_str, _toStr, charNum);
                    charNum = strScan(_str, _fromStr, charNum + toLength, strLen(_str));
                }
            }
        }
        return _str;
    }
    
    Vanya Kashperuk,
    My blog - http://kashperuk.blogspot.com
    MorphX IT in Russian - http://www.lulu.com/content/723888
    Inside Dynamics AX 4.0 in Russian - http://www.ozon.ru/context/detail/id/3714582
Sign In or Register to comment.