I found a work-around!!
Might be useful to others.
I give the main script an input variable, say 'Fun'. And, say, if Fun=[] then the main() is run as it would be without this trick. Alternatively if main() is called with Fun='test' then main() bypasses its ordinary job and instead runs an "eval('strings = Fun(varargin)')" you know with the correct setting of this string.
So now I can run my external script even from within the main-file and the external script can call functions written inside the main-file.
Voila!
.m:
function Out = main(Fun,In,varargin)
if isempty(Fun)
%%%%
else
if ~isempty(varargin)
str = 'varargin{1}';
for n = 2:nargin-2
str = [str,',varargin{',num2str(n),'}'];
end
eval(sprintf('Out = %s(%s);',Fun,str))
else
eval(sprintf('Out = %s;',Fun))
end
end
end
function a = test(b)
a = b^2;
end