Re: Opendialog problem



David Kerber wrote:

In article <xn0evjvcojwg6o2008@xxxxxxxxxxxxxx>,
newsgroups@xxxxxxxxxxxx says...
Jim P wrote:

if opendialog.execute = true then

Why would you do:

if mybooleanexpression = true then

It suffices (and is much safer) if one does:

if mybooleanexpression then

I realize it suffices, but why is it safer?

Because a boolean doesn't have to be 0 or 1.

If it is e.g. 3 (yes, I know this is not a valid value, but you
sometimes see it when API functions are declared as returning a boolean
when in fact they return something else), the comparison with True will
fail. If you don't compare to True, the value will be compared to 0
only, and even API functions declared the wrong way will either return
0 or a value <> 0.

--
Rudy Velthuis http://rvelthuis.de

"When you hear hoofbeats, think of horses, not zebras."
-- Old saying
.



Relevant Pages

  • Re: Opendialog problem
    ... It suffices (and is much safer) if one does: ... if mybooleanexpression then ... newsgroups if possible). ...
    (alt.comp.lang.borland-delphi)
  • Re: Opendialog problem
    ... Rudy Velthuis wrote: ... It suffices (and is much safer) if one does: ... if mybooleanexpression then ...
    (alt.comp.lang.borland-delphi)
  • Re: Opendialog problem
    ... Jim P wrote: ... It suffices (and is much safer) if one does: ... if mybooleanexpression then ...
    (alt.comp.lang.borland-delphi)
  • Re: adding to a ddmmyyyy date
    ... Better, yes; but why safer? ... so, in this context, if parseInt ... suffices. ... Similar considerations apply to ...
    (comp.lang.javascript)