Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: Problem trying to PutScrap() some TEXT Keywords: PutScrap() Message-ID: <29037@ucbvax.BERKELEY.EDU> Date: 4 May 89 10:18:17 GMT References: <1907@etive.ed.ac.uk> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 35 In article <1907@etive.ed.ac.uk> nick@lfcs.ed.ac.uk (Nick Rothwell) writes: _>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. You are confusing the Scrap manager's private, internal format with what you need to do. Just post the text. You don't need to include the length, just tell it the length: _> _> static char *message = "\pHello world."; _> _> main() _> { SystemEdit(3); /* fake multi-finder into externalizing clip */ _> printf("ZeroScrap() -> %ld\n", ZeroScrap()); _> printf("PutScrap() -> %ld\n", PutScrap(message[0], 'TEXT', &message[1])); _> } You don't need the LoadScrap(), that is an internal matter of the Scrap Manager. You don't need the call to SystemEdit in a real program, but you do in this toy if you want multi-finder to make your scrap change visible in other programs. Note: the general case of posting a string would have you use: (int) (unsigned int) (unsigned char) message[0] to make C sign extend the length byte correctly. This is only an issue for strings longer than 127 characters. I bind all this up in a macro called #define Length(s) ((int) (unsigned int) (unsigned char) (s)[0]) _> 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? Can you document this? I've never had any trouble posting an odd number of characters. _> As an aside: why do all the scrap manager calls return their error status _>as a long? Some knowledge isn't given to mortals.