From: ear@wpi.WPI.EDU (Mr. Neat-O [tm])
Newsgroups: comp.os.os2.apps
Subject: Re: Drag and Drop Compression
Date: 20 Dec 1992 22:36:15 GMT
Organization: Worcester Polytechnic Institute
Distribution: world
NNTP-Posting-Host: wpi.wpi.edu

In article <BzIptG.D2n@ucunix.san.uc.edu> kreinddm@ucunix.san.uc.edu (David M Kreindler) writes:
>Specificially with regard to the 'file' vs 'files' drag-and-drop issue,
>I called IBM Tech Support the other day, and asked 'em to tell me how an
>app could be set up to accept multiple files via the drag-n'-drop method
>from the desktop.  I was told that it's a 'program design issue': i.e.,
>if you want to be able to drag multiple files to a single application,
>and have the application run (as a single invocation of the program) on
>the bunch of files passed, you have to *write* the program that way --
>there's no way to set up the WPS to pass multiple arguments to a single
>program by the drag'n'drop method if it wasn't designed as such from
>scratch.  FYI.

Ta-Da!  I've just completed my very first useful REXX script.  Guess what it
does?  That's right, it allows you to drag and drop multiple files onto OS/2
programs which only accept a single filename at a time.  It's called
split.cmd, and I'll be uploading it to the /pub/uploads directory of hobbes
a few minutes after I finish typing in this message.  I've also included it
at the end of this message.  (I hope nobody minds, it's not too big)

To quote from it's usage text:
----------------------------------------------------------------------------
Usage: SPLIT <baseprog> <numargs> <args> <filelist>
Where:
  <baseprog> is the program or command to be invoked
  <numargs> is the number of <args>
  <args> is the list of arguments to be passed to <baseprog> every time
  <filelist> is the list of files to be passed to <baseprog> one at a time
Example:
  SPLIT detach 2 unzip -x abc def
Result:
  detach unzip -x abc
  detach unzip -x def
----------------------------------------------------------------------------

If it is invoked with no parameters, or with some invalid number of
parameters, then an appropriate message is displayed along with the above
usage text.  

Split is designed to be invoked from a program icon onto which you can drop
as multiple file icons.  I tried to make it reasonably flexible by allowing
arguments that are sent to every instance of whatever program/command is
being invoked in addition to the filenames which are sent one to each
instance.  Unfortunately, I could not figure out a better scheme for
detecting the difference between the arguments and the filenames than to
simply have a number representing the number of arguments and assuming that
all further parameters are filenames.  (See the above example if you are
confused.)  However, since the number of arguments ought to remain constant
if/when this is invoked from a program icon, this should not be too
annoying.  

I welcome feedback, helpful suggestions (and cash ;) regarding this script.
I just started using REXX today (because I don't have an OS/2 C compiler yet)
so please excuse any blatantly inefficient bits of code.  I think it's
pretty short and sweet and a moderate amount of testing hasn't uncovered any
bugs in it thus far.

The actual script follows my sigature.

+---------< Eric A. Rasmussen - Mr. Neat-O (tm) >---------+ +< Email Address >+
|   A real engineer never reads the instructions first.   | | ear@wpi.wpi.edu |
|   (They figure out how it works by playing with it.)    | | ear%wpi@wpi.edu |
+---------------------------------------------------------+ +-----------------+
                     ((( In Stereo Where Available )))

/**********************************************
SPLIT.CMD v1.0 - December 20, 1992
	written by Eric A. Rasmussen (ear@wpi.wpi.edu)

Restrictions:  This REXX script may be used by anyone,
and distributed by any means so long as no money is 
charged for the script and distributed versions of the
script are not modified.  (Modification for personal use
is fine, of course.)

Disclaimer:  It works for me, but I don't guarantee that 
it is bug free.  Thus, use at your own risk.

-Eric Rasmussen (ear@wpi.wpi.edu)

P.S.  Happy Holidays
**********************************************/
if arg() == 0 then do
  call usage
  exit
end
parse arg argv
if words(argv) < 2 then do
  say "Error: insufficient number of parameters"
  say "Input was: SPLIT" arg(1)
  call usage
  exit
end
baseprog =word(argv,1)
numargs = word(argv,2)
if words(argv) < 2+numargs then do
  say "Error: insufficient number of <args>, expected" numargs", found" words(argv)-2
  say "Input was: SPLIT" arg(1)
  call usage
  exit
end
if words(argv) = 2+numargs then do
  say "Warning: Nothing to do!"
  say "Input was: SPLIT" arg(1)
  say "Suggestions:"
  say "  1. Verify that number of <args> = <numargs>"
  say "  2. Be sure to drop at least one file onto the program object"
  call usage
  exit
end
arglist = ''
do i=3 to 2 + numargs
  arglist =arglist word(argv,i)
end
do i=3+numargs to words(argv)
  baseprog arglist word(argv,i)
end
exit
usage:
  say "Usage: SPLIT <baseprog> <numargs> <args> <filelist>"
  say "Where:"
  say "  <baseprog> is the program or command to be invoked"
  say "  <numargs> is the number of <args>"
  say "  <args> is the list of arguments to be passed to <baseprog> every time"
  say "  <filelist> is the list of files to be passed to <baseprog> one at a time"
  say "Example:"
  say "  SPLIT detach 2 unzip -x abc def"
  say "Result:"
  say "  detach unzip -x abc"
  say "  detach unzip -x def"
  say
  say "Press Enter"
  pull junkstr
return


Newsgroups: comp.os.os2.apps
From: gordon@galisant.demon.co.uk (Gordon Beck)