Can anyone think of a reason why someone would write:
Can anyone think of a reason why someone would write:
if (aRecordSet <> nil) and ((aRecordSet.State and cardinal(osStateOpen)) = Cardinal(osStateOpen)) then
begin
aRecordSet.Close;
end;
instead of just:
if (aRecordSet <> nil) and aRecordSet.State = adStateOpen?
begin
aRecordSet.Close;
end;
if (aRecordSet <> nil) and ((aRecordSet.State and cardinal(osStateOpen)) = Cardinal(osStateOpen)) then
begin
aRecordSet.Close;
end;
instead of just:
if (aRecordSet <> nil) and aRecordSet.State = adStateOpen?
begin
aRecordSet.Close;
end;
I should note that osStateOpen is an enumerated Type.
ReplyDeleteThey're not equivalent. The first is closer to:
ReplyDeleteif (aRecordSet <> nil) and (adStateOpen in aRecordSet.State) then
Maybe they were new to Delphi and weren't used to dealing with sets?
Thanks, Craig -- it's probably something like that.
ReplyDeleteMy first thought was Delphi 3 era compiler glitches.
ReplyDeleteWarren Postma I was looking at some "if Count>0 then for i:=0 to Count" blocks the other day and thinking happily that at least that bug is gone now.
ReplyDeleteIs State a bit set ?
ReplyDeleteAlso: osStateOpen or adStateOpen?
Maybe somebody discovered bit wise operations and as sometimes when you discover something new, you try to apply it "a little bit" to much ...
ReplyDelete