Question: Error, reserved word `if` unexpected

I don't understand whats wrong with my code
r(x):=proc(x) 
    local y
    if (x=1)
    then    
    y=1;
    else 
        y=0;
    end if; 
    return y
    end proc    

Error, reserved word `if` unexpected

I'm also having trouble getting this code to work:

h(x):=proc(x) 
    if (x= infinity)
    then    
    return 1 ;
    else 
        return 0;
        end if; 
    end proc 
theres no error but h(0) just returns h(0) not either value as I would like

Please Wait...