2
$\begingroup$

My objective is to obtain results from calculations in a CDF document that can be used elsewhere (in an R script, Excel, etc.) without having to type the results in by hand. I understand that writing to a file is not allowed for CDF documents.

The following in a CDF document copies a list of strings just fine to the clipboard:

Manipulate[z = Table[ToString[i], {i, n}],
 {n, 1, 100, 1, Appearance -> "Labeled"},
 Button["Copy results to clipboard", CopyToClipboard[z]]]

Figure 1

But the following in a CDF document does not produce anything in the clipboard:

Manipulate[z = "n = " <> ToString[n] <> "\nn2 = " <> ToString[n + 2],
 {n, 1, 100, 1, Appearance -> "Labeled"},
 Button["Copy results to clipboard", CopyToClipboard[z]]]

Figure 2

I'm using Mathematica 10.2 and CDF Player 10.3 on a Windows 7 PC and both scripts work in Mathematica. It's just the second one that doesn't work in the CDF Player.

Any suggestions (including those that avoid the clipboard approach) would be greatly appreciated.

$\endgroup$
  • $\begingroup$ Many FronEnd related functions are not available in CDF, that's probably another one. $\endgroup$ – Kuba Nov 4 '15 at 19:45
  • 1
    $\begingroup$ Further attempts seem to indicate that lists are copied to the clipboard but single strings are not. Surrounding z in the second example with curly brackets gets the information into the clipboard but the curly brackets are included and longer substrings are split. I'm still looking for a cleaner way to create code in the CDF that can be made available to another application. $\endgroup$ – JimB Nov 4 '15 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.