Question: Tell Maple to use a specific value, if the function is not real

I try to find a way to tell maple to use a specific value (e.g. zero), if the function is not real i.e. not defined, or complex etc.

Actually I want to find out, where a specific function is not defined, or has no real value. Is that possible with Maple?
Anyway, if there is no way to find out, where a specific function has no real value, I want to apply a specific real value to any value of the function, which is not real.

For example I tried the following:

restart;
h:=x->sqrt(x);
x -> sqrt(x)
g:=piecewise(h(x)<>real,0,h(x));
g(-1);


Unfortunately Maple does not print 0 for g(-1), but prints the function again.

Thanks a lot for helping.

Please Wait...