Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!purdue!bu-cs!dartvax!eleazar.dartmouth.edu!earleh From: earleh@eleazar.dartmouth.edu (Earle R. Horton) Newsgroups: comp.sys.mac.programmer Subject: "TN.248.DAs in Need of Time" in need of proofreader. Keywords: Sloppy, careless, wrong. Message-ID: <15462@dartvax.Dartmouth.EDU> Date: 7 Sep 89 21:40:30 GMT Sender: news@dartvax.Dartmouth.EDU Reply-To: earleh@eleazar.dartmouth.edu (Earle R. Horton) Organization: Thayer School of Engineering Lines: 38 The topic is setting flags in the high-order byte of a desk accessory's Device Control Entry. The quoted text is from Technote 248, August 1989 version. >The _BitClr and _BitSet Toolbox utilities are a mite on the >brain-damaged side... > >(I think whoever wrote these routines did this just to see if anyone >was paying attention.) > >Pascal > >BitClr(@dce^.dCtlFlags, 31 - dNeedTime);{ clear bit 5/dNeedTime bit. IM I-471 } >BitSet(@dce^.dCtlFlags, 31 - dNeedTime);{ set bit 5/dNeedTime bit. IM I-471 } > >C > >dce->dCtlFlags ^= dNeedTime; /* clear bit 5/dNeedTime bit */ >dce->dCtlFlags |= dNeedTime; /* set bit 5/dNeedTime bit */ > The Pascal code is incorrect. Substitute 7 for 31. Look who's paying attention now! The C code is grossly incorrect. The correct code is dce->dCtlFlags &= ~(1 << (dNeedTime + 8) ); /* Clear. */ dce->dCtlFlags |= (1 << (dNeedTime + 8)); /* Set. */ Furthermore, "dNeedTime" is not defined in the MPW C header files. This leads me to believe that the C code, and possibly the Pascal code, has never been tested or even typed in anywhere, except for the Technote. Tip 1: Test code before distribution. Tip 2: Know your operators. Earle R. Horton