home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 283 / Shell5SourceCode.sis / getclip.txt < prev    next >
Encoding:
Text File  |  1998-08-30  |  1.9 KB  |  67 lines

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