5
$\begingroup$
GeneralUtilities`GetUsages["System`Sin"]

I want to get $\color{red}{\textbf{1}}$ plain string,but this function actually will give me some RowBox:

And the same case:

GeneralUtilities`GetUsages["System`Plot"]

I want to get $\color{red}{\textbf{4}}$ plain string from it:

{"Plot[f,{x,Subscript[x, min],Subscript[x, max]}] generates a plot of f as a function of x from Subscript[x, min] to Subscript[x,max].","Plot[{Subscript[f, 1],Subscript[f,2],…},{x,Subscript[x,min],Subscript[x, max]}] plots several functions Subscript[f,i].","Plot[{…,w[Subscript[f, i]],…},…] plots Subscript[f,i] with features defined by the symbolic wrapper w.","Plot[…,{x}∈reg] takes the variable x to be in the geometric region reg."}

Can any method do this?

$\endgroup$
1
  • $\begingroup$ @Kuba I have,we can copy it as plain string to get it by right click. $\endgroup$
    – yode
    Feb 24, 2017 at 13:55

1 Answer 1

5
$\begingroup$

How can I get the unchanged Box form of an arbitrary expression?

toBoxes = MathLink`CallFrontEnd[
    FrontEnd`UndocumentedTestFEParserPacket[#, True]
][[1]] &

How to convert arbitrary raw boxes directly into String?

toText = FrontEndExecute[
    FrontEnd`ExportPacket[#, "PlainText"]
][[1]] &

Composition[
    Map[toText]
  , Map[toBoxes]
  , StringSplit[#[[1]], "\n"] &
] @ GeneralUtilities`GetUsages["System`Plot"]
{
 "Plot[f,{x,Subscript[x, min],Subscript[x, max]}]generates a plot of \
 f as a function of x from Subscript[x, min]to Subscript[x, max]."
 ,
 "Plot[{Subscript[f, 1],Subscript[f, 2],\[Ellipsis]},{x,Subscript[x, \
 min],Subscript[x, max]}]plots several functions Subscript[f, i]."
 , 
 "Plot[{\[Ellipsis],w[Subscript[f, i]],\[Ellipsis]},\[Ellipsis]]plots \
 Subscript[f, i]with features defined by the symbolic wrapper w."
 ,
 "Plot[\[Ellipsis],{x}\[Element]reg]takes the variable x to be in the \
 geometric region reg."
} 
$\endgroup$
3
  • $\begingroup$ Good lesson to me.Thanks a lot. $\endgroup$
    – yode
    Feb 24, 2017 at 14:06
  • $\begingroup$ I'm shy to say I don't know the function of FrontEnd`UndocumentedTestFEParserPacket still.And the function of the True? $\endgroup$
    – yode
    Feb 24, 2017 at 15:12
  • $\begingroup$ @yode I can't say more than you can find in the topic linked above. $\endgroup$
    – Kuba
    Feb 24, 2017 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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