\ ob.ctrl.interpreter \ \ ctrl_interpreter \ class of interpreter designed to handle continuous control, and facilitate \ "on-the-fly" reconfiguration of the controllers. \ \ The on and off functions can access the object, and object specific data, \ via the object address stored in the CURRENT-INTERPRETER variable. \ Alternatively, you can create a subclass and override the ELEMENT.ON: \ and/or the ELEMENT.OFF: method. \ \ Code: Han-earl Park \ Copyright 2000 Buster & Friends C-ALTO Labs \ (Valencia, April 2000 - \ \ MOD: HeP 04/12/00 Start the io_interpreter component. \ MOD: HeP 04/15/00 Rename as ctrl_interpreter, and start a "general" purpose \ version for use outside io. \ MOD: HeP 04/16/00 Add the }STUFF: method. \ MOD: HeP 05/05/00 Add the instance variable iv-free-on-close? include? task-interpreter myt:interpreter anew task-ctrl_interpreter method PUT.#CONTROLLERS: method GET.#CONTROLLERS: method PUT.CONTROL#: method GET.CONTROL#: :class OB.CTRL.INTERPRETER iv-interp-#ctrl false iv=> iv-free-on-close? ;m :m RAW.OPEN: ( -- ) raw.open: super \ many: iv-interp-ctrl# iv-interp-#ctrl < IF iv-interp-#ctrl new: iv-interp-ctrl# true iv=> iv-free-on-close? THEN ;m :m RAW.CLOSE: ( -- ) raw.close: super \ iv-free-on-close? IF free: iv-interp-ctrl# THEN ;m :m FREE: ( -- ) free: super free: iv-interp-ctrl# ;m \ number of controllers :m PUT.#CONTROLLERS: ( n -- , set number of controllers available ) dup 0>= IF dup iv=> iv-interp-#ctrl new: iv-interp-ctrl# \ false iv=> iv-free-on-close? ELSE " put.#controllers:" " the number of controllers cannot be a negative value" er_warning ob.report.error drop THEN ;m :m GET.#CONTROLLERS: ( -- n ) iv-interp-#ctrl ;m \ controllers : CTRL.INTERP.REPORT.ERROR ( $ -- , print error message ) " invalid controller index" er_return ob.report.error ; :m PUT.CONTROL#: ( ctrl# indx -- , set controller number ) dup 0 iv-interp-#ctrl within? IF to: iv-interp-ctrl# ELSE " put.control#:" CTRL.INTERP.REPORT.ERROR 2drop THEN ;m :m GET.CONTROL#: ( indx -- ctrl# , retrieve controller number ) dup 0 iv-interp-#ctrl within? IF at: iv-interp-ctrl# ELSE " get.control#:" CTRL.INTERP.REPORT.ERROR drop THEN ;m :m }STUFF: ( name preset# offset lo hi bend -- ) stuff.depth iv=> iv-interp-#ctrl }stuff: iv-interp-ctrl# ;m :m PRINT: ( -- ) print: super ." #Controllers = " iv-interp-#ctrl 4 .r cr many: iv-interp-ctrl# IF iv-interp-#ctrl 0 DO space ." indx# = " i 2 .r tab ." Control# = " i at: iv-interp-ctrl# 3 .r cr LOOP THEN ;m ;class