There's no need for the function to return a value. You could do this:
function add(num)
if num=1:beam(2)=5
else
sun(2)=5
endif:endfunction
And call it like:
Anyway, the problem with your code is that endfunction needs its own line if it is returning a value for some reason. So, this works (returns a value):
function add(num)
if num=1:beam(2)=5
else
sun(2)=5
endif
endfunction 0
and so does this (doesn't return a value):
function add(num)
if num=1:beam(2)=5
else
sun(2)=5
endif:endfunction
But what you're currently doing does
not work, which is this:
function add(num)
if num=1:beam(2)=5
else
sun(2)=5
endif:endfunction
Good luck