Own module and how to run it

I have to files:

  1. test.jl
x=5
y=4
include("./file.jl")
using .File

xyzadd(x,y)

xyzmultiply(x,y)

and
2)file.jl

module File

export xyzadd,xyzmultiply

function xyzadd(a,b) 
  print("Add: ")
  return a+b
end

function xyzmultiply(a,b) 
  print("Multiply: ")
  return a*b
end
end

I am using vscode with julia extension and when I touch F5 to compile it I get:
Add: Multiply: 20
Instead of: Add: 9 Multiply: 20
When I compile it by the line(ctrl+enter) everything works fine.
Do you know what’s the problem?

Running test.jl only returns the results of the last expression, which is xymultiply(a,b).

1 Like

I rewrited this file.jl file in that way:

module File

export xyzadd,xyzmultiply

function xyzadd(a,b) 
  return println("Add $(a+b)")
end

function xyzmultiply(a,b) 
  return println("Multiply: $(a*b)")
end
end```
and it works now.
1 Like

It returns also xyzadd(a,b) function, but not completely. I think it’s because of print function. It seems that I can display/print/etc. multiple statements only with using these functions.

So if I write:

a=6
b=4
a+b
a*b
a-b

It only show me the last result(a-b=2), but if I use:

a=6
b=4
println(a+b)
println(a*b)
a-b

It show me all results(even I didn’t use function in last statement.

module File

export xyzadd,xyzmultiply

function xyzadd(a,b) 
  return a+b
end

function xyzmultiply(a,b) 
  return a*b
end
end

That only show the second result.
I probably hurried up with this problem. Sorry.