Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13039 > unrolled thread

Attaching a notebook to a message

Started byDavid Bailey <dave@removedbailey.co.uk>
First post2013-01-05 07:17 +0000
Last post2013-01-07 05:35 +0000
Articles 4 — 3 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Attaching a notebook to a message David Bailey <dave@removedbailey.co.uk> - 2013-01-05 07:17 +0000
    Re: Attaching a notebook to a message Frank K <fkampas@gmail.com> - 2013-01-07 05:35 +0000
      Re: Attaching a notebook to a message David Bailey <dave@removedbailey.co.uk> - 2013-01-08 04:04 +0000
    Re: Attaching a notebook to a message Helen Read <readhpr@gmail.com> - 2013-01-07 05:35 +0000

#13039 — Attaching a notebook to a message

FromDavid Bailey <dave@removedbailey.co.uk>
Date2013-01-05 07:17 +0000
SubjectAttaching a notebook to a message
Message-ID<kc8k33$b1p$1@smc.vnet.net>
I suddenly realised that there is (probably) a way to attach a notebook 
to a message here! The trick is to compress the expression which is the 
notebook:

Compress[NotebookGet[nb]]

For example:

"1:eJzVUslOwzAQdSlQtgouHLggIwS0YhGtqooTEruQgEoNggPikBQHLBw7xI5aOHHmyF8\
hxI/wFXicUNKUpYgTl5c3M2/\
Gs2TGEXV3ACEkhzQcCUUcIa7dDHj6NRxQqT6sLcKY2wdWPrb2AhH627ayI3c7JZtMsSY1s\
TybMSxtz2cE8/ghaxQioSNDR1HFyEeVesiIHI8LbF3Z/JIcU49IAgpoCL4I4YXy4+\
sGQlMF+P6506hATsOmaBmxcQxCQ6KpfW5/MtkCckQ0AdlZl3ige42JaN+\
30e6HrJvgq4eyHWKIzhpcNFg2eG5w3uCSwVaCV2INtLzP/VD99hT3T9PmFPcPc+\
YUvew1F08FI/w8UjTG4r9LjXcN0lqoelttJl4tQi9mnUZd8wlvk1SREU1OKb8QTYveEf5+\
lmcNDd1ZSp1vqw/t4JJymfoZOyw5rMlGqIRnK9qgY5lkORDQdbA6VJ+\
MuBsIrnb4xQkJJBXcqmjf2soqdkWAD2kjEFK4CkddSVyoVpYdqoq4UGso4ZAAV5dwebVUK\
qZKT8BJ1C0j28SlnCpdWlqwDW3bIVMr3HkDs7QGzA=="

Since Compress only uses printable ASCII characters, hopefully if you 
paste the above string into a notebook and perform:

string//Uncompress//NotebookPut

Of course, it is also possible to paste the raw output from NotebookGet, 
but that will be considerably more voluminous. Also a compressed string 
that becomes corrupted will be utterly destroyed, so it is probably 
safer than using the raw BoxForm expression.

NB: The 9.0 bug that messes up cell merges, also affects NotebookGet, so 
I would suggest you use 8.0.4 for this trick until 9.1 comes out.

This is really a test to discover if this survives the posting process!

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [next] | [standalone]


#13044

FromFrank K <fkampas@gmail.com>
Date2013-01-07 05:35 +0000
Message-ID<kcdmrf$m00$1@smc.vnet.net>
In reply to#13039
It worked on both Mathematica 8 and 9.  Version 9 had a message saying it had updated the styling.

[toc] | [prev] | [next] | [standalone]


#13052

FromDavid Bailey <dave@removedbailey.co.uk>
Date2013-01-08 04:04 +0000
Message-ID<kcg5sh$rcc$1@smc.vnet.net>
In reply to#13044
On 07/01/2013 05:35, Frank K wrote:
> It worked on both Mathematica 8 and 9.  Version 9 had a message saying it had updated the styling.
>
It is the creation of one of these objects that is a bit flaky under 
9.0.0, because NotebookGet can generate junk in particular situations.

You can use an alternative for NotebookGet containing a workround:

NotebookGet1[nb_]:=(NotebookGet[nb]/.RowBox[x___]/;(Length[{x}]!=1 || 
Head[x]=!=List):>RowBox[{x}]);

An easy way to check, of course, is to reverse the process on the string 
before posting it. Hopefully a version 9.0.1 will be out very soon!

Now we know it works, I should add a word of warning. Obviously it is a 
good idea to turn off dynamic execution when using an 'attached' 
notebook, unless you trust the sender.

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [next] | [standalone]


#13045

FromHelen Read <readhpr@gmail.com>
Date2013-01-07 05:35 +0000
Message-ID<kcdmrk$m02$1@smc.vnet.net>
In reply to#13039
That actually works. I'm not sure we should be doing this routinely, 
though. In most instances I think it's better to post as text, so that 
people can read and comment inline.

Still, it's a cool idea.

Helen Read
University of Vermont

On 1/5/2013 2:17 AM, David Bailey wrote:
> I suddenly realised that there is (probably) a way to attach a notebook
> to a message here! The trick is to compress the expression which is the
> notebook:
>
> Compress[NotebookGet[nb]]
>
> For example:
>
> "1:eJzVUslOwzAQdSlQtgouHLggIwS0YhGtqooTEruQgEoNggPikBQHLBw7xI5aOHHmyF8\
> hxI/wFXicUNKUpYgTl5c3M2/\
> Gs2TGEXV3ACEkhzQcCUUcIa7dDHj6NRxQqT6sLcKY2wdWPrb2AhH627ayI3c7JZtMsSY1s\
> TybMSxtz2cE8/ghaxQioSNDR1HFyEeVesiIHI8LbF3Z/JIcU49IAgpoCL4I4YXy4+\
> sGQlMF+P6506hATsOmaBmxcQxCQ6KpfW5/MtkCckQ0AdlZl3ige42JaN+\
> 30e6HrJvgq4eyHWKIzhpcNFg2eG5w3uCSwVaCV2INtLzP/VD99hT3T9PmFPcPc+\
> YUvew1F08FI/w8UjTG4r9LjXcN0lqoelttJl4tQi9mnUZd8wlvk1SREU1OKb8QTYveEf5+\
> lmcNDd1ZSp1vqw/t4JJymfoZOyw5rMlGqIRnK9qgY5lkORDQdbA6VJ+\
> MuBsIrnb4xQkJJBXcqmjf2soqdkWAD2kjEFK4CkddSVyoVpYdqoq4UGso4ZAAV5dwebVUK\
> qZKT8BJ1C0j28SlnCpdWlqwDW3bIVMr3HkDs7QGzA=="
>
> Since Compress only uses printable ASCII characters, hopefully if you
> paste the above string into a notebook and perform:
>
> string//Uncompress//NotebookPut
>
> Of course, it is also possible to paste the raw output from NotebookGet,
> but that will be considerably more voluminous. Also a compressed string
> that becomes corrupted will be utterly destroyed, so it is probably
> safer than using the raw BoxForm expression.
>
> NB: The 9.0 bug that messes up cell merges, also affects NotebookGet, so
> I would suggest you use 8.0.4 for this trick until 9.1 comes out.
>
> This is really a test to discover if this survives the posting process!
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk
>


-- 
HPR

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web