Question: Maple Procedure error

Hey, I have made this procedure for the trapezium rule but I get an error when I perform this calculation.

Procedure is 

TrapRule:=proc(f,N,a,b)
local k,sum1,h,i:
h:=(b-a)/N:
sum1:=0:
for i from 1 by 1 to n-1 do
sum1:=sum1+f(a+i*h):
end do:
k:=(h/2)*(f(a)+2*sum+f(b)):
return (k):
end proc:
When I try calculating (TrapRule(exp(x),4,-3,1)); I get 
Error, (in TrapRule) final value in for loop must be numeric or character
Can anyone help me out? Thanks

Please Wait...