How to set mutliple words variable from command line

I'm writing a script (C shell) to search for a pattern in file. For example
scriptname pattern file1 file2 filenN
I use for loop to loop through arguments argv, and it does the job if all arguments are supplied. However if only one argument is supplied (in that case pattern ) it should ask to input file name or names, and then check for pattern. How I can set variable to include multiple words input from command line so I can use it in loop. Or even better is it possible to assign command line input to argv, so I don�t have to use the same loop twice only because it is different variable name (one to loop through argv if more than on argument, and second to loop through filenames variable if only one argument supplied). Below is the part of my script which is causing problem:

set pattern = $1 
if ($#argv == 1) then
    echo "Enter name of files"
    set filenames = $< #how I can set it to accept more than word?
endif

Any help will much appreciated.

Something like that ? (bash shell, can be translated)

#!/bin/bash
if [ ${#@} = 0 ]
then
  echo "error no arguments" # or anything else
else
     PATTERN=$1
     if [ ${#@} = 1  ]
     then
          read -p "Enter name(s) of files (separated by spaces and delimited wit quotes if containing spaces)" FILES
     else
          shift
          FILES="$@"
     fi
fi
for FILE in $FILES
do
     # what you want to do with each file i.e. :
     grep $PATTERN $FILES
done

It might also be appropriate to ask why you are using C shell.

If you were weaned on it and just don't want to waste all that you have learned, that's one thing, but far too often people think "Oh, "C" shell. That must be C-like, so it's better".

Generally speaking, it's not. It has very poor redirection abilities and other faults (try searching Google for "Csh Programming Considered Harmful").

If you are going to be doing shell scripting as part of your work, you absolutely want to know Bash - you won't find too many places still using csh for anything (a few very ancient Sun BSD boxes).

And (as you saw here) if you ask for scripting help, most people aren't going to give you an answer using csh - almost always it will be Bash nowadays.

Thanks for response frans, but it doesn't solve my problem. I use exactly the same analogy, as you described on bash example, but in C-shell I can't initialize variable with more than one word input from command line, or I don't know how to do this.

Tony, I know C-shell is not recommended, I have read already "Csh Programming Considered Harmful". Unfortunately, they use C-shell at the university and all students have to learn C. As soon as I'm done, I'm going to switch to bash.

Hi Tony, I agree that the Bourne Shell derivatives have become the lineage of shells to use. However I do not think the suggestion that almost always people are using bash is an accurate statement. Have a look at this poll and judge for yourself. I for one think that for interactive use bash has its advantages, however for scripting in my experience ksh93 is the more advanced free shell, plus it is quite a bit faster. If you require portability you will often have to restrict yourself to the posix standard anyway. Not trying to start a this shell vs. that shell thing, just wanted to make the point that there are varying opinions in this matter.

Yeah, I don't disagree - and as the poll shows, you will find ksh often also.

Too bad his university is so behind the times. On the other hand, too many Linux uswers today are unaware of anything BUT bash, so maybe it's a good thing in disguise.