Search code examples
axaptamicrosoft-dynamicsdynamics-ax-2012dynamics-ax-2012-r2dynamics-ax-2012-r3

Strings paddings and alignments


I have tried today to save a file using TextIo. Just 3 lines:

Radio Station;MagicFM
Test;This is jost for testing purpose.
TV;TV_Brand

All good but then i read it.

enter image description here

I am not able to align the the things.

Maybe something like:

Radio Station         - MagicFM
Test                  - This is jost for testing purpose.
TV                    - TV_Brand

This is what i have in code:

info(strFmt("%1  - %2", strLFix( conPeek(con, 1), 20),conpeek(con, 2)));

I have played a bit with strRFix and strLFix but with no luck .. is there an easy way to accomplish this?


Solution

  • Aligning output like this is not the intended use of infolog, and as Matej said, the reason is because of the font. However, if you are wanting to use the infolog for display purposes, you probably will want to use it like this to get the following output:

    static void Job114(Args _args)
    {
        container       c, cc;
        int             i;
    
        c = [["Radio Station", "MagicFM"], ["Test", "This is jost for testing purpose."], ["TV", "TV_Brand"]];
        setPrefix("Output"); // SetPrefix is necessary to get the tabbing to function correctly
        for (i=1; i<=conLen(c); i++)
        {
            cc = conPeek(c, i);
            info(strFmt("%1\t%2", conPeek(cc, 1), conPeek(cc, 2)));
        }
    }
    

    Output