if else command syntax error

can anyone tell me what`s going wrong with my if else statement?

set exam=(AAA BBB CCC)

foreach ii ($exam)
if ($ii -eq "AAA")
do
echo "PASS"
else
echo "FAILED"
done
end

Use = for string comparison and eq for numerical comparison

if ($ii = "AAA")

I have set to = but for the following error.

if: Expression syntax.

Your if syntax is invalid (assume csh).

set exam=(AAA BBB CCC)
foreach ii ($exam)
   if ("$ii" = "AAA") then
      echo "PASS"
   else
      echo "FAILED"
   endif
end

Jean-Pierre.

Looks like you have a mix of csh and sh style syntax. For sh it would be

exam="AAA BBB CCC"
for ii in $exam
do
   if [ "$ii" = "AAA" ]
   then
      echo "PASS"
   else
      echo "FAILED"
   fi
done

aigles csh is correct except the test in the if line needs '==' not '='.