Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have been working on my senior project that involves the creation of a CDF with multiple Manipulateexpressions. I need to protect my code so I have been trying to create/encode a package that will run the program. I have gotten the program to work flawlessly as a notebook in MMA, but as a CDF I get shadowing errors. I have 54 functions in the code and many of my functions use the same variables which are changed by the user input. I have tried to put all of the code in a single package then set the initialization of each Manipulate to the same package, but I get errors. It seems like I need to have a package for each Manipulate, then have a function at the beginning of the program to call each package. I am not sure. Here is a scaled-down version.

Manipulate[dummyFunctionToDefineNullSet[], 
  Initialization :> (SuccessfulShotsFor = {};)]

<someManipulateObject>  

Manipulate[iSSF[], 
  Initialization :> (
    iSSF[] := 
     (PopupWindow[
          Button[Style[SomeStyle], , Background -> SomeBackground], 
          Button[
            (ptevent0 := 
              (If[Extract[#, {1}] < 575, {1150, 740} - #, #]) &;
              Show[Image, ImageSize -> {1150, 740}]), 
            AppendTo[SuccessfulShotsFor, ptevent0[MousePosition["Graphics"]]], 
            Appearance -> Frameless], 
        WindowTitle -> "Successful Shots For", WindowFrame -> "Normal", 
        Background -> RGBColor[51/240, 163/240, 220/240], 
        Editable -> False, TextAlignment -> Center , 
        WindowSize -> {1200, 825}, WindowFloating -> False, 
        WindowMargins -> {{0, Automatic}, {Automatic, 0}}]))]

<someManipulateObject>

Manipulate[
 Quiet[dSSF[SuccessfulShotsFor]], 
 Initialization :> (
   dSSF[
     SuccessfulShotsFor_] := 
       (Check[
          ImageCompose[
            SmoothDensityHistogram[SuccessfulShotsFor, 
              AspectRatio -> Full, PlotRange -> {{0, 1150}, {0, 740}}, 
              ColorFunction -> "GreenPinkTones", Frame -> False, 
              PlotRangePadding -> 0, ImageSize -> {1150, 740}], 
            SomeImage], 
          "ERROR: no user input"]
        Check[
         ImageCompose[
           ListPlot[SuccessfulShotsFor, 
             AspectRatio -> Full, PlotRange -> {{0, 1150}, {0, 740}}, 
             PlotMarkers -> {SomePlotMarker}, Frame -> False, 
             PlotRangePadding -> 0, ImageSize -> {1150, 740}, 
             Background -> RGBColor[0, 62/240, 5/240], Axes -> False], 
           SomeImage], 
         "ERROR: no user input"]))]

<someManipulateObject>

SuccessfulShotsFor has been giving me a ton of trouble. Once in a package, the value (which gets changed by the user input on the second Manipulate) takes on a different name which does not get passed on to the third Manipulate, which displays the images for the user to copy.

I am running these CDFs in Mathematica. I read about the $ContextPath, and I think that is the where the problem lies, but I am not experienced enough to implement the fix.

share|improve this question
    
Thank you for the links, but I am using a package so that I can protect my code. I do not want anyone to be able to mess with the 20 pages or so of code I have. In addition, I cannot use one Manipulate, because I have nearly 30 different manipulate objects with different functions. Any ideas? –  user8736 Jul 30 '13 at 20:54
1  
Have you tried the TrackedSymbols option in Manipulate? This specifies which variables will initiate changes in the Manipulate. Depending on how you have coded things, you may be able to specify only those that are needed within the given manipulate. –  bill s Jul 31 '13 at 0:25
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.