In the splotem example the list of NDFs on the command line required the inclusion of the .sdf file extension. Having to supply the .sdf for an NDF is abnormal. For reasons of familiarity and ease of use, you probably want your relevant scripts to accept a list of NDF names and to append the file extension automatically before the list is passed to foreach. Here is an example. It is a modified version of the splotem script.
#!/bin/csh
figaro # Only need be invoked once per process
# Append the HDS file extension to the supplied arguments.
set ndfs
set i = 1
while ( $i <= $#argv )
set ndfs = ($ndfs[*] $argv[i]".sdf")
@ i = $i + 1
end
# Plot each 1-dimensional NDFs.
foreach file ($ndfs[*])
if (-e $file) then
splot $file:r accept
endif
end
This loops through all the arguments and appends the HDS-file extension to them by using a work array ndfs. The
set defines a value for a shell
variable; don't forget the spaces around the =.
ndfs[*] means all the elements of variable ndfs. The loop
adds elements to ndfs which is initialised without a value.
Note the necessary parentheses around the expression ($ndfs[*]
$argv[i]".sdf").
On the command line the wildcards have to be passed verbatim, because the shell will try to match with files than don't have the .sdf file extension. Thus you must protect the wildcards with quotes. It's a nuisance, but the advantages of wildcards more than compensate.
% ./splotem myndf 'arc[a-z]' 'hd[0-9]*'
% ./noise myndf 'ccd[a-z]'
If you forget to write the ' ', you'll receive a No match
error.
C-shell Cookbook