Finding previously defined messages in Mathematica

半世苍凉 提交于 2019-12-05 01:32:58

问题


Mathematica by default defines a lot of useful messages for signaling common errors, like functions being called with the wrong number of arguments or files not being found. In general, I prefer to use existing, defined messages wherever possible, because it makes it easier for them to be handled via mechanisms like Check, Quiet and On/Off. However, all my attempts at finding what messages are currently defined have failed; obvious approaches like

DownValues[MessageName] 

don't work at all.

Is there a trick I'm missing?

Thanks in advance.


回答1:


That's a good question. In principle, you can display any messages associated with a symbol by using Messages[<symbol>]. However, according to the documentation, the system messages are not loaded until the message is actually used. But, $MessageGroups (new in 7) does provide a list of some of the messages available, but not nearly all.

EDIT: After some looking, I found the file $InstallationDirectory/SystemFiles/Kernel/TextResources/English/Messages.m that appears to contain all of the system wide messages.



来源:https://stackoverflow.com/questions/1675387/finding-previously-defined-messages-in-mathematica

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!