PutScrap
PutScrap Write one item to the desk scrap
#include <Scrap.h> Scrap Manager
long PutScrap( length, theType, srcPtr );
long length ; size, in bytes, of data to add to the scrap
ResType theType ; resource type; e.g., 'TEXT' or 'PICT'
Ptr srcPtr ; address of data to add to the scrap
returns an Error Code; 0=no error
PutScrap adds an item to the desk scrap.
length is the size, in bytes, of the data to be added to the scrap. For a 'TEXT'
item, it is the number of bytes; for a 'PICT' item it is the same as
the picSize field of the Picture structure.
theType is a resource type; a long integer, usually a 4-byte constant such as
'TEXT' or 'PICT'. It identifies the type of data you are adding to the
scrap.
srcPtr is the address of the data to be added to the desk scrap (note that this
is a direct pointer, not a handle).
Returns: a long integer Error Code. It may be one of:
noErr (0) No Error
noScrapErr (-100) Scrap is not initialized

Notes: It is your responsibility to ensure that each item in the desk scrap has a
different resource type. The normal sequence is to call ZeroScrap,
followed by one or more calls to PutScrap (one call per data type). For
instance, if the scrap contains more than one 'TEXT' scrap, then
GetScrap(...,'TEXT',...) will always fetch the first one.
If you use the TextEdit scrap, you can call TEToScrap to duplicate the
TextEdit internal scrap to the desk scrap (where it will be available for
DAs, etc.).
The desk scrap is written on the system startup volume (that is, the
volume that contains the currently open System File) rather than the
default volume. With hierarchical volumes, the scrap file is placed in the
folder containing the currently open System File and Finder. In addition, the
GetScrap and PutScrap functions will never return the result code
noScrapError; if the scrap has not been initialized, the ZeroScrap
function will be called. The InfoScrap function also calls ZeroScrap if
the scrap is un initialized.
In the following example, a 'TEXT' item and a 'PICT' item are written to the
desk scrap.
Example
#include <Scrap.h>
#include <Quickdraw.h>
char textMsg[]="here's some text for the scrap";
PicHandle thePic; /* we'll put a picture of it here */
ZeroScrap(); [TOKEN:12074] purge current scrap contents */
/* ---- store the 'TEXT' version of the message ----*/
PutScrap( strlen(textMsg), 'TEXT', textMsg );
/* ---- create and store a 'PICT' of the same message ---- */
SetRect( &r, 0,0,300,20 ); [TOKEN:12074] arbitrary size for frame */
thePic = OpenPicture( &r );
TextBox( textMsg, strlen(textMsg), &r, teJustLeft );
HLock( thePic ); /* lock before dereferencing */
/* store to desk scrap */
PutScrap( GetHandleSize(thePic), 'PICT', *thePic );
HUnlock( thePic );