home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / os / os2 / apps / 9551 < prev    next >
Encoding:
Text File  |  1992-12-21  |  5.7 KB  |  148 lines

  1. Path: sparky!uunet!noc.near.net!bigboote.WPI.EDU!wpi.WPI.EDU!ear
  2. From: ear@wpi.WPI.EDU (Mr. Neat-O [tm])
  3. Newsgroups: comp.os.os2.apps
  4. Subject: Re: Drag and Drop Compression
  5. Date: 20 Dec 1992 22:36:15 GMT
  6. Organization: Worcester Polytechnic Institute
  7. Lines: 135
  8. Distribution: world
  9. Message-ID: <1h2sgvINNk6o@bigboote.WPI.EDU>
  10. References: <1992Dec19.234613.12909@waikato.ac.nz> <BzIptG.D2n@ucunix.san.uc.edu>
  11. NNTP-Posting-Host: wpi.wpi.edu
  12.  
  13. In article <BzIptG.D2n@ucunix.san.uc.edu> kreinddm@ucunix.san.uc.edu (David M Kreindler) writes:
  14. >Specificially with regard to the 'file' vs 'files' drag-and-drop issue,
  15. >I called IBM Tech Support the other day, and asked 'em to tell me how an
  16. >app could be set up to accept multiple files via the drag-n'-drop method
  17. >from the desktop.  I was told that it's a 'program design issue': i.e.,
  18. >if you want to be able to drag multiple files to a single application,
  19. >and have the application run (as a single invocation of the program) on
  20. >the bunch of files passed, you have to *write* the program that way --
  21. >there's no way to set up the WPS to pass multiple arguments to a single
  22. >program by the drag'n'drop method if it wasn't designed as such from
  23. >scratch.  FYI.
  24.  
  25. Ta-Da!  I've just completed my very first useful REXX script.  Guess what it
  26. does?  That's right, it allows you to drag and drop multiple files onto OS/2
  27. programs which only accept a single filename at a time.  It's called
  28. split.cmd, and I'll be uploading it to the /pub/uploads directory of hobbes
  29. a few minutes after I finish typing in this message.  I've also included it
  30. at the end of this message.  (I hope nobody minds, it's not too big)
  31.  
  32. To quote from it's usage text:
  33. ----------------------------------------------------------------------------
  34. Usage: SPLIT <baseprog> <numargs> <args> <filelist>
  35. Where:
  36.   <baseprog> is the program or command to be invoked
  37.   <numargs> is the number of <args>
  38.   <args> is the list of arguments to be passed to <baseprog> every time
  39.   <filelist> is the list of files to be passed to <baseprog> one at a time
  40. Example:
  41.   SPLIT detach 2 unzip -x abc def
  42. Result:
  43.   detach unzip -x abc
  44.   detach unzip -x def
  45. ----------------------------------------------------------------------------
  46.  
  47. If it is invoked with no parameters, or with some invalid number of
  48. parameters, then an appropriate message is displayed along with the above
  49. usage text.  
  50.  
  51. Split is designed to be invoked from a program icon onto which you can drop
  52. as multiple file icons.  I tried to make it reasonably flexible by allowing
  53. arguments that are sent to every instance of whatever program/command is
  54. being invoked in addition to the filenames which are sent one to each
  55. instance.  Unfortunately, I could not figure out a better scheme for
  56. detecting the difference between the arguments and the filenames than to
  57. simply have a number representing the number of arguments and assuming that
  58. all further parameters are filenames.  (See the above example if you are
  59. confused.)  However, since the number of arguments ought to remain constant
  60. if/when this is invoked from a program icon, this should not be too
  61. annoying.  
  62.  
  63. I welcome feedback, helpful suggestions (and cash ;) regarding this script.
  64. I just started using REXX today (because I don't have an OS/2 C compiler yet)
  65. so please excuse any blatantly inefficient bits of code.  I think it's
  66. pretty short and sweet and a moderate amount of testing hasn't uncovered any
  67. bugs in it thus far.
  68.  
  69. The actual script follows my sigature.
  70.  
  71. +---------< Eric A. Rasmussen - Mr. Neat-O (tm) >---------+ +< Email Address >+
  72. |   A real engineer never reads the instructions first.   | | ear@wpi.wpi.edu |
  73. |   (They figure out how it works by playing with it.)    | | ear%wpi@wpi.edu |
  74. +---------------------------------------------------------+ +-----------------+
  75.                      ((( In Stereo Where Available )))
  76.  
  77. /**********************************************
  78. SPLIT.CMD v1.0 - December 20, 1992
  79.     written by Eric A. Rasmussen (ear@wpi.wpi.edu)
  80.  
  81. Restrictions:  This REXX script may be used by anyone,
  82. and distributed by any means so long as no money is 
  83. charged for the script and distributed versions of the
  84. script are not modified.  (Modification for personal use
  85. is fine, of course.)
  86.  
  87. Disclaimer:  It works for me, but I don't guarantee that 
  88. it is bug free.  Thus, use at your own risk.
  89.  
  90. -Eric Rasmussen (ear@wpi.wpi.edu)
  91.  
  92. P.S.  Happy Holidays
  93. **********************************************/
  94. if arg() == 0 then do
  95.   call usage
  96.   exit
  97. end
  98. parse arg argv
  99. if words(argv) < 2 then do
  100.   say "Error: insufficient number of parameters"
  101.   say "Input was: SPLIT" arg(1)
  102.   call usage
  103.   exit
  104. end
  105. baseprog =word(argv,1)
  106. numargs = word(argv,2)
  107. if words(argv) < 2+numargs then do
  108.   say "Error: insufficient number of <args>, expected" numargs", found" words(argv)-2
  109.   say "Input was: SPLIT" arg(1)
  110.   call usage
  111.   exit
  112. end
  113. if words(argv) = 2+numargs then do
  114.   say "Warning: Nothing to do!"
  115.   say "Input was: SPLIT" arg(1)
  116.   say "Suggestions:"
  117.   say "  1. Verify that number of <args> = <numargs>"
  118.   say "  2. Be sure to drop at least one file onto the program object"
  119.   call usage
  120.   exit
  121. end
  122. arglist = ''
  123. do i=3 to 2 + numargs
  124.   arglist =arglist word(argv,i)
  125. end
  126. do i=3+numargs to words(argv)
  127.   baseprog arglist word(argv,i)
  128. end
  129. exit
  130. usage:
  131.   say "Usage: SPLIT <baseprog> <numargs> <args> <filelist>"
  132.   say "Where:"
  133.   say "  <baseprog> is the program or command to be invoked"
  134.   say "  <numargs> is the number of <args>"
  135.   say "  <args> is the list of arguments to be passed to <baseprog> every time"
  136.   say "  <filelist> is the list of files to be passed to <baseprog> one at a time"
  137.   say "Example:"
  138.   say "  SPLIT detach 2 unzip -x abc def"
  139.   say "Result:"
  140.   say "  detach unzip -x abc"
  141.   say "  detach unzip -x def"
  142.   say
  143.   say "Press Enter"
  144.   pull junkstr
  145. return
  146.  
  147.  
  148.