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$ Commented Jan 13, 2021 at 17:54
  • 1
    $\begingroup$ Sorry, didn't read it to the end. (#::"usage")&/@lst should work. $\endgroup$ Commented Jan 13, 2021 at 17:56
  • $\begingroup$ Quite surprisingly, this do work! Thanks! $\endgroup$ Commented Jan 13, 2021 at 18:11
  • $\begingroup$ I would prefer explicitly using MessageName[] for this: MessageName[#, "usage"] & /@ {General, Sin}. $\endgroup$ Commented Jan 13, 2021 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$ Commented Jan 14, 2021 at 21:55

1 Answer 1

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$ Commented Jan 13, 2021 at 18:09

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.