【问题标题】:Strings paddings and alignments字符串填充和对齐
【发布时间】:2015-12-14 16:11:40
【问题描述】:

我今天尝试使用 TextIo 保存文件。只需 3 行:

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

一切都好,但后来我读了。

我无法对齐这些东西。

可能是这样的:

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

这是我在代码中的内容:

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

我玩了一些 strRFix 和 strLFix 但没有运气.. 有没有简单的方法来完成这个?

【问题讨论】:

    标签: axapta microsoft-dynamics dynamics-ax-2012 dynamics-ax-2012-r2 dynamics-ax-2012-r3


    【解决方案1】:

    像这样对齐输出不是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)));
        }
    }
    

    【讨论】:

    • 感谢您的详细回复,我看到您也提到了像 Matej 一样的字体,但是..我在哪里更改它?
    • 我不建议更改它,但它的形式是\Forms\SysInfologBrowser
    【解决方案2】:

    你必须像Courier 一样使用Fixed width font。您无法在视觉上与可变宽度字体对齐。

    【讨论】:

      【解决方案3】:

      您可以尝试使用System.String.Format 方法,例如:

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

      有关详细信息,请参阅 Align String with SpacesstrFmt Function [AX 2012]String.Format Method

      【讨论】:

        猜你喜欢
        • 2018-01-23
        • 2020-11-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-13
        • 1970-01-01
        • 2017-08-17
        相关资源
        最近更新 更多