GetScrap
GetScrap Read one item from the desk scrap
#include <Scrap.h> Scrap Manager
long GetScrap(destHandle, theType, scrapOffset );
Handle destHandle ; an existing Handle to receive data
ResType theType ; type of data desired; e.g., 'TEXT' or 'PICT'
long * scrapOffset ; receives the scrap offset of the data
returns length of data, in bytes, or a 32-bit error code
GetScrap searches the desk scrap for a specified data type, and if found,
copies that data to an existing handle.
destHandle is an existing, previously- allocated Handle. The current data at that
handle (if any) is purged, and the scrap data is put in its place. If, on
entry, destHandle =0, then the scrap is not read, but the length (or
error code) and offset are returned.
theType specifies the type of data you want to get from the scrap; e.g., 'TEXT'
for text data or 'PICT' for picture data.
scrapOffset is the address of a 32-bit long int. Upon return, it will contain the
offset (in bytes) from the start of the desk scrap at which the data
was found, or 0 if no data matching theType was found.
You might use this to compare the relative locations in the scrap of
two types of data. It is likely that the first item in the scrap
( scrapOffset receives 0) is the "most native" type. And other items
are copies of the same information in different formats.
Returns: a 32-bit long integer. It may be one of:
noTypeErr (-102) No item of theType was found
any positive value (>0) Length of the item found, in bytes

Notes: GetScrap requires that destHandle be an existing handle, as obtained via
NewHandle (see the example, below). One exception is if you are just
interested in seeing if a specified data type is in the scrap (or just finding
its length). In that case, use destHandle =NIL and examine the return code.
If the scrap has not been initialized, the ZeroScrap function will be called.
The item is not removed from the scrap; it may be retrieved any number of
times until ZeroScrap is called.
To transfer directly from the desk scrap into the TextEdit internal scrap,
use TEFromScrap.
To read-in large pictures, you may need to customize the Quickdraw
picture retrieval function to read directly from the clipboard file on disk.
See SetStdProcs and StdGetPic.
Example
#include <Scrap.h>
Handle myHandle;
long scrapOffset, rc;
myHandle = NewHandle( 0 ); [TOKEN:12074] allocate 0-length data area */
rc = GetScrap( myHandle, 'TEXT', & scrapOffset );
if ( rc < 0 ) { /* . . . process the error . . . */ }
else {
SetHandleSize( myHandle, rc+1 ); /* prepare for printf() */
HLock( myHandle );
(* myHandle)[rc] = 0; /* make it ASCIIZ */
printf( "Scrap contained text: ’%s'\n", *myHandle );
HUnlock( myHandle );
}