if ("$myVar" == "") then
echo "the string is blank"
endif
Note that in csh, it is an error to attempt to access an undefined variable. (From a Bourne shell perspective, it's as if `set -u` was always in effect.) To test whether a variable is defined, use `$?myVar`:
if (! $?myVar) then
echo "myVar is undefined"
else
if ("$myVar" == "") then
echo "myVar is empty"
else
echo "myVar is non-empty"
endif
endif
Note the use of a nested `if`. You can't use `else if` here, because that would cause the `"$myVar" == ""` condition to be parsed even when the first condition is true. If you want to treat the empty and the undefined case in the same way, first set the variable:
if (! $?myVar) then
set myVar=""
endif
if ("$myVar" == "") then
echo "myVar is empty or was undefined"
else
echo "myVar is non-empty"
endif