The nShell drag and drop template may be used from any folder.
This package also contains a new "read" command and a replacement "man" command. Please drop these files in your nShell "bin" directory.
This is an experimental release. If you encounter any problems, please write to:
John Jensen <jjensen@kaiwan.com>
Thank you.
Known Problems
--------------
On my system, scripts fail to run when I drop a large number of files on them (>100).
Background
----------
The "nShell™ drop" template allows nShell scripts to be converted into drag and drop applications. This template requires that a copy of the nShell™ or nShell-Pro™ application be installed on your system. Version 1.0.2 of the nShell may be found on the info-mac archive at:
/info-mac/dev/n-shell-102.hqx
That package also contains a hypertext User's Guide which describes nShell scripting.
Writing a script
----------------
Make a copy of "nShell™ drop". You can use the finder "Duplicate" function, or the nShell "cp" command. Give this copy of the drag and drop template a unique name.
Method 1 - Direct Editing
-------------------------
Drag your new icon onto a BBEdit icon, and type in your script. Close the file and you're done.
Method 2 - Appending a file
---------------------------
If you have an existing script file which you would like to make into a drag and drop application, you can 'cat' the file onto a copy of the "nShell™ drop" template:
cat my_script >> template_copy
and you're done.
NOTE: Never use the ">" operator, as this will delete and replace the target with a new TEXT file.
Parameters
----------
The normal script parameters $#, $0...$n will be set up with any items dropped onto the application. Specifically:
$# = The number of parameters (1 = script only, 2 = script + 1 param, etc.)
$0 = The name of the script (not a full pathname)
$1 = The full pathname of the first dropped item
$2 = The full pathname of the second dropped item
...
The parameters may be files, folders, or disks but are always represented as pathnames. Remember to use quotes around these variables, as in
chattr "$1" -c 'R*ch'
Limitations: The total length of all dropped pathnames may not exceed 4096 characters. Beyond this input is ignored. Only those files dropped on the application as it is opened are set as parameters. Anything dropped on the script after it is running is ignored (the finder is given an errAEEventNotHandled).
System Variables
----------------
On startup, drag and drop applications search out the nShell application and set their paths based upon that directory. The defaults are:
PWD = "drag and drop application directory"
HOME = "nShell application directory"
PATH = ":/nShell application directory:bin"
TMP = "nShell application directory:tmp"
Memory
------
I've set the default to memory size to 200k. When I dropped 88 files on a script it used up a lot of that. If you think you are going to need it, bump the memory. nShell and the template start complaining about low memory when 80k is left.
Hint #1
-------
If you're not sure what's going on with a drag an drop script, add
env
echo ' '
echo 'Press <Return> to continue...'
echo ' '
read foo
as the first line. That'll tell you what your dropped files ended up looking like.
And if you don't want to fall off the end of the script right away, use 'delay 5' or 'read foo' or something as the last line.
Hint #2
-------
Any script can run any other script. So create a drag and drop application containing the line
"$1"
and you have a program that will run any nShell script dropped on it.
System 6
--------
Under System 6, "nShell™ drop" applications serve as "clickable scripts". There is no way to provide start-up parameters. In addition, the applications must reside in the nShell application directory when running under System 6.