ループの中に、 n(変数)=button()==(特定のボタン定数) と書くか、 if button()==(特定のボタン定数) then n(変数)=1 else n(変数)=0 と書けばよろしいかと