I’m wondering if anyone can help with this issue.
So the minimal example is as follows.
Suppose I have a “A.jl” file in the present working directory and it contains the following.
f = [x+y; x+2];
And I want to read this file into another jl file called “B.jl”.
In the “B.jl” file, I would have the following
x = 2 y = 2 include("A.jl")
Then the output is f = [4;6].
And this works as intended, but what if I want to use include inside a function? I know that include brings variables only work in global scope, so there is a problem. Basically something like this in the “B.jl” file.
function f() x = 2 y = 2 include("A.jl") end
This would throw an error. I searched on Julia’s discourse and I found this link.
So this link says that I could come up with a macro to allow for some variables to be read in locally as well, but using macro is impossible in my case since the variables inside “A.jl” is around 70x80 matrices and probably more than 100 variables (which I created using SymEngine in by running another function). So creating macro one by one seems infeasible.
So I guess I’m wondering if you guys had any idea on how to read such a file into a local scope? This workflow works in Matlab, but this doesn’t work in Julia.
Thank you in advance guys.