1
$\begingroup$

I have defined usage statements for a few symbols, e.g., foo::usage="This is how to use foo";

If I type ? foo or Information[foo], I get in return a nicely formated cell with the string information. However, the command returns Null:

t = Information[foo];
FullForm[t]

My question: How can I get the usage statement and store it in a new variables? I could of course do foo::usage, but let's say I have a list of symbols, lst = {foo, fii};, how could I map #::usage to all these symbols?

$\endgroup$
5
  • $\begingroup$ t=foo::usage huh? $\endgroup$
    – Roma Lee
    Jan 13 at 17:54
  • 1
    $\begingroup$ Sorry, didn't read it to the end. (#::"usage")&/@lst should work. $\endgroup$
    – Roma Lee
    Jan 13 at 17:56
  • $\begingroup$ Quite surprisingly, this do work! Thanks! $\endgroup$ Jan 13 at 18:11
  • $\begingroup$ I would prefer explicitly using MessageName[] for this: MessageName[#, "usage"] & /@ {General, Sin}. $\endgroup$ Jan 13 at 22:50
  • $\begingroup$ Salut @J. M., indeed, I came to this same solution. Would you want to turn your comment into an anwer? $\endgroup$ Jan 14 at 21:55
2
$\begingroup$

How can I get the usage statement and store it in a new variables?

 var = Information[foo]["Usage"]

enter image description here

$\endgroup$
1
  • $\begingroup$ This does not work for me. Mathematica v. 10.0. I get in return Null[Usage] $\endgroup$ Jan 13 at 18:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.