1.  function RankPost_EPost()
        ChatFrame1:AddMessage("My Arena Stats:");
        for i=1,3 do
            t,s,r,_,_,_,_,_,_,ra=GetArenaTeam(i);
            if (t ~= nil) then
                ChatFrame1:AddMessage(""..s.."v"..s.." - "..t..": "..r.." (Rank "..ra..")");
            else
                if(i==1) then
                    ChatFrame1:AddMessage("No arena team found.");  
                end
            end
        end
     end
    

    I'm using the preceding code to get and echo the specifics of arena teams. This works fine; there are no errors, but if I use the following code, I get "Message: Interface\AddOns\RankPost\RankPost.lua:86: 'end' expected (to close 'function' at line 41) near '<eof>'"

     function RankPost_EPost()
        ChatFrame1:AddMessage("My Arena Stats:");
        for i=1,3 do
            t,s,r,_,_,_,_,_,_,ra=GetArenaTeam(i);
            if (t ~= nil) then
                ChatFrame1:AddMessage(""..s.."v"..s.." - "..t..": "..r.." (Rank "..ra..")");
            else
                if(i==1) then
                    ChatFrame1:AddMessage("No 2s team found.");
                else if(i==2) then
                    ChatFrame1:AddMessage("No 3s team found."); 
                end
            end
        end
     end
    

    This is hard for me to understand because there aren't any new functions added or any other clause that needs an end and yet this error persists if I add a new if clause. Can anyone help out a noob who's struggling to see where he's gone wrong?

    Thanks in advance.

  2. It's a pretty subtle error. You have:

                 else if(i==2) then
    

    The proper syntax is elseif (i==2). Basically else if opens two conditionals.

  3. facepalm

    Experience with different languages was screwing me up there. Thanks a lot for that mate.