# Dynamically show usage

As the title states I would like to dynamically show ::usage on several functions.

Let's consider two functions here:

funlist={Plot,Plot3D};


Thus I do:

Input[
Panel[
PopupMenu[Dynamic@whichfun, funlist], "usage should be here"],
Dynamic@whichfun]


Instead of "usage should be here" I obviously tried (Dynamic@whichfun)::usage but it's complaining that the Head is not a Symbol, so I tried to convert it to a Symbol but it still fails.

Thus the question is:

How can I convert Dynamic@whichfun in order to be able to have its usage?

-

## 2 Answers

This is the problem with evaluation, since MessageName is HoldFirst. You can use e.g.

Dynamic[MessageName @@ {whichfun, "usage"}]


or

Dynamic @ MessageName[Evaluate[whichfun], "usage"]


in place of "usage should be here".

-
Thanks! It seems like I'll always do the same mistakes when I use Dynamic. Additional Question (might be to be edited): Do you know how to display the first line of the usage only? –  Öskå Oct 1 '13 at 13:35
@Öskå Not sure how robust this is, but I would use something like this: Dynamic[First@ StringSplit[MessageName[Evaluate[whichfun], "usage"], "\n"]]. –  Leonid Shifrin Oct 1 '13 at 14:02
It does the job, thanks! –  Öskå Oct 1 '13 at 14:05

Use With to inject expression:

funlist = {Plot, Plot3D};
Input[Panel[PopupMenu[Dynamic@whichfun, funlist],
Dynamic[With[{t = whichfun}, MessageName[t, "usage"]]]],
Dynamic@whichfun]


-