Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!uunet!mcvax!ukc!etive!lfcs!nick From: nick@lfcs.ed.ac.uk (Nick Rothwell) Newsgroups: comp.sys.mac.programmer Subject: Problem trying to PutScrap() some TEXT Keywords: PutScrap() Message-ID: <1907@etive.ed.ac.uk> Date: 3 May 89 10:35:03 GMT Sender: news@etive.ed.ac.uk Reply-To: nick@lfcs.ed.ac.uk (Nick Rothwell) Organization: LFCS Enya Admiration Society Lines: 48 Hello. Thanks for the suggestions about pasting some TEXT or a PICT along with a private scrap format - it seems to work. Well, almost. I'm following the instructions in the Scrap Manager chapter of IM, where it says that a TEXT scrap is a longword for the length, followed by the characters. So, I have this example program: static char *message = "\pHello world."; main() { Handle textHan; long len; struct Coerce_ {long len; char text[4];} *coerce; printf("ZeroScrap() -> %ld\n", ZeroScrap()); len = (long) message[0]; textHan = NewHandle(len + sizeof(long)); HLock(textHan); coerce = (struct Coerce_ *)(*textHan); coerce->len = len; BlockMove(&message[1], &coerce->text[0], len); printf("PutScrap() -> %ld\n", PutScrap(len + sizeof(long), 'TEXT', *textHan) ); printf("LoadScrap() -> %ld\n", LoadScrap()); } In other words, I map a record with the required structure ("Coerce_") onto the handle storage, fill in the fields, and that's it. When I view the scrap from the Finder's "Show Clipboard" command, the text is there, but there's a bum character at the front (whose ASCII value is the length of the text). The "char text[4]" is an experiment, in case there were alignment problems. I've also tried "char text[1]" and "Str255 text". There are rules that say that the thing being pasted must be an even number of bytes long. I've followed these rules, but the same thing happens. Has anybody had (or solved) the same kind of problems? As an aside: why do all the scrap manager calls return their error status as a long? Nick. Nick Rothwell, Laboratory for Foundations of Computer Science, Edinburgh. nick@lfcs.ed.ac.uk !mcvax!ukc!lfcs!nick ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ Fais que ton reve soit plus long que la nuit.