  '=============
  'THE CLIPBOARD
  '=============

  uses MinWin



  '--------------------
  'WRITING TO CLIPBOARD
  '====================


  'Get exclusive access to the clipboard
  '=====================================

  OpenClipboard 0 'hwnd


  'Get some data
  '=============

  string s="this is clipboard text"
  int le=1+len s
 
  'Allocate a global memory object for the text.
  '=============================================
 
  sys h = GlobalAlloc GMEM_MOVEABLE, le

  'Lock the handle.
  '================ 
 
  sys k = GlobalLock h


  'copy in the data
  '================

  copy k, strptr s, le

  'Attach it to the clipboard
  '==========================

  SetClipboardData CF_TEXT, h

  'Unlock the memory block
  '=======================
 
  GlobalUnlock h

  'Release the Clipboard
  '=====================

  CloseClipboard 0 'hwnd



  '----------------------
  'READING FROM CLIPBOARD
  '======================


  'Get exclusive access to the clipboard
  '=====================================

  OpenClipboard 0 'hwnd

  'get data from clipboard
  '=========================

  h = GetClipboardData CF_TEXT

  'Lock the handle.
  '================ 
 
  k = GlobalLock h

  'Copy it
  '=======

  zstring z at k
  string s=z

  'Unlock the memory block
  '=======================
 
  GlobalUnlock h

  'Release the Clipboard
  '=====================

  CloseClipboard 0 'hwnd

  'Display data
  '============

  print s
 

