Please see the previous responses: https://groups.google.com/d/msg/julia-users/sTo_Nr85AnE/0wKr50I6CgAJ
Also read the 'Scope' section of the manual: http://docs.julialang.org/en/release-0.4/manual/variables-and-scoping/ On Wed, Mar 23, 2016 at 2:41 PM, new to Julia <[email protected]> wrote: > I have a question for calling files in Julia: > > I have two jl files. And I can call one file from the other file. However, > the variable or constant defined in that file cannot be used in the other > file. I am wondering that how to fix this? The following is a simple > example. > > function test(x) > c=2; > y1=6*x; > y2=x/5; > y1,y2 > end > pwd() > > > ## test and test2 are used for calling functions in Julia > function test2(x) > include("test.jl") > yold,ynew=test(x/c); > y3=yold+10; > y4=ynew-10; > yold2,ynew2=test(x) > y5=yold2+20; > y6=ynew2-20; > y3,y4,y5,y6 > end > y3,y4,y5,y6=test2(100) > > > However, when I run this test2, there is a error comes out: saying that c > is not defined. > > Thank you very much. > >
