There is no reason why you can't check for 1000 joysticks. It may seem excessive but at least you know there won't be that many joysticks connected so you're covered.
Something like this (untested):
Btw, is that you Hans?
Something like this (untested):
For jt=0 to 999 If JoyType(jt)>0 Then Print "Joystick type "+JoyType(jt)+" attached to port "+jt Next
Btw, is that you Hans?