Cannot see UNEXPECTED Symbol error cause!

Rob, …Am I really needing new glasses?

What is wrong here, I get this error

…book/Library/Application Support/Outlaw/Sandbox/126/Scenes/dashboard.lua:190: unexpected symbol near ‘then’

—The code is copied from Corona example newButton widget and I have added another test on target.id

— and it is failing…     }:{|    , thanks

local function onButtonEvent( event )
   local phase = event.phase
   local target = event.target
      if ( “began” == phase ) then
          print( target.id … " pressed" )

            If  (2 == target.id )  then    ----- <=========This is the line in error CAN ANYONE SEE THE PROB?
              target:setLabel( “DOCs” )  --set a new label
          else
             target:setLabel( “END” )  --set a new label
            end

   elseif ( “ended” == phase ) then
      print( target.id … " released" )
      target:setLabel( target.baseLabel )  --reset the label
   end
   return true
end

I don’t think Lua uses parentheses to enclose conditions in the if-then-else :-) ie try removing the brackets :slight_smile:

You seem to be using capital i in the word if. Should be lower case.

If &nbsp;(2 == target.id ) &nbsp;then &nbsp;-- should be if &nbsp;

Capital “I” instead of lowercase “i” on the “if” :slight_smile:

Edit: Sorry, didn’t see jonjonsson’s post…

C

Well done, Thanks… I have been looking at that for about three hours!

The message was a red herring pointing to the word then!

Opticians next stop…

I don’t think Lua uses parentheses to enclose conditions in the if-then-else :-) ie try removing the brackets :slight_smile:

You seem to be using capital i in the word if. Should be lower case.

If &nbsp;(2 == target.id ) &nbsp;then &nbsp;-- should be if &nbsp;

Capital “I” instead of lowercase “i” on the “if” :slight_smile:

Edit: Sorry, didn’t see jonjonsson’s post…

C

Well done, Thanks… I have been looking at that for about three hours!

The message was a red herring pointing to the word then!

Opticians next stop…