yonge@pnet02.gryphon.com (Yam Hui) (12/02/89)
Hello, I need help in using clipboard on the Amiga. I am currently using Lattice 5.04 C compiler. And I could not find any sample code sitting around that I could use anywhere, including the manuals. The sample code in the ROM kernal manual does not work at all, and came without comments. Any information would be greatly appreciated. Thank you. Yonge. UUCP: {ames!elroy, <backbone>}!gryphon!pnet02!yonge INET: yonge@pnet02.gryphon.com
root@ccave.UUCP (Juergen Hermann) (12/04/89)
In article <22940@gryphon.COM> yonge@pnet02.gryphon.com (Yam Hui) writes: >that I could use anywhere, including the manuals. The sample code in the ROM >kernal manual does not work at all, and came without comments. Well, this is uncommented also, but I can assure you that it works :-). It's written for Manx 3.6 w/ 16 bit ints, but should also work with Lattice. It writes a global array of lines (lines[i].buf) to the clipboard, formatted as IFF.FTXT. void ClipStr (ClipIO, str, len) struct IOClipReq * ClipIO; char * str; int len; { ClipIO->io_Command = CMD_WRITE; ClipIO->io_Flags = 0; ClipIO->io_Data = (STRPTR) str; ClipIO->io_Length = (LONG) len; DoIO (ClipIO); } /* ClipStr */ int clip_msg () { struct MsgPort * Port = NULL; struct IOClipReq * ClipIO = NULL; long length; register i; int err = 0; if (line_count > 0) { err = 1; if ((Port = CreatePort (NULL, 0L)) != NULL && (ClipIO = CreateExtIO (Port, (long) sizeof (*ClipIO))) != NULL) { if (OpenDevice ("clipboard.device", PRIMARY_CLIP, ClipIO, 0L) == 0L) { for (i = 0, length = 0L; i < line_count; i++) { length += strlen (lines[i].buf) + 1L; } ClipIO->io_Offset = 0L; ClipIO->io_ClipID = 0L; length += 12L; ClipStr (ClipIO, "FORM", 4); ClipStr (ClipIO, &length, 4); ClipStr (ClipIO, "FTXTCHRS", 8); length -= 12L; ClipStr (ClipIO, &length, 4); for (i = 0; i < line_count; i++) { ClipStr (ClipIO, lines[i].buf, strlen (lines[i].buf)); ClipStr (ClipIO, "\n", 1); } if (length & 1L) { ClipStr (ClipIO, "", 1L); } ClipIO->io_Command = CMD_UPDATE; DoIO (ClipIO); CloseDevice (ClipIO); err = 0; } } if (ClipIO) { DeleteExtIO (ClipIO); } if (Port) { DeletePort (Port); } } return (err); } /* clip_msg */ -- // Juergen Hermann root@ccave.smurf.ira.uka.de \X/ 75 Karlsruhe 1, FRG Fido: 2:241/2.1212@FidoNet