Using:
Windows 11
Julia 1.11.4
Visual Studio Code 1.98.2
julialang extension 1.127.2
I get an error message whenever I try to run any code from VSCode if it contains a user-defined function. Here’s an example I threw together:
println(x1,x2)
function quadratic_formula(a, b, c)
discrim = b^2 - 4.0*a*c
if discrim >= 0.0
x1 = (-b + sqrt(discrim))/(2.0*a)
x2 = (-b - sqrt(discrim))/(2.0*a)
else
return nothing
end
return (x1, x2)
end```
Using CTRL-F5 gives this error message:
ERROR: LoadError: UndefVarError: `quadratic_formula` not defined in `Main`
Stacktrace:
[1] top-level scope
@ c:\Users\xxxxx\OneDrive\Documents\xxxxx\Examples\quadratic.jl:1
[2] include(fname::String)
@ Main .\sysimg.jl:38
[3] run(debug_session::VSCodeDebugger.DebugAdapter.DebugSession, error_handler::VSCodeDebugger.var"#3#4"{String})
@ VSCodeDebugger.DebugAdapter c:\Users\xxxxx\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\DebugAdapter\src\packagedef.jl:122
[4] startdebugger()
@ VSCodeDebugger c:\Users\xxxxx\.vscode\extensions\julialang.language-julia-1.127.2\scripts\packages\VSCodeDebugger\src\VSCodeDebugger.jl:45
[5] top-level scope
@ c:\Users\xxxxx\.vscode\extensions\julialang.language-julia-1.127.2\scripts\debugger\run_debugger.jl:12
[6] include(mod::Module, _path::String)
@ Base .\Base.jl:557
[7] exec_options(opts::Base.JLOptions)
@ Base .\client.jl:323
[8] _start()
@ Base .\client.jl:531
in expression starting at c:\Users\xxxxx\OneDrive\Documents\xxxxx\Examples\quadratic.jl:1
Using F5 gives this message:
Exception has occurred: UndefVarError
UndefVarError: `quadratic_formula` not defined in `Main`
Stacktrace:
[1] top-level scope
@ c:\Users\jbmcv\OneDrive\Documents\MasterPC\Examples\quadratic.jl:1
I'm able to evaluate the quadratic_formula function by putting my cursor on the final line and executing "Shift Enter", but this doesn't fix the issue. I've searched the available resources and can't find anything that seems helpful. I'm in the process of porting an old Fortran 77 code of mine and will need to be able to run it in the debugger. Any help would be appreciated!