Skip to main content
added 1 characters in body
Source Link
VLC
  • 9.9k
  • 1
  • 32
  • 60

Since it seems like you want constants accessible from a number of applications, why not create a package of constants and start each application by calling the constants you need. You would then change the constants only in the package should they ever need changing.

    (* Mathematica Package *)

    BeginPackage["CONSTANTS`"]
    (* Exported symbols added here with SymbolName::usage *)  
    
    constant1::usage = "some text"
    constant2::usage = "some text"
    constant3::usage = "some text"
    
    Begin["`Private`"] (* Begin Private Context *) 
    
    constant1[]: = 22;
    constant2[]: = "myConstant";
    constant3[]: = 0.618;
    
    End[] (* End Private Context *)
    
    EndPackage[]

See: Package development Place package in an appropriate directordirectory so Mathematica can see it.

To give your notebooks access to the constants:

Needs["CONSTANTS`"]

constant1[]
constant2[]
constant3[]

22
"myConstant"
0.618

Just a sketch but this should give you the idea.

Since it seems like you want constants accessible from a number of applications, why not create a package of constants and start each application by calling the constants you need. You would then change the constants only in the package should they ever need changing.

    (* Mathematica Package *)

    BeginPackage["CONSTANTS`"]
    (* Exported symbols added here with SymbolName::usage *)  
    
    constant1::usage = "some text"
    constant2::usage = "some text"
    constant3::usage = "some text"
    
    Begin["`Private`"] (* Begin Private Context *) 
    
    constant1[]: = 22;
    constant2[]: = "myConstant";
    constant3[]: = 0.618;
    
    End[] (* End Private Context *)
    
    EndPackage[]

See: Package development Place package in an appropriate director so Mathematica can see it.

To give your notebooks access to the constants:

Needs["CONSTANTS`"]

constant1[]
constant2[]
constant3[]

22
"myConstant"
0.618

Just a sketch but this should give you the idea.

Since it seems like you want constants accessible from a number of applications, why not create a package of constants and start each application by calling the constants you need. You would then change the constants only in the package should they ever need changing.

    (* Mathematica Package *)

    BeginPackage["CONSTANTS`"]
    (* Exported symbols added here with SymbolName::usage *)  
    
    constant1::usage = "some text"
    constant2::usage = "some text"
    constant3::usage = "some text"
    
    Begin["`Private`"] (* Begin Private Context *) 
    
    constant1[]: = 22;
    constant2[]: = "myConstant";
    constant3[]: = 0.618;
    
    End[] (* End Private Context *)
    
    EndPackage[]

See: Package development Place package in an appropriate directory so Mathematica can see it.

To give your notebooks access to the constants:

Needs["CONSTANTS`"]

constant1[]
constant2[]
constant3[]

22
"myConstant"
0.618

Just a sketch but this should give you the idea.

Source Link
Jagra
  • 14.6k
  • 1
  • 39
  • 82

Since it seems like you want constants accessible from a number of applications, why not create a package of constants and start each application by calling the constants you need. You would then change the constants only in the package should they ever need changing.

    (* Mathematica Package *)

    BeginPackage["CONSTANTS`"]
    (* Exported symbols added here with SymbolName::usage *)  
    
    constant1::usage = "some text"
    constant2::usage = "some text"
    constant3::usage = "some text"
    
    Begin["`Private`"] (* Begin Private Context *) 
    
    constant1[]: = 22;
    constant2[]: = "myConstant";
    constant3[]: = 0.618;
    
    End[] (* End Private Context *)
    
    EndPackage[]

See: Package development Place package in an appropriate director so Mathematica can see it.

To give your notebooks access to the constants:

Needs["CONSTANTS`"]

constant1[]
constant2[]
constant3[]

22
"myConstant"
0.618

Just a sketch but this should give you the idea.