# Calling several functions inside a function?

**URL:** <https://discourse.julialang.org/t/calling-several-functions-inside-a-function/59270>\
**Category:** New to Julia\
**Created:** [April 14, 2021, 12:01pm UTC](https://discourse.julialang.org/t/calling-several-functions-inside-a-function/59270 "2021-04-14T12:01:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![marianoarnaiz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/marianoarnaiz/32/19377_2.png) [@marianoarnaiz](https://discourse.julialang.org/u/marianoarnaiz)\
**Post date:** [April 14, 2021, 12:01pm UTC](https://discourse.julialang.org/t/calling-several-functions-inside-a-function/59270/1 "2021-04-14T12:01:27Z")

</div>

Hi everyone.  
I was wondering if you guys can point me in the right direction here. I have quite a few functions with a bunch of inputs and outputs. I just wanted to make one that would help me organize them. The inner functions do not communicate properly with each other. I keep getting that the outputs of “fix\_SWF\_input” cannot be read by the following functions.

All the functions are inside the same file…

Any ideas?

```julia
function SW_Disp(Model,FEM_MESH,T0,Tstep,TF,Nmodes,Earth,Elastic,Anisotropy)

println("Forfward modelling ",Nmodes," Surface Wave Modes")
# Prepare Inputs
fks,Mesh,vpv,vsv,vsv_v,vsv_h,rhov,qsv,qR,Nsolid,hsolid,Nfluid,hfluid,vpfluid,vpfv,rhofv = fix_SWF_input(TF,Tstep,T0,FEM_MESH,Model,Elastic,Anisotropy);
# Compute de Dispersion for R Wave
kkR, cR, UR, evR = Rayleigh_Forwardsp(Nsolid,vsv_v,vpv,rhov,fks,hsolid,Nmodes,Nfluid,vpfv,rhofv,hfluid,qsv,Earth,Elastic);
println("Running: R wave dispersion")
# Compute de Dispersion for L Wave
kkL, cL, UL, evL = Love_Forwardsp(Nsolid,vsv_h,rhov,fks,hsolid,Nmodes,qsv,Earth,Elastic);
println("Running: L wave dispersion")
# Organize the Outputs
T, SWV,EG_FUNC_R_Z, EG_FUNC_R_R, EG_FUNC_L = fix_SWF_output(cR, UR, evR, cL, UL, evL, fks);
println("Done!")

##
return T, SWV,EG_FUNC_R_Z, EG_FUNC_R_R, EG_FUNC_L

end

```

---

<div class="post-metadata">

**Author:** ![rikh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rikh/32/204104_2.png) [@rikh](https://discourse.julialang.org/u/rikh)\
**Post date:** [April 14, 2021, 12:11pm UTC](https://discourse.julialang.org/t/calling-several-functions-inside-a-function/59270/2 "2021-04-14T12:11:13Z")

</div>

I think that it would be a good idea to combine your variables into types, probably structs. Then, you can move objects with clear names around instead of having to fall back to such long lists of variables and parameters.

Depending on how well the code is documented, so how clear it is what, for example, `cL` means, you might also want to use longer variable names.

---

<div class="post-metadata">

**Author:** ![amrods](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/amrods/32/2543_2.png) [@amrods](https://discourse.julialang.org/u/amrods)\
**Post date:** [April 14, 2021, 12:13pm UTC](https://discourse.julialang.org/t/calling-several-functions-inside-a-function/59270/3 "2021-04-14T12:13:38Z")

</div>

Or use `ComponentArrays`!! 🙂
