Developer Guidelines for Wolfram CDF Player Pro Compatibility

Programming for CDF Player Pro

Almost all programming and computational functions available in Mathematica can be used to build applications for CDF Player Pro, with just a few programming restrictions:

  • Wolfram Symbolic Transfer Protocol operations, including .NET/Link, are not supported. Avoid using commands such as Install, LinkConnect, Links and so on. This includes links to remote Mathematica kernels such as gridMathematica.
  • InputField will not accept arbitrary Mathematica programs, although it will accept mathematical expressions and any other input that does not look like a Mathematica program.
  • Alternative front ends to the kernel, such as those that could be written in Java, C/C++ or .NET, are not supported. The only supported method of using a kernel is through the Mathematica notebook interface.
  • GUIKit is not supported.

Preloading Data

CDF Player Pro applications do not require embedding of data, as you can load external data when it is needed. However, if your goal is to make an application as self-contained as possible, please consider these guidelines.

There are two basic approaches to embedding:

Initialization
Small blocks of code and data can be included in the Manipulate command using the Initialization option. For example:
Manipulate[myfunction[mydata,n],{n,0,1},
    Initialization:>(myfunction[dat_,n_]:=...;mydata={...})];

SaveDefinitions
For larger blocks of code, packages, or larger data files, it may be more convenient to define them before creating the Manipulate, then store their state within the Manipulate using the SaveDefinitions option. For example:
<<MyPackage`
mydata=Import[...];
Manipulate[myfunction[data,n],{n,0,1},SaveDefinitions->True];

Utilizing External Files

CDF Player Pro's ability to access external files at runtime provides several benefits.

Code Organization and Protection
For larger projects, organizing code in packages (including with Wolfram Workbench) promotes maintainable development. Instead of including your code inside a Manipulate with the Initialization command, you can include a call to the packages. All packages must be encoded either by using the Encode command or by using DumpSave to create a .mx binary file. For additional information, see this screencast.

You can then load this from your dynamic interface. For example:
Manipulate[myfunction[n],{n,0,1},Initialization:>Needs["EncodedPackage`"]]

A further advantage is that this encrypts your source code.

Real-Time or User-Specified Data
There are a number of ways of to incorporate external data calls in notebooks so that those with CDF Player Pro can use their own data or get pre-specified real-time data. Typical examples:

  • Initialize the application with data from a remote source:
    Manipulate[...,Initialization:>(data=Import["http://server.domain.com/latestdata.dat"])]
  • Capture data from a webcam:
    Manipulate[...,Button["Get image", data=Import["http://server.domain.com/webcam.jpg"]
  • Have the user select a local data file for analysis:
    Manipulate[..., Button["Load data", mydatapath = SystemDialogInput["FileOpen"]]]

Notebooks and Other Files

Only notebooks created by Mathematica can be opened—notebooks without valid file outline caches cannot be opened. Non-notebook files cannot be opened.

es ja pt-br ru zh