how to prompt the user to enter an array in tcsh

Hello,

I am writing a script that requires the user to enter a string of numbers:

 
ex: 134 345 865 903

This command only allows for one variable to be entered:

 
set "var" = $<

and than once I got the array I want to change it to a list with each input on a different line:

 
ex:
134
345
865
903

Does anyone know how to accomplish this in tcsh.

Thanks :slight_smile:

If you want the user input to be an array then I think you may have the double quotes in the wrong place.

Instead of

set "var" = $<

Try

set var = "$<"

For example:

startover:
echo Please enter a string of numbers eg 134 345 865 903
set num = "$<"
if ( "$num" == "" ) then
 echo "You need to enter a list of numbers"
 goto startover
endif

You should be able to create a list of your array easy enough. Give it a try :wink: