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

Let's consider two functions here:


Thus I do:

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

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?


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

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


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

in place of "usage should be here".

  • $\begingroup$ 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? $\endgroup$ – Öskå Oct 1 '13 at 13:35
  • $\begingroup$ @Öskå Not sure how robust this is, but I would use something like this: Dynamic[First@ StringSplit[MessageName[Evaluate[whichfun], "usage"], "\n"]]. $\endgroup$ – Leonid Shifrin Oct 1 '13 at 14:02
  • $\begingroup$ It does the job, thanks! $\endgroup$ – Ö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"]]]], 

enter image description here


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.