home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 283 / Shell5SourceCode.sis / getclip (.txt) < prev    next >
Encoding:
EPOC OPL Source  |  1998-08-30  |  2.1 KB  |  72 lines

  1.  
  2.  
  3. Rem   getclip, an addon command for Shell5
  4. Rem   Read the system clipboard
  5. Rem
  6. Rem   Copyright (C) 1998  Nick Murray
  7. Rem   This routine was made possible by Cliplib.opl v 1.0
  8. Rem    by Russ Spooner (psion@labrat.demon.co.uk)
  9. Rem
  10. Rem   This program is free software; you can redistribute it and/or
  11. Rem   modify it under the terms of the GNU General Public License
  12. Rem   as published by the Free Software Foundation; either version 2
  13. Rem   of the License, or (at your option) any later version.
  14. Rem
  15. Rem   This program is distributed in the hope that it will be useful,
  16. Rem   but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. Rem   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  18. Rem   See the GNU General Public License for more details.
  19. Rem
  20. Rem   You should have received a copy of the GNU General Public License
  21. Rem   along with this program; if not, write to the Free Software Foundation,
  22. Rem   Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  23. Rem
  24. PROC getclip%:(n%)
  25. LOCAL h%,p&,end&,pos&,len&,base&,c%
  26.     ONERR ErrTrap::
  27.     IOOPEN (h%,"c:\system\data\clpboard.cbd",$200)
  28.     pos&=20
  29.     IOSEEK(h%,1,pos&)
  30.     IOREAD(h%,ADDR(len&),4)
  31.  
  32.     base&=ALLOC(len&+4)                    Rem only NEED + 1  - because poking
  33.     Rem the string length on the first entry would be at pos -1    
  34.     IOREAD(h%,base&+4,len&)
  35.     h%=IOCLOSE (h%)
  36.     
  37.     end&=base&+len&+4
  38.     p&=base&+4
  39.     WHILE p& <= end&
  40.         IOYIELD
  41.         IF _stat%<>-46
  42.             IF _key%(1)=27
  43.                 BREAK                    Rem this should ensure something is written!!
  44.             ELSE
  45.                 KEYA(_stat%,_key%())
  46.             ENDIF
  47.         ENDIF
  48.         IF (PEEKB(p&)=6) OR c%=253 OR p&=end&    Rem newline in dialog or max characters
  49.             POKEB p&-c%-1,c%
  50.             fprint%:(PEEK$(p&-c%-1))
  51.             c%=-(c%=253)    Rem as we USE the 253rd character!
  52.         ELSE
  53.             c%=c%+1
  54.         ENDIF
  55.         p&=p&+1
  56.     ENDWH
  57.     FREEALLOC(base&)
  58.     RETURN
  59. ErrTrap::
  60.     ONERR off
  61.     IF h%
  62.         IOCLOSE (h%)
  63.     ENDIF
  64.     IF base&
  65.         FREEALLOC(base&)
  66.     ENDIF
  67.     PRINT err$:(ERR)
  68.     RETURN ERR
  69. ENDP
  70.  
  71.  
  72.