I see! And looking through the code, and the headers, it appears that the function only returns 1 or 0, and the only other thing "val" is used for is to provide the return value. Therefore, I can eliminate the variable altogether, test the function's result directly in the loop, and simply end with "result := 1".

Thanks!