Re: Proper way to return a string



Terence <tbwright@xxxxxxxxx> wrote:

For any string operation I always use a function call because this can
return an error code,

I've noticed that I usually disagree with almost every style preference
Terence expresses. If there is an exact opposite of his preference,
you'll usually be right in guessing that opposite to be my preference.
It applies here.

For me, returning an error code is a reason to avoid using a function.

I strive to make my functions pure, at least in principle (i.e. I have
much f90 code where the functions aren't declared as pure, but do
otherwise meet the requirements for doing so), which means that I don't
tend to use a lot of functions. I do make some exceptions to purity, but
they are exceptions rather than the rule.

On the other hand, I do have several basic string functions because they
are things that are pure and do not have error codes. That includes such
things as case conversion, string comparison, and conversion of numeric
values to strings. (Yes, I know that the conversion can potentially
overflow fixed string lengths, but asterisk fill is ok for handling that
in my apps - any error handling for the asterisks can be separated).

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain| experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.



Relevant Pages

  • Re: Proper way to return a string
    ... I've noticed that I usually disagree with almost every style preference ... If there is an exact opposite of his preference, ... returning an error code is a reason to avoid using a function. ... last keystroke input, which allows signalling of function keys, pad ...
    (comp.lang.fortran)
  • Re: Various error codes: (was: Add AUXILIARY object class to inetOrgPerson entry)
    ... There are some legal implications of using English strings -- sometimes, ... >> error code as the first hex number of the server error ... >> The problem with returning string errors is that they need to be ... >> With DSIDs -- try searching the KB with the dsid value. ...
    (microsoft.public.windows.server.active_directory)
  • Re: using NULL pointers in COM
    ... *string" if I exit with an error code: ... you exit with an error code. ... pointed-to memory, a crash or heap corruption ensues. ... This has nothing to do with your initializing or not initializing the ...
    (microsoft.public.vc.atl)
  • Re: using NULL pointers in COM
    ... it is possible for me to not modify that "BSTR ... *string" if I exit with an error code: ... you exit with an error code. ...
    (microsoft.public.vc.atl)
  • An Error while running Error Handling Code
    ... strCallingProc As String, Optional vParameters, Optional bShowUser As ... Is there something that is wrong in the On Error code? ...
    (microsoft.public.access.modulesdaovba)