I’m an apprentice for development working with C# and a few months ago I have been playing around with basics of Julia whenever I have some free time. I am still learning. I decided to start a small project calculating the average grade after receiving grades in school subjects. My problem is, I can’t compile it to an .exe and I am out of options. The links lead you to the screenshots for the following details.
This is my script:
My code
using Decimals
module CalculateAverageGrade
function _calculateAverageGrade()
list = Array{Int}(undef,11);
for i in 1:length(list)
saveInput::String = "";
validInput::Bool = false;
while(!validInput)
saveInput = strip(readline())
try
if isempty(saveInput) || !isinteger(parse(Int8, saveInput)) || parse(Int8, saveInput) <= 0 || parse(Int8, saveInput) > 6
println("Fehlerhafte Eingabe. Wiederhole deine Eingabe:")
continue
else
validInput = true;
end
catch e
println("Fehlerhafte Eingabe. Wiederhole deine Eingabe:")
continue
end
end
grade::Int8 = parse(Int8, saveInput);
list[i] = grade;
end
averageGrade = decimal(sum(list) / length(list))
println("Dein Notendurchschnitt ist: $averageGrade")
readline()
clear()
end
function julia_main()
_calculateAverageGrade()
end
end
You are free to give me feedbacks how to improve the code.
From what I have learned, in order to compile a project to an .exe, the .jl file needs to be in /<Projectname>/src/
. In /src
needs to be the desired .jl file with the same name as the main project folder.
In the REPL, I change the directory to \julia\CalculateAverageGrade
, then ]
, activate .
, add PackageCompiler
and then I get the following output:
1st Output
With import Pkg; Pkg.precompile()
I get the following:
And finally…
julia> create_app("CalculateAverageGrade.jl", "_Compiled")
ERROR: could not find project at "CalculateAverageGrade.jl"
although I confirmed with pwd()
I am in the project folder.
The REPL said I should use Pkg.resolve()
or Pkg.instantiate()
but this didn’t solve anything.