Odd problem with if/then statements

I’m having problems getting if/then statements with multiple actions to work properly.

When I try something like:

if variableA=variableB then set variableC to "1"
set variableD to "2"
end if

I get the error message

So I tried removing end if, and variableD is always set to “2” no matter what happens with the if/then statement.

I’ve also tried:

if variableA=variableB then set variableC to "1" and set variableD to "2"

But that doesn’t work either.

What am I doing wrong!?

hi tor,

i think it has something to do with setting ‘variableC’ on the same line as the ‘if’ statement.

you don’t say what you are trying to accomplish in the long run, but this works for me:

set variableA to 1
set variableB to 2
if variableA = variableB then
	set variableC to "1"
	set variableD to "2"
	display dialog variableD
end if

waltr is correct. If a statement follows a “then” in an if statement, the if statement is complete; no “end if” required. If you want more than one statement to follow an if test, then each must follow on a separate line terminated by a final “end if”, but nothing can follow the “then” in that case.

Thanks guys! That was indeed the problem.