Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!ucsd!ucbvax!bloom-beacon!rsfinn From: rsfinn@athena.mit.edu (Russell S. Finn) Newsgroups: comp.sys.mac.programmer Subject: Re: @ Operator & Keydown events in Think Pascal? Message-ID: <1990Nov2.235814.25686@athena.mit.edu> Date: 2 Nov 90 23:58:14 GMT References: <3234.27315d8c@cc.nu.oz.au> Sender: daemon@athena.mit.edu (Mr Background) Organization: Massachusetts Institute of Technology Lines: 40 In article <3234.27315d8c@cc.nu.oz.au> mebhl@cc.nu.oz.au writes: >The crucial function has the form: > > function TestKey (i: longint): boolean; > var > myKeys: keyMap; > begin > GetKeys(myKeys); > TestKey := BitTst(@myKeys[1], i) > end; > >When this is run, THINK Pascal tells me that: > > @ can't be applied to a component of a packed type. Right, because KeyMap is defined as PACKED ARRAY[0..127] OF BOOLEAN. >But the code obviously used to work. What's changed, and what can I change >get it to work again? In versions of THINK Pascal earlier than 3.0, PACKED ARRAY OF BOOLEAN was not implemented, and so KeyMap had to be defined as PACKED ARRAY[0..3] OF LONGINT instead. This required the circumlocution described above. Since version 3.01, PACKED ARRAY OF BOOLEAN is supported correctly, and you can now just say TestKey := myKeys[keyCode] where keyCode is the code of the desired key (see the Event Manager chapter of Inside Macintosh). Note that if you're just interested in modifier keys, you can simply call GetNextEvent and examine the modifier field of the EventRecord, even if GetNextEvent returned FALSE (as someone has previously pointed out). Of course, this works for WaitNextEvent also. -- Russ rsfinn@{athena,lcs}.mit.edu