Skip to main content
typo
Source Link
  • (a). You have to call youyour package before creating DynamicModule because you need all static content (not held/dynamic) in the body of DM to be parsed and evaluated properly.
  • (a). You have to call you package before creating DynamicModule because you need all static content (not held/dynamic) in the body of DM to be parsed and evaluated properly.
  • (a). You have to call your package before creating DynamicModule because you need all static content (not held/dynamic) in the body of DM to be parsed and evaluated properly.
deleted 104 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803

First code block is only to create a test package:

Things above only mimics that you have a package somewhere for readers' tests ease.

Encode[path, pathEnc]; (*c*) encodedpackage = Import[pathEnc, "Text"]; Get @ pathEnc (*a*) CDFDeploy[  pathCDF, #, Method -> "Standalone", "Target" -> "CDFPlayer"  ] & @ With[{  With[ { source = encodedpackage (*b*)  },  , DynamicModule[{x = 1, stream}, , Column[{   Dynamic[{x, f[x]}],   Button["x++", x++],   Dynamic @ $ContextPath   }]   ,  UnsavedVariablesInitialization :> Module[{stream} , Initialization :> ( , stream = StringToStream @ source;source ; Get @ stream;stream ; Close @ stream;stream   )]   ]  ] 

Things above only mimics that you have a package somewhere for readers' tests ease.

Encode[path, pathEnc]; (*c*) encodedpackage = Import[pathEnc, "Text"]; Get @ pathEnc (*a*) CDFDeploy[  pathCDF, #, Method -> "Standalone", "Target" -> "CDFPlayer"  ] & @ With[{   source = encodedpackage (*b*)  },   DynamicModule[{x = 1, stream}, Column[{ Dynamic[{x, f[x]}], Button["x++", x++], Dynamic @ $ContextPath   }]   ,  UnsavedVariables :> {stream} , Initialization :> (  stream = StringToStream @ source; Get @ stream; Close @ stream;   )   ]  ] 

First code block is only to create a test package:

Encode[path, pathEnc]; (*c*) encodedpackage = Import[pathEnc, "Text"]; Get @ pathEnc (*a*) CDFDeploy[ pathCDF, #, Method -> "Standalone", "Target" -> "CDFPlayer" ] & @ With[ { source = encodedpackage (*b*) } , DynamicModule[{x = 1} , Column[{   Dynamic[{x, f[x]}],   Button["x++", x++],   Dynamic @ $ContextPath }] , Initialization :> Module[{stream} , stream = StringToStream @ source ; Get @ stream ; Close @ stream ] ] ] 
deleted 61 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803

###Scheme

Outline

Needs @ yourPackage (*a*) CDFDeploy[...]&CDFDeploy @ With[{   { source = (text content of the package, encoded or whatever)Import[packagePath] (*b*)   }, , DynamicModule[ { ... },  , ...   ,  Initialization :>(  ( Get[#]&Get @ StringToStream @ source  ) ] 

###Scheme

Needs @ yourPackage (*a*) CDFDeploy[...]& @ With[{ source = (text content of the package, encoded or whatever) (*b*)  }, DynamicModule[{ ... },  ...   ,  Initialization:>(  Get[#]& @ StringToStream @ source  ) ] 

Outline

Needs @ yourPackage (*a*) CDFDeploy @ With[   { source = Import[packagePath] (*b*) } , DynamicModule[ { ... } , ... , Initialization :> ( Get @ StringToStream @ source ) ] 
Minor spelling fixes.
Source Link
Emilio Pisanty
  • 10.5k
  • 1
  • 39
  • 74
Loading
added 28 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
added 14 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
Source Link
Loading
deleted 2 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
added 198 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
deleted 56 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
added 3 characters in body
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading
Source Link
Kuba
  • 138.9k
  • 13
  • 297
  • 803
Loading