Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83 (MC840302); site boring.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!mcvax!boring!guido From: guido@boring.UUCP Newsgroups: net.micro.mac Subject: How to read the scrap for TextEdit (Re: ascii.question 2) Message-ID: <6655@boring.UUCP> Date: Wed, 16-Oct-85 15:34:42 EDT Article-I.D.: boring.6655 Posted: Wed Oct 16 15:34:42 1985 Date-Received: Fri, 18-Oct-85 21:23:32 EDT References: <1034@ttds.UUCP> Reply-To: guido@mcvax.UUCP (Guido van Rossum) Organization: "Stamp Out BASIC" Committee, CWI, Amsterdam Lines: 33 Apparently-To: rnews@mcvax.LOCAL Here is an example of how to get the global Scrap into the TextEdit scrap in SUMacC. The global variables TEScrapHandle and TEScrapLen are actually #defines in : #define TEScrapHandle (*(Handle *)0xab4) #define TEScrapLen (*(short *)0xab0) Note that I use long instead of int for the offset and length returned by GetScrap; with SUMacC these are identical but other C systems may have 2-byte ints, and the Toolbox really requires 4-byte longs here. (Wish the SUMacC header files were more precise in this matter -- this could enhance portability between difference C systems!) Guido van Rossum, CWI, Amsterdam (guido@mcvax.UUCP) static int scrap_count; /* Should be initialized to, e.g., ! InfoScrap()->scrapCount */ get_scrap (){ long off, len; ScrapStuff *scrap_stuff; scrap_stuff = InfoScrap (); if (scrap_count == scrap_stuff->scrapCount) return; scrap_count = scrap_stuff->scrapCount; len = GetScrap (TEScrapHandle, "TEXT", &off); if (len >= 0) TEScrapLen = len; /* Else, it was probably a PICT or other type of scrap; in this case TEScrapHandle's contents has not been touched. */ }