Quote:
As I presumed that @error is kind of global I thought I have to reset it to zero when leaving the function. Regarding your answers must that be wrong?


Not totally wrong.

@ERROR is a macro, but you can consider it to be a special type of global variable.

When you use a KiXtart function, command, user defined function or some COM entities the value of @ERROR is *automatically* set to the exit / error value.

If you don't explicitly set an exit value then the value of @ERROR is undefined so the simple rule is *always* set an exit value when leaving a UDF even if it doesn't seem to be relevant, and you won't have any problems.

The exit value of a function is set by using "Exit n" where "n" is an integer. Exit only exits the execution sandbox that it is *currently* in - function, script or Executed() code - and returns to the calling element. If you want to shut down the entire KiXtart instance you would use Quit.

BTW, you can get even trickier with Glenn's code:
 Code:
Function Alive($Host)
 Shell '%COMSPEC% /c Ping ' + $Host + '>NUL:'
 $Alive=Not @ERROR
 Exit @ERROR 
EndFunction


Do you see what I did there? ;\)