How to create module and call it from another file?

Hi, I want to write a module and want to call some of its members such as type,function etc from another file by using the following command:
using ModuleName
Problem is to specify path of the module to julia.
How to specify the path of module? Please let me know with small example.

If you want a module that is not in the standard path (LOAD_PATH in Julia), just include it manually first. That is, if you have a file /foo/bar/SomeModule.jl that defines module SomeModule, you can do:

include("/foo/bar/SomeModule.jl")
using .SomeModule

The . in using .SomeModule ensures that the SomeModule in the current scope is what is used (see https://docs.julialang.org/en/latest/manual/modules/#Relative-and-absolute-module-paths-1).

8 Likes

Hello,
Yeah. I used same way. It’s working. I would like to know any
other way so that julia solver could know its location. Just use LOAD_PATH
at Julia Prompt. It will show two different directories for Julia to locate
module. It is like GAC in C#.
Is there any other way to specify path for module?

Thanks,