home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / CLPPASTE.ZIP / CLPPASTE.SPF < prev    next >
Text File  |  1991-02-08  |  3KB  |  82 lines

  1. /***********************************************************************
  2.  MACRO:     CLPPASTE
  3.  PURPOSE:   Copies text from the clipboard to SPF/2
  4.  OPERATION: A program - CLP2FILE - gets text from the clipboard and
  5.             puts it to a file.  It is then copied from the file into
  6.             the file being being edited after the A.
  7. ***********************************************************************/
  8.  
  9. 'ISREDIT MACRO NOPROCESS'
  10.  
  11. TRACE OFF
  12. quote = "'"
  13.         /* CLP2FILE copies text from clipboard to a file CLIP.OUT */
  14. ADDRESS CMD 'CLP2FILE'
  15.   select
  16.     when RC = 0 then
  17.     do
  18.         /* sets the .ZDEST label where the A is */
  19.       'ISREDIT PROCESS DEST'
  20.        select
  21.          when RC = 0 then
  22.            do
  23.             'ISREDIT (last_line) = LINENUM .ZLAST'
  24.             'ISREDIT (copy_start) = LINENUM .ZDEST'
  25.             copy_start_sav = copy_start + 0
  26.         /* copy the file after the A  */
  27.             'ISREDIT COPY CLIP.OUT AFTER .ZDEST'
  28.         /* calculate the number of lines copied  */
  29.             'ISREDIT (new_last_line) = LINENUM .ZLAST'
  30.              copy_end = copy_start + (new_last_line - last_line)
  31.              copy_start = copy_start + 1
  32.         /* label the new lines  */
  33.             'ISREDIT LABEL (copy_start) = .start'
  34.             'ISREDIT LABEL (copy_end) = .end'
  35.         /* change the  at the end of the new lines to spaces  */
  36.             'ISREDIT CHANGE all ""  " " .start .end'
  37.             'ISREDIT RESET'
  38.         /* erase CLIP.OUT */
  39.              ADDRESS CMD 'ERASE CLIP.OUT'
  40.             endok = quote||'Clipboard contents have been copied after line '||copy_start_sav ||quote
  41.            'ISREDIT RESET'
  42.            'ISREDIT LINE_BEFORE .ZFIRST = NOTELINE ' endok
  43.            end
  44.          when RC = 8 then
  45.         /* if no A then error */
  46.           do
  47.            'ISREDIT RESET'
  48.             procerr = quote||'Destination for data not found - use line command A'||quote
  49.            'ISREDIT LINE_BEFORE .ZFIRST = NOTELINE ' procerr
  50.            end
  51.          otherwise
  52.           do
  53.         /* if a line command conflict then error */
  54.             procerr = quote||'Incomplete or conflicting line commands'||quote
  55.            'ISREDIT RESET'
  56.            'ISREDIT LINE_BEFORE .ZFIRST = NOTELINE ' procerr
  57.           end
  58.        end
  59.     end
  60.     when RC = 1 then
  61.         /* ADDRESS CMD returns a 1 if cannot find executable */
  62.           do
  63.            'ISREDIT RESET'
  64.             cliperr = quote||'Please place CLP2FILE.EXE in a sub-dir on your path'||quote
  65.            'ISREDIT LINE_BEFORE .ZFIRST = NOTELINE' cliperr
  66.           end
  67.     when RC = 2 then
  68.    /* CLP2FILE returns a 2 if clipboard is empty or has non-text data */
  69.       do
  70.       'ISREDIT RESET'
  71.        cliperr = quote||'Clipboard is empty or contains non-text data'||quote
  72.       'ISREDIT LINE_BEFORE .ZFIRST = NOTELINE ' cliperr
  73.       end
  74.     otherwise
  75.         /* CLP2FILE returns a 3 if clipboard cannot be opened */
  76.       do
  77.       'ISREDIT RESET'
  78.        cliperr = quote||'Clipboard cannot be opened'||quote
  79.       'ISREDIT LINE_BEFORE .ZFIRST = NOTELINE ' cliperr
  80.       end
  81.   end
  82.