Quote:

If Exist()

That just doesn't work with 0 for success so he used positive logic for testing.

Returns:
0 File not found
1 File found





That is a very bad example to choose

You've assumed that because the function is returning a 1 or a 0 that this is the same as returning an error state.

But is not is it? The 1 or 0 returned by Exist() is data and has nothing to do with the error condition.

This still fits into the simple rule set:
  1. If a function is designed to return data it should return FALSE, 0 or null on an error where that will not prejudice the purpose of the function.
  2. If a function has no explicit return value then it should return an error status where "0" is success.

Now the example you have chosen (Exist) is designed to explicitly return a value, so it matches rule 1. If an error occurs then 0 will be returned, which fits it's purpose and the way it is used in scripts.

AScan is a good example of a function which fits rule 1 but cannot return 0 on an error which is a bit of a design error IMO.