2

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?

4

3 回答 3

4

像这样对齐输出不是 的预期用途infolog,正如 Matej 所说,原因是字体。但是,如果您想将信息日志用于显示目的,您可能希望像这样使用它来获得以下输出:

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)));
    }
}

输出

于 2015-12-14T18:09:11.200 回答
1

您必须使用固定宽度字体,例如Courier. 您无法在视觉上与可变宽度字体对齐。

于 2015-12-14T16:40:55.567 回答
1

您可以尝试使用以下System.String.Format方法:

str       s; 
s = System.String::Format("{0, -15} - {1, -15}", "Radio Station", "MagicFM");    
info(s);

有关更多信息,请参阅将字符串与空格对齐strFmt 函数 [AX 2012]String.Format 方法

于 2015-12-14T18:11:36.980 回答