Marcelo and Jos, I for one find this a really useful function which saved my looking up the obscure (to me) functions used within it. This has saved me probably at least an hour of searching through help. So basically you can get lost.
Manuel do not delete the file, it's helped me, thank you!
I think it was usefull. I didn't know how to do it, now I do.
01 Sep 2008
Alex Leung
Absolutely no problem at all!
19 Jul 2008
AHMET ANIL D?NDAR
THANKS FOR THE CODE
20 Sep 2007
m m
If ret ~= 0, it means that command 'hostname' has not been found in the system. So, an alternative way, based on enviromental variables, is tried. On the other hand, 'name' always is set to a value, either by system() or by getenv.
20 Sep 2007
Jos x@y.z
This (indeed trivial) function will produce a misleading error ('Undefined function or variable "name".') if "ret", for whatever reason, equals zero. If ret is always non-zero, why check? And why convert it to lower case?
The help could be improved, by adding a H1, SEE ALSO lines.
19 Sep 2007
Manuel Marin
Thanks for your comment but, from my point of view, if I have to rewrite 10 lines of code hundreds of times, independently of the difficulty, it worths to pack them into a function.
19 Sep 2007
Marcelo Perlin
Manuel, you can't publish something as trivial as this:
[ret, name] = system('hostname');
if ret ~= 0,
if ispc
name = getenv('COMPUTERNAME');
else
name = getenv('HOSTNAME');
end
end
name = lower(name);
I don't see how you can improve this because it is very trivial.