# Own module and how to run it

**URL:** https://discourse.julialang.org/t/own-module-and-how-to-run-it/24273
**Category:** General Usage
**Tags:** package, module, vscode
**Created:** [May 16, 2019, 10:18am UTC](https://discourse.julialang.org/t/own-module-and-how-to-run-it/24273 "2019-05-16T10:18:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)
#### Post date: [May 16, 2019, 10:18am UTC](https://discourse.julialang.org/t/own-module-and-how-to-run-it/24273/1 "2019-05-16T10:18:31Z")

</div>

I have to files:

1. test.jl

```julia
x=5
y=4
include("./file.jl")
using .File

xyzadd(x,y)

xyzmultiply(x,y)

```

and  
2)file.jl

```julia
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?

---

<div class="post-metadata">

### Author: ![eliassno](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eliassno/32/18917_2.png) [@eliassno](https://discourse.julialang.org/u/eliassno)
#### Post date: [May 16, 2019, 10:29am UTC](https://discourse.julialang.org/t/own-module-and-how-to-run-it/24273/2 "2019-05-16T10:29:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)
#### Post date: [May 16, 2019, 10:30am UTC](https://discourse.julialang.org/t/own-module-and-how-to-run-it/24273/3 "2019-05-16T10:30:27Z")

</div>

I rewrited this file.jl file in that way:

````julia
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.
````

---

<div class="post-metadata">

### Author: ![wiktorkujawa](https://avatars.discourse-cdn.com/v4/letter/w/bc8723/32.png) [@wiktorkujawa](https://discourse.julialang.org/u/wiktorkujawa)
#### Post date: [May 16, 2019, 10:44am UTC](https://discourse.julialang.org/t/own-module-and-how-to-run-it/24273/4 "2019-05-16T10:44:54Z")

</div>

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:

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

```

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

```julia
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.

```julia
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.
