info-mac@uw-beaver (info-mac) (11/19/84)
From: leavitt.guest@XEROX.ARPA Dumb question # 541: Can anyone tell me (or provide a pointer to information about) how to read the Clipboard from inside a MacPascal routine? If so, please let me know. Many thanks for any help. Mike
info-mac@uw-beaver (info-mac) (11/20/84)
From: singer@harvard.ARPA (Andrew Singer)
MacPascal uses the standard ToolBox Scrap Manager to maintain the Clipboard.
All the information you need (and more than you probably want) is contained in the
Scrap Manager section of Inside Macintosh. The following sample program shows how
to read the contents of the Clipboard if it contains text. If you want to read
picture information out of the Clipboard, you're on your own...
program ReadClipboard;
const
GetScrap = $A9FD;
type
Buffer = packed array[0..32767] of Char;
BufferPtr = ^Buffer;
BufferHandle = ^BufferPtr;
var
theBuffer : BufferHandle;
Offset, BufferLength : Longint;
Index : Integer;
TypeRec : record
theType : packed array[1..4] of Char
end;
begin
theBuffer := NewHandle(0);
TypeRec.theType := 'TEXT';
BufferLength := LInLineF(GetScrap, theBuffer, TypeRec, @Offset);
if BufferLength < 0 then
if BufferLength = -102 then
writeln('*** Clipboard empty or does not contain text')
else
writeln('*** Error #', BufferLength : 1)
else
begin
for Index := 0 to BufferLength - 1 do
write(theBuffer^^[Index]);
end;
DisposeHandle(theBuffer)
end.
Jon F. Hueras, Think Technologies, Inc.
(singer@harvard)