Formatting usage messages

前端 未结 4 1814
离开以前
离开以前 2021-02-03 14:04

If you take a look at the Combinatorica package in Mathematica8 in (mathematicapath)/AddOns/LegacyPackages/DiscreteMath/Combinatorica.m you wi

4条回答
  •  滥情空心
    2021-02-03 14:52

    OK, here's the explanation.

    Digging in the Combinatorica source reveals this:

    (* get formatted Combinatorica messages, except for special cases *)
    If[FileType[ToFileName[{System`Private`$MessagesDir,$Language},"Usage.m"]]===File,
    Select[FindList[ToFileName[{System`Private`$MessagesDir,$Language},"Usage.m"],"Combinatorica`"],
    StringMatchQ[#,StartOfString~~"Combinatorica`*"]&&
    !StringMatchQ[#,"Combinatorica`"~~("EdgeColor"|"Path"|"Thin"|"Thick"|"Star"|"RandomInteger")~~__]&]//ToExpression;
    ]
    

    It is loading messages from ToFileName[{System`Private`$MessagesDir,$Language},"Usage.m"], which on my machine is SystemFiles\Kernel\TextResources\English\Usage.m. This is why all usage messages are created conditionally in Combinatorica.m (only if they don't exist yet). If you look in Usage.m you'll see it has all the ugly boxes stuff that @ragfield mentioned.

    I guess the simplest way to have formatted messages is to edit them in the front end in a notebook, and create an auto-save package. This way you can use all the front end's formatting tools, and won't need to deal with boxes.

提交回复
热议问题