home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 106 / EnigmaAmiga106CD.iso / software / varie / cutnpaste / opus5 / modules / cutnpaste.dopus5
Encoding:
Text File  |  1999-09-04  |  22.3 KB  |  582 lines

  1. /* $VER: CutNPaste.dopus5 3.4 (28.08.99) Written by Keith Halstead <cutnpaste@halsteadk.freeserve.co.uk>
  2. *  Locale support by Michael Skibsted Sørensen <MSS@kob.dk>                               *
  3. *  For full history and acknowledgements see accompanying documentation                   *
  4. */
  5.  
  6. parse arg portname function source dest arguments
  7. address value portname
  8. options results
  9.  
  10. if ~show('l','rexxsupport.library') then
  11.   call addlib('rexxsupport.library',0,-30,0)
  12. if ~show(l,'locale.library') then
  13.   call addlib('locale.library',0,-30)
  14. if show(l,'locale.library') then
  15.   catalog = opencatalog('CutNPaste.catalog','english',0)
  16.  
  17. /* ****** USER CONFIGURATION SECTION ****** */
  18.  
  19. /* Edit these filetype ID's to suit your own filetypes (you may use wildcards, eg 'LHA#?') */
  20. lhatype = 'LHA'
  21. lzxtype = 'LZX'
  22. ziptype = 'ZIP'
  23.  
  24. /* Edit these commands to suit yourself (if you really don't like the defaults) -
  25.    By default they will automatically add non-existant files and update older files,
  26.    but not replace newer files.  To add non-existant files only - change "u" to "a" for
  27.    lzx and lha, change zipcmd to 'zip -r'.  Do not remove "-r" for any of them - the defaults
  28.    and rest of the script will handle (empty) directories (and their contents) perfectly.
  29.    Don't change them unless you really want to!! */
  30. lzxcmd = 'lzx -r -e u'
  31. lhacmd = 'lha -r -e u'
  32. zipcmd = 'zip -ru'
  33.  
  34. /* Some miscellaneous things to alter the behaviour of Cut'n'Paste */
  35.  
  36. ramdisktype = 'RAMDISK'    /* allows 'clear' command to be added to ram disk icon menu */
  37.  
  38. copyicons = 'yes'  /* 'yes' if you want to always cut/copy associated icons from RMB cut/copy/add,
  39.                       'notnamemode' if you want to do this in icon (action) mode listers only,
  40.                       anything else if you never want to copy the icon */
  41. addcheck = 'quiet'   /* 'yes' - checks that items aren't already in clipboard when adding,
  42.                         'quiet' -  no warning requesters - these are a bit slower than 'no' */
  43. enablepastelinks = 'yes'  /* 'yes' will enable all "paste as links" menu items,
  44.                               anything else will disable them (for if you never use links)  */
  45. secondviewreq = 'yes'   /* 'yes' allows a second view requester to pop up after you view the
  46.                            clipboard contents in the DOpus text reader;
  47.                            anything else to disable the second requester  */
  48.  
  49. /* ****** DO NOT EDIT BELOW THIS LINE ****** */
  50.  
  51. dopus version
  52. dopver = substr(result,3,1)  /* "dopver" contains "8" for Mag II and "6" for Mag I */
  53.  
  54. /* MAIN PROGRAM LOOP STARTS */
  55.  
  56. select
  57.   when function = 'init' then do
  58.     cnptypes = 'type drawer type tool type project type trash'
  59.     'dopus command "Clip-Cut" program "CutNPaste" ext 'locale(2,"Cut")' private' cnptypes
  60.     'dopus command "Clip-MCut" program "CutNPaste" ext 'locale(2,"Cut")' desc "Cut''n''Paste: "'locale(2,"Cut")'' type lister
  61.     'dopus command "Clip-Copy" program "CutNPaste" ext 'locale(1,"Copy")' private' cnptypes
  62.     'dopus command "Clip-MCopy" program "CutNPaste" ext 'locale(1,"Copy")' desc "Cut''n''Paste: "'locale(1,"Copy")'' type lister
  63.     call addpastecmds
  64.     call cnpclear
  65.   end
  66.  
  67.   /* CUT OR COPY SINGLE ITEMS (with RMB) */
  68.   when (function = 'Clip-Cut') | (function = 'Clip-Copy') then call clipsingle
  69.  
  70.   /* CUT OR COPY MULTIPLE ITEMS (from lister pop-up menus or buttons) */
  71.   when (function = 'Clip-MCut') | (function = 'Clip-MCopy') then call clipmulti
  72.  
  73.   /* ADD SINGLE ITEMS (with RMB) */
  74.   when (function = 'Clip-Add') then call addsingle
  75.  
  76.   /* ADD MULTIPLE ITEMS (from lister pop-up menus or buttons) */
  77.   when function = 'Clip-MAdd' then call addmulti
  78.  
  79.   /* PASTE (AS/LINKS) */
  80.   when (function = 'Clip-MPaste') | (function = 'Clip-MPasteAs') | (function = 'Clip-MPasteLinks') then do
  81.     lister query source path
  82.     pastepath = '"'result'"'
  83.     call pastefunc
  84.     lister set source busy off
  85.   end
  86.  
  87.   /* PASTE INTO (AS/LINKS) */
  88.   when (function = 'Clip-MPasteInto') | (function = 'Clip-MPasteIntoAs') | (function = 'Clip-MPasteLinksInto') then do
  89.     pastepath = strip(arguments,L)
  90.     call pastefunc
  91.     lister set source busy off
  92.   end
  93.  
  94.   /* PASTE INTO ARCHIVES */
  95.   when (function='Clip-LhaPaste')|(function='Clip-LzxPaste')|(function='Clip-ZipPaste') then call arcpaste
  96.  
  97.   /* CLEAR */
  98.   when function = 'Clip-Clear' then call cnpclear
  99.  
  100.   /* VIEW CLIPBOARD CONTENTS */
  101.   when function = 'Clip-View' then call viewfunc
  102.  
  103.   /* ABOUT */
  104.   otherwise do
  105.     if getclip('numselobj') = 1 then objtext = locale(33,"item")
  106.     else objtext = locale(34,"items")
  107.     dopus request """Opus Cut'n'Paste "||locale(17,'Version')||' 3.4'||'0a'x||,
  108.                   "- - - - - - - - - - - - - - - - -"""||'0a'x||,
  109.                   locale(18,'Written by')||""" Keith Halstead, 1999"||'0a'x||,
  110.                   locale(19,'E-mail:')||" cutnpaste@halsteadk.freeserve.co.uk"||'0a'x||,
  111.                   "http://www.halsteadk.freeserve.co.uk/cutnpaste/"""||'0a0a'x||,
  112.                   locale(16,'Using built-in English')||'0a0a'x||,
  113.                   locale(13,"Cut'n'Paste clipboard contents")||''': '||,
  114.                   getclip('numselobj')||' '''||objtext,
  115.                   compress(locale(32,'Help...|OK'),'"')
  116.     if rc=1 then address command "run >NIL: multiview DOpus5:Help/CutNPaste.guide"
  117.   end
  118. end
  119.  
  120. exit
  121.  
  122.  
  123. /* LOCALE FUNCTION */                                
  124. locale:
  125.   parse arg msgno,msgstring
  126.  
  127.   if catalog ~= 0 then
  128.     msgstring = getcatalogstr(catalog,msgno,msgstring)
  129.  
  130.   do i = 3 to arg()
  131.     parse var msgstring before '%s' after
  132.     msgstring = before||arg(i)||after
  133.   end
  134. return '"'msgstring'"'
  135.  
  136.  
  137. /* INVALID CLIPBOARD FUNCTION */
  138. invalid:
  139.   lister request source locale(7,"Cut'n'Paste clipboard was invalid!  It has been cleared.")
  140.   call cnpclear
  141. return
  142.  
  143.  
  144. /* CLEAR CLIPBOARD FUNCTION */
  145. cnpclear:
  146.   setclip('numselobj',0)
  147.   if exists('T:clipcnp')=1 then command 'Delete T:clipcnp quiet'
  148.   call rempastecmds
  149.   setclip('cnpcmd',0)
  150. return
  151.  
  152.  
  153. /* REMOVE PASTE/VIEW COMMANDS */
  154. rempastecmds:
  155.   if dopver>=8 then do
  156.     dopus command "Clip-Add" remove
  157.     dopus command "Clip-MAdd" remove
  158.     dopus command "Clip-MPasteInto" remove
  159.     dopus command "Clip-MPasteIntoAs" remove
  160.     dopus command "Clip-MPaste" remove
  161.     dopus command "Clip-MPasteAs" remove
  162.     if enablepastelinks='yes' then do
  163.       dopus command "Clip-MPasteLinks" remove
  164.       dopus command "Clip-MPasteLinksInto" remove
  165.     end
  166.     dopus command "Clip-LhaPaste" remove
  167.     dopus command "Clip-LzxPaste" remove
  168.     dopus command "Clip-ZipPaste" remove
  169.     dopus command "Clip-View" remove
  170.     dopus command "Clip-Clear" remove
  171.   end
  172. return
  173.  
  174.  
  175. /* ADD PASTE/VIEW COMMANDS */
  176. addpastecmds:
  177.   call rempastecmds
  178.   if dopver>=8 then dopus command "Clip-About" remove
  179.  
  180.   if (function = 'init') | (dopver>=8) then do
  181.     cnptypes = 'type drawer type tool type project type trash'
  182.     'dopus command "Clip-Add" program "CutNPaste" ext 'locale(40,"Add To Clipboard")' private' cnptypes
  183.     'dopus command "Clip-MAdd" program "CutNPaste" ext 'locale(40,"Add To Clipboard")' desc "Cut''n''Paste: "'locale(40,"Add to Clipboard")'' type lister
  184.     'dopus command "Clip-MPasteInto" program "CutNPaste" ext 'locale(5,"Paste Into")' private' type disk type drawer
  185.     'dopus command "Clip-MPasteIntoAs" program "CutNPaste" ext 'locale(6,"Paste Into As...")' private' type disk type drawer
  186.     'dopus command "Clip-MPaste" program "CutNPaste" ext 'locale(3,"Paste")' desc "Cut''n''Paste: "'locale(3,"Paste")'' type lister
  187.     'dopus command "Clip-MPasteAs" program "CutNPaste" ext 'locale(4,"Paste As...")' desc "Cut''n''Paste: "'locale(4,"Paste As...")'' type lister
  188.     if enablepastelinks='yes' then do
  189.       if getclip('numselobj')=1 then do     /* only if one item in clipboard */
  190.         'dopus command "Clip-MPasteLinks" program "CutNPaste" ext 'locale(37,"Paste As Link")' private' type lister
  191.         'dopus command "Clip-MPasteLinksInto" program "CutNPaste" ext 'locale(38,"Paste Into As Link")' private' type disk type drawer
  192.       end
  193.       else do                               /* for several or zero items - ie for function = "init" for Opus 5.66 */
  194.         'dopus command "Clip-MPasteLinks" program "CutNPaste" ext 'locale(35,"Paste As Links")' desc "Cut''n''Paste: "'locale(35,"Paste As Links")'' type lister
  195.         'dopus command "Clip-MPasteLinksInto" program "CutNPaste" ext 'locale(36,"Paste Into As Links")' private' type disk type drawer
  196.       end
  197.     end
  198.     'dopus command "Clip-LhaPaste" program "CutNPaste" ext 'locale(47,"Paste Into Archive")' private' type lhatype
  199.     'dopus command "Clip-LzxPaste" program "CutNPaste" ext 'locale(47,"Paste Into Archive")' private' type lzxtype
  200.     'dopus command "Clip-ZipPaste" program "CutNPaste" ext 'locale(47,"Paste Into Archive")' private' type ziptype
  201.     'dopus command "Clip-View" program "CutNPaste" ext 'locale(9,"View/Alter Clipboard Properties...")' desc 'locale(9,"View Clipboard Contents...")'' type lister
  202.     'dopus command "Clip-Clear" program "CutNPaste" ext 'locale(10,"Clear Clipboard Contents")' desc 'locale(10,"Clear Clipboard Contents")'' type ramdisktype type lister
  203.     'dopus command "Clip-About" program "CutNPaste" ext 'locale(12,"About Opus Cut'n'Paste...")' desc 'locale(12,"About Opus Cut'n'Paste...")'' type lister
  204.   end
  205. return
  206.  
  207.  
  208. /* VIEW CLIPBOARD CONTENTS FUNCTION */
  209. viewfunc:
  210.   numobj = getclip('numselobj')
  211.   if numobj>0 & exists('T:clipcnp')=0 then call cnpclear
  212.   if numobj>0 & exists('T:clipcnp')=1 then do
  213.     if numobj>1 then do
  214.  
  215.       if getclip('cnpcmd')=1 then righttext = locale(45,"items cut to the Cut'n'Paste clipboard.")
  216.       else if getclip('cnpcmd')=2 then righttext = locale(46,"items copied to the Cut'n'Paste clipboard.")
  217.       else do
  218.         call invalid
  219.         return
  220.       end
  221.  
  222.       lister request source locale(20,'There are')||''' 'numobj' '''||righttext||'0a'x||,
  223.                     locale(22,'What would you like to do with them?'),
  224.                     compress(locale(24,'View...|Paste here|Toggle cut/copy|Clear clipboard|Nothing'),'"')
  225.       action = rc
  226.  
  227.       if action=1 then do
  228.         command wait read 't:clipcnp'
  229.         if secondviewreq = 'yes' then do
  230.           lister request source locale(22,'What would you like to do with them?'),
  231.                          compress(locale(25,'Paste into current lister|Toggle cut/copy|Clear clipboard|Nothing'),'"')
  232.           action = rc
  233.         end
  234.         else action = 0      /* if second requester not displayed, pretend "Nothing" was pressed */
  235.       end
  236.  
  237.       else action=action-1   /* now paste=1, toggle=2, clear=3 regardless of previous statements */
  238.     end
  239.  
  240.     /* routine for when number of objects is 1 */
  241.     else if open('cnpfile','T:clipcnp','r') then do
  242.  
  243.       if getclip('cnpcmd')=2 then cmd = compress(locale(1,'Copy'),'"')
  244.       else cmd = compress(locale(2,'Cut'),'"')
  245.  
  246.       srcfile = '"'readln('cnpfile')'"'
  247.       call close('cnpfile')
  248.  
  249.       if length(srcfile)>3 then do
  250.         if length(srcfile) > 72 then sourcefile=left(srcfile,60)||' ...'||'0a'x||'... '||substr(srcfile,61)
  251.         else sourcefile=srcfile
  252.         lister request source locale(11,'Clipboard contents')||'": '||'0a'x||,
  253.                       cmd' "'sourcefile||'0a'x||,
  254.                       locale(23,'What would you like to do with it?'),
  255.                       compress(locale(26,'Paste here|Toggle cut/copy|Clear clipboard|Nothing'),'"')
  256.         action = rc
  257.       end
  258.       else do
  259.         call invalid
  260.         return
  261.       end
  262.     end
  263.     else do
  264.       call invalid
  265.       return
  266.     end
  267.  
  268.     /* execute one action depending on which button was pressed */
  269.     if action = 1 then do
  270.       lister query source path
  271.       pastepath = '"'result'"'
  272.       call pastefunc
  273.     end
  274.  
  275.     else if action = 2 then do
  276.       setclip('cnpcmd',getclip('cnpcmd')-1)
  277.       if getclip('cnpcmd')=0 then do
  278.         setclip('cnpcmd',2)
  279.         newactiontext = locale(44,'Clipboard contents will now be copied')
  280.       end
  281.       else newactiontext = locale(43,'Clipboard contents will now be cut')
  282.       lister request source newactiontext
  283.     end
  284.  
  285.     else if action = 3 then call cnpclear
  286.   end
  287.   else lister request source locale(21,"View")||""": """||locale(8,"Cut'n'Paste clipboard is empty")
  288. return
  289.  
  290.  
  291. /* PASTE (INTO) (AS/LINKS) FUNCTION */
  292. pastefunc:
  293.   if getclip('numselobj')>0 then do
  294.     if open('cnpfile','T:clipcnp','r') then do
  295.  
  296.       if (function = 'Clip-MPasteLinksInto') | (function = 'Clip-MPasteLinks') then do
  297.         dopcmd = 'makelink'                    /* same whether cut or copied */
  298.         action = compress(locale(42,'Pasting link to'),'"')
  299.       end
  300.       else if getclip('cnpcmd')=1 then do     /* if not pasting links and items were cut */
  301.         clear = 1               /* will clear clipboard after paste finishes - see later */
  302.         dopcmd = 'move'
  303.         action = compress(locale(30,'Moving'),'"')
  304.       end
  305.       else if getclip('cnpcmd')=2 then do     /* if not pasting links and items were copied */
  306.         dopcmd = 'copy'
  307.         action = compress(locale(29,'Copying'),'"')
  308.       end
  309.       else do
  310.         call invalid
  311.         return
  312.       end
  313.  
  314.       if (function = 'Clip-MPasteAs') | (function = 'Clip-MPasteIntoAs') then do
  315.         dopcmd = dopcmd||'as'
  316.       end
  317.  
  318.       numobj = getclip('numselobj')
  319.       lister set source newprogress name file info bar abort
  320.       progressfail=rc           /* progressfail is 1 if progress requester isn't created */
  321.       lister set source newprogress title compress(locale(28,"Cut'n'Paste progress..."),'"')
  322.       lister set source newprogress info compress(locale(31,'into') "'"pastepath"'",'"')
  323.       lister set source busy on
  324.  
  325.       /* loops for each item */
  326.       do i=1 for numobj
  327.         lister query source abort
  328.         if (result = 1) & (progressfail = 0) then leave i   /* if abort pressed AND progress requester created successfully */
  329.         lister set source newprogress bar numobj i
  330.         lister set source newprogress file numobj i
  331.         srcfile = readln('cnpfile')
  332.         lister set source newprogress name action "'"substr(srcfile,max(lastpos(":",srcfile),lastpos("/",srcfile))+1)"'"
  333.         srcfile = '"'srcfile'"'
  334.         command wait dopcmd 'name=' srcfile 'to=' pastepath    /* this line does it all - remove "wait" for speed but there are problems! */
  335.       end
  336.  
  337.       lister set source busy off
  338.       if (function = 'Clip-MPaste') | (function = 'Clip-MPasteAs') then lister refresh source
  339.       call close('cnpfile')
  340.       if clear = 1 then call cnpclear     /* if action was cut+paste then clear clipboard */
  341.     end
  342.     else do
  343.       call cnpclear
  344.       lister request source locale(3,"Paste")'": "'locale(8,"Cut'n'Paste clipboard is empty")
  345.     end
  346.   end
  347.   else lister request source locale(3,"Paste")'": "'locale(8,"Cut'n'Paste clipboard is empty")
  348. return
  349.  
  350.  
  351. /* FUNCTION TO PASTE CLIPBOARD CONTENTS INTO ARCHIVES */
  352. arcpaste:
  353.   if getclip('numselobj')>0 then do
  354.     if open('cnpfile','T:clipcnp','r') then do
  355.       numobj = getclip('numselobj')
  356.       arcname = substr(arguments,max(lastpos(":",arguments),lastpos("/",arguments))+1)
  357.       arcname = left(arcname,length(arcname)-1)
  358.  
  359.       if (function = 'Clip-LzxPaste') then arccmd = lzxcmd
  360.       else if (function = 'Clip-LhaPaste') then arccmd = lhacmd
  361.       else if (function = 'Clip-ZipPaste') then arccmd = zipcmd
  362.       else return               /* should be impossible */
  363.  
  364.       lister set source newprogress name file info bar abort
  365.       progressfail=rc           /* checks if progress indicator appears - doesn't for desktop items */
  366.       lister set source newprogress title compress(locale(28,"Cut'n'Paste progress..."),'"')
  367.       lister set source newprogress info compress(locale(49,'to') "'"arcname"'",'"')
  368.       lister set source busy on
  369.  
  370.       /* loops for each item */
  371.       do loopcount=1 for numobj
  372.         lister query source abort
  373.         if (result = 1) & (progressfail = 0) then leave loopcount  /* if abort pressed AND indicator was created */
  374.         lister set source newprogress bar numobj loopcount
  375.         lister set source newprogress file numobj loopcount
  376.         srcfile = readln('cnpfile')                 /* complete path and name */
  377.         breakpos = max(lastpos(":",srcfile),lastpos("/",srcfile))   /* finds position of last : or / */
  378.         srcname = substr(srcfile,breakpos+1)        /* name of current file or dir */
  379.         srcdir = left(srcfile,breakpos)             /* name of path to current file or dir */
  380.         lister set source newprogress name compress(locale(48,'Adding'),'"') "'"srcname"'"
  381.         srctype = left(statef(srcfile),1)
  382.  
  383.         if (srctype = 'D') & (arccmd=zipcmd) then srcname = '"'srcname'"' '"'srcname'/#?"'
  384.         else if srctype = 'D' then srcname = '"'srcname'/#?"'
  385.         else srcname = '"'srcname'"'
  386.  
  387.         olddir = pragma(D,srcdir)
  388.         address command arccmd arguments srcname
  389.         pragma(D,olddir)
  390.       end
  391.  
  392.       lister set source busy off
  393.       lister refresh source
  394.       call close('cnpfile')
  395.  
  396.     end
  397.     else do
  398.       call cnpclear
  399.       lister request source locale(3,"Paste")'": "'locale(8,"Cut'n'Paste clipboard is empty")
  400.     end
  401.   end
  402.   else lister request source locale(3,"Paste")'": "'locale(8,"Cut'n'Paste clipboard is empty")
  403. return
  404.  
  405.  
  406. /* CUT OR COPY SINGLE ITEM (WITH ICON) */
  407. clipsingle:
  408.   if open('cnpfile','T:clipcnp','w,') then do
  409.     selfile=compress(strip(arguments,L),'"')
  410.     /* fix for lone icons cut/copied in icon mode */
  411.     if exists(selfile)=0 & exists(selfile||'.info')=1 then selfile = selfile||'.info'
  412.  
  413.     writeln('cnpfile',selfile)
  414.  
  415.     if function = 'Clip-Cut' then setclip('cnpcmd',1)
  416.     else setclip('cnpcmd',2)
  417.  
  418.     setclip('numselobj',1)
  419.     if exists(selfile||'.info')=1 then do    /* test for existence of icon */
  420.       lister query source mode
  421.       if (copyicons = 'yes') | ((copyicons = 'notnamemode') & (left(result,4) = 'icon')) then do
  422.         writeln('cnpfile',selfile||'.info')
  423.         setclip('numselobj',2)
  424.       end
  425.     end
  426.  
  427.     call close('cnpfile')
  428.     call addpastecmds
  429.   end
  430. return
  431.  
  432.  
  433. /* FUNCTION TO WRITE CLIPBOARD FILE CONTAINING MULTIPLE ITEMS */
  434. clipmulti:
  435.   lister query source numselentries
  436.   numsel = result
  437.   if numsel~=0 then do
  438.     if open('cnpfile','T:clipcnp','w,') then do
  439.       if function = 'Clip-MCut' then setclip('cnpcmd',1)
  440.       else setclip('cnpcmd',2)
  441.       setclip('numselobj',numsel)
  442.       lister query source path
  443.       srcpath = result
  444.       do i=1 for numsel
  445.         lister query source firstsel
  446.         selobj = compress(result,'"')
  447.         call writeln('cnpfile',srcpath || selobj)
  448.         lister select source '"'selobj'"' off
  449.       end
  450.       lister refresh source full
  451.       call close('cnpfile')
  452.       call addpastecmds
  453.     end
  454.   end
  455.   else if function = 'Clip-MCut' then lister request source locale(14,'Please select something to cut!')
  456.   else lister request source locale(15,'Please select something to copy!')
  457. return
  458.  
  459.  
  460. /* ADD SINGLE ITEM (WITH ICON) */
  461. addsingle:
  462.   if open('cnpfile','T:clipcnp','a')=1 & getclip('numselobj')>0 then do
  463.     if (addcheck = 'yes')|(addcheck = 'quiet') then call readclip
  464.     selfile=compress(strip(arguments,L),'"')
  465.     /* fix for lone icons cut/copied in icon mode */
  466.     if exists(selfile)=0 & exists(selfile||'.info')=1 then selfile = selfile||'.info'
  467.  
  468.     present = 0
  469.     if (addcheck = 'yes')|(addcheck = 'quiet') then call checkitem(selfile,oldnumobj)
  470.     if present = 0 then do
  471.       writeln('cnpfile',selfile)
  472.       setclip('numselobj',getclip('numselobj')+1)
  473.     end
  474.     else present = 0        /* ensures present = 0 for next check */
  475.  
  476.     if exists(selfile||'.info')=1 then do    /* test for existence of icon */
  477.       lister query source mode
  478.       if (copyicons = 'yes') | ((copyicons = 'notnamemode') & (left(result,4) = 'icon')) then do
  479.         if (addcheck = 'yes')|(addcheck = 'quiet') then call checkitem(selfile||'.info',oldnumobj)
  480.  
  481.         if present = 0 then do
  482.           writeln('cnpfile',selfile||'.info')
  483.           setclip('numselobj',getclip('numselobj')+1)
  484.         end
  485.  
  486.       end
  487.     end
  488.  
  489.     call close('cnpfile')
  490.     call addpastecmds
  491.   end
  492.   else do
  493.     dopus request locale(39,"Add")""": """locale(8,"Cut'n'Paste clipboard is empty")
  494.     call cnpclear
  495.   end
  496. return
  497.  
  498.  
  499. /* FUNCTION TO ADD MULTIPLE ITEMS TO CLIPBOARD */
  500. addmulti:
  501.   if open('cnpfile','T:clipcnp','a,')=1 & getclip('numselobj')>0 then do
  502.     lister query source numselentries
  503.     numsel = result
  504.  
  505.     if numsel~=0 then do
  506.       lister set source busy on
  507.       lister query source path
  508.       srcpath = result
  509.  
  510.       if (addcheck = 'yes')|(addcheck = 'quiet') then do
  511.         call readclip
  512.         duplicates = 0
  513.         lister set source newprogress file name info bar abort
  514.         lister set source newprogress title compress(locale(28,"Cut'n'Paste progress..."),'"')
  515.         lister set source newprogress info compress(locale(51,'Number of duplicated items: '),'"') duplicates
  516.       end
  517.  
  518.       do lcount=1 for numsel
  519.         lister query source firstsel
  520.         selobj = compress(result,'"')
  521.         present = 0
  522.  
  523.         if (addcheck = 'yes')|(addcheck = 'quiet') then do
  524.           lister query source abort
  525.           if result = 1 then leave lcount
  526.           lister set source newprogress name compress(locale(48,'Adding'),'"') "'"selobj"'"
  527.           lister set source newprogress bar numsel lcount
  528.           lister set source newprogress file numsel lcount
  529.           call checkitem(srcpath||selobj,oldnumobj)
  530.         end
  531.  
  532.         if present = 0 then do
  533.           call writeln('cnpfile',srcpath || selobj)
  534.           call setclip('numselobj',getclip('numselobj')+1)
  535.         end
  536.         else do
  537.           duplicates = duplicates+1
  538.           lister set source newprogress info compress(locale(51,'Number of duplicated items:'),'"') duplicates
  539.         end
  540.  
  541.         lister select source '"'selobj'"' off
  542.       end
  543.  
  544.       lister refresh source full
  545.       call close('cnpfile')
  546.       call addpastecmds
  547.       lister set source busy off
  548.     end
  549.     else lister request source locale(41,'Please select something to add!')
  550.  
  551.   end
  552.   else do
  553.     lister request source locale(39,"Add")'": "'locale(8,"Cut'n'Paste clipboard is empty")
  554.     call cnpclear
  555.   end
  556. return
  557.  
  558.  
  559. /* FUNCTION TO READ CURRENT CONTENTS OF CLIPBOARD TO STEM VARIABLE (assumes cnpfile already open) */
  560. readclip:
  561.   seek('cnpfile',0,BEGIN)              /* returns read/write pointer to start of cnpfile */
  562.   oldnumobj = getclip('numselobj')
  563.   do i=1 for oldnumobj
  564.     oldclipitem.i = readln('cnpfile')
  565.   end
  566. return
  567.  
  568.  
  569. /* FUNCTION TO CHECK FOR AN ITEM IN THE oldclipitem.x STEM VARIABLE */
  570. checkitem:
  571.   parse arg checkfile,numobj
  572.   present = 0
  573.   do i=1 for numobj
  574.     if checkfile = oldclipitem.i then do
  575.       if addcheck = 'yes' then dopus request '"'''checkfile''''||'0a'x||,
  576.                                compress(locale(50,"already present in the clipboard!"),'"')'"'
  577.       present = 1
  578.       leave i
  579.     end
  580.   end
  581. return
  582.