Steven Edwards wrote:
if (((int) Res || !Res) == -1)
Ehhhm, you probably mean something like 'if ((int)Res == -1 || !Res)', don't you? The one you've written makes no sense for me. Maybe that could even be replaced with a simple 'if ((int)Res < 0)', haven't looked at the whole code yet.
Best regards,
Colin