func init // initialize instance this.type = isdef("Bits") ? 1 : 105 sys.add_var(this.name, this.type) // initialize properties blk_init.println(this.codename, ' = ', this.make_min(), ';') if(linked("doMin")) sys.add_var('min', this.type) blk_init.println(this.min, ' = ', this.props("Min").value, ';') end if(linked("doMax")) sys.add_var('max', this.type) blk_init.println(this.max, ' = ', this.props("Max").value, ';') end if(linked("doStep")) sys.add_var('step', this.type) blk_init.println(this.step, ' = ', this.props("Step").value, ';') end end func make_min() return(linked("doMin") ? this.min : linked("Min") ? sys.to_type(d("Min"), this.type) : this.props("Min").value) end func make_max() return(linked("doMax") ? this.max : linked("Max") ? sys.to_type(d("Max"), this.type) : this.props("Max").value) end func make_step() return(linked("doStep") ? this.step : linked("Step") ? sys.to_type(d("Step"), this.type) : this.props("Step").value) end func doNext() if(isdef("Type")) // Increment blk.print('if(', this.codename, ' > ', this.make_max(), ') ') if(linked("onThroughMax")) blk.println('{').inc() .println(this.codename, ' = ', this.make_min(), ';') event("onThroughMax", sub(this.codename, this.type)) blk.dec().println('}') else blk.println(this.codename, ' = ', this.make_min(), ';') end else // Decrement blk.print('if(', this.codename,' < ', this.make_min(), ') ') if(linked("onThroughMin")) blk.println('{').inc() .println(this.codename, ' = ', this.make_max(), ';') event("onThroughMin", sub(this.codename, this.type)) blk.dec().println('}') else blk.println(this.codename, ' = ', this.make_max(), ';') end end blk.println(this.codename, isdef("Type") ? ' +' : ' -', '= ', this.make_step(), ';') event("onNext", sub(this.codename, this.type)) end func doPrev() if(isdef("Type")) // Increment blk.print('if(', this.codename,' < ', this.make_min(),') ') if(linked("onThroughMin")) blk.println('{').inc() .println(this.codename, ' = ', this.make_max(), ';') event("onThroughMin", sub(this.codename, this.type)) blk.dec().println('}') else blk.println(this.codename, ' = ', this.make_max(), ';') end else // Decrement blk.print('if(', this.codename, ' > ', this.make_max(), ') ') if(linked("onThroughMax")) blk.println('{').inc() .println(this.codename, ' = ', this.make_min(), ';') event("onThroughMax", sub(this.codename, this.type)) blk.dec().println('}') else blk.println(this.codename, ' = ', this.make_min(), ';') end end blk.println(this.codename, isdef("Type") ? ' -' : ' +', '= ', this.make_step(), ';') event("onNext", sub(this.codename, this.type)) end func doReset() blk.println(this.codename, ' = ', isdef("Type") ? this.make_min() : this.make_max(), ';') //event("onNext", sub(this.codename, this.type)) end func doValue(data) blk.println(this.codename, ' = ', sys.to_type(data, this.type), ';') //event("onNext", sub(this.codename, this.type)) end func doMin(data) blk.println(this.min, ' = ', sys.to_type(d("Min"), this.type), ';') end func doMax(data) blk.println(this.max, ' = ', sys.to_type(d("Max"), this.type), ';') end func doStep(data) blk.println(this.step, ' = ', sys.to_type(d("Step"), this.type), ';') end func Count return(sub(this.codename, this.type)) end