o<mysetspeed> sub
   (DEBUG, S#<speed> setspeed)
   o10 if [#<speed> LE 950]
      o11 if [#4997 NE 1]
         (MSG, Set spindle speed selection belt in AC1 position)
         O<myspindlegain> call [0.48483] [20.16466]
         #4997 = 1
      o11 endif
   o10 else
      o20 if [#<speed> LE 1500]
         o21 if [#4997 NE 2]
            (MSG, Set spindle speed selection belt in AC2 position)
            O<myspindlegain> call [0.32571] [-8.05714]
            #4997 = 2
         o21 endif
      o20 else
         o30 if [#<speed> LE 2400]
            o31 if [#4997 NE 3]
               (MSG, Set spindle speed selection belt in AC3 position)
               O<myspindlegain> call [0.20098] [22.64117]
             #4997 = 3
            o31 endif
         o30 else
            (MSG, Unsupported spindle speed. will continue anyway. Safest is probably to abort and regenerate program)
         o30 endif
      o20 endif
   o10 endif
   S#<speed>
   M0
o<mysetspeed> endsub [1]
M2
