If you know how to do it on the first controller then you're probably just missing the line:
selectmidi x
where x is the device (1-4) as configured in your midi settings. By default, all midiout commands go to device 1 unless the above command is used ahead of time to steer the output.
Good luck!