Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Print an expression and get the corresponding CellObject
ResourceFunction["PrintAsCellObject"][expr] prints expr as output and yields a CellObject corresponding to the printed cell. |
Print an expression:
In[1]:= |
Out[1]= |
Get the printed CellObject for manipulation in the front end:
In[2]:= |
Out[2]= |
View the corresponding Cell expression:
In[3]:= |
Out[3]= |
Print the first five primes:
In[4]:= |
Out[4]= |
Print graphics:
In[5]:= |
Out[5]= |
In[6]:= |
Out[6]= |
Multiple arguments will be concatenated together:
In[7]:= |
Out[7]= |
Print an unevaluated expression:
In[8]:= |
Out[8]= |
If no arguments are given, an empty cell will be printed:
In[9]:= |
Out[9]= |
In[10]:= |
Out[10]= |
The cells generated by PrintAsCellObject are equivalent to those generated by Print:
In[11]:= |
Out[11]= |
In[12]:= |
Out[12]= |
In[13]:= |
In[14]:= |
Out[14]= |
However, the output of Print is always Null:
In[15]:= |
Out[15]= |
In[16]:= |
Out[16]= |
PrintAsCellObject returns a CellObject similar to PrintTemporary, but does not automatically remove the cell:
In[17]:= |
Out[17]= |
In a kernel session that has no front end, the output is a Missing object:
In[18]:= |
Out[18]= |
Wrapping the evaluation in UsingFrontEnd will give a CellObject:
In[19]:= |
Out[19]= |
However, that CellObject is only useful in the front end instance that created it:
In[20]:= |
Out[20]= |
In[21]:= |
Out[21]= |
Unlike Print, PrintAsCellObject needs to wait for a response from the front end:
In[22]:= |
Out[22]= |
In[23]:= |
Out[23]= |
PrintAsCellObject does not inherit settings for GeneratedCellStyles:
In[24]:= |
Create a version of Print that is automatically cleared after a specified amount of time:
In[25]:= |
In[26]:= |
Out[26]= |
In[27]:= |
This work is licensed under a Creative Commons Attribution 4.0 International License